chore: change C-style casts to dynamic_cast (#1299)
This commit is contained in:
parent
87027fbfd9
commit
4422655b32
@ -14,7 +14,7 @@ namespace big
|
|||||||
g_player_service->iterate([](auto& plyr) {
|
g_player_service->iterate([](auto& plyr) {
|
||||||
if (plyr.second->is_host())
|
if (plyr.second->is_host())
|
||||||
{
|
{
|
||||||
((player_command*)(command::get(RAGE_JOAAT("breakup"))))->call(plyr.second, {});
|
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("breakup")))->call(plyr.second, {});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -39,10 +39,10 @@ namespace big
|
|||||||
if (kick)
|
if (kick)
|
||||||
{
|
{
|
||||||
g_fiber_pool->queue_job([player] {
|
g_fiber_pool->queue_job([player] {
|
||||||
((player_command*)command::get(RAGE_JOAAT("bailkick")))->call(player, {});
|
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("bailkick")))->call(player, {});
|
||||||
((player_command*)command::get(RAGE_JOAAT("nfkick")))->call(player, {});
|
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("nfkick")))->call(player, {});
|
||||||
script::get_current()->yield(700ms);
|
script::get_current()->yield(700ms);
|
||||||
((player_command*)command::get(RAGE_JOAAT("breakup")))->call(player, {});
|
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("breakup")))->call(player, {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ namespace big
|
|||||||
|
|
||||||
if (notify)
|
if (notify)
|
||||||
{
|
{
|
||||||
char notification[500]{};// I don't like using sprintf but there isn't an alternative afaik
|
char notification[500]{}; // I don't like using sprintf but there isn't an alternative afaik
|
||||||
snprintf(notification, sizeof(notification), m_notify_message, player->get_name());
|
snprintf(notification, sizeof(notification), m_notify_message, player->get_name());
|
||||||
g_notification_service->push_warning("Protections", notification);
|
g_notification_service->push_warning("Protections", notification);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ namespace big
|
|||||||
template<template_str cmd_str, ImVec2 size = ImVec2(0, 0), ImVec4 color = ImVec4(0.24f, 0.23f, 0.29f, 1.00f)>
|
template<template_str cmd_str, ImVec2 size = ImVec2(0, 0), ImVec4 color = ImVec4(0.24f, 0.23f, 0.29f, 1.00f)>
|
||||||
static void player_command_button(player_ptr player = g_player_service->get_selected(), const std::vector<std::uint64_t> args = {}, std::optional<const std::string_view> label_override = std::nullopt)
|
static void player_command_button(player_ptr player = g_player_service->get_selected(), const std::vector<std::uint64_t> args = {}, std::optional<const std::string_view> label_override = std::nullopt)
|
||||||
{
|
{
|
||||||
static player_command* command = (player_command*)command::get(rage::consteval_joaat(cmd_str.value));
|
static player_command* command = dynamic_cast<player_command*>(command::get(rage::consteval_joaat(cmd_str.value)));
|
||||||
if (command == nullptr)
|
if (command == nullptr)
|
||||||
return ImGui::Text("INVALID COMMAND");
|
return ImGui::Text("INVALID COMMAND");
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ namespace big
|
|||||||
template<template_str cmd_str>
|
template<template_str cmd_str>
|
||||||
static void command_checkbox(std::optional<const std::string_view> label_override = std::nullopt)
|
static void command_checkbox(std::optional<const std::string_view> label_override = std::nullopt)
|
||||||
{
|
{
|
||||||
static bool_command* command = (bool_command*)command::get(rage::consteval_joaat(cmd_str.value));
|
static bool_command* command = dynamic_cast<bool_command*>(command::get(rage::consteval_joaat(cmd_str.value)));
|
||||||
if (command == nullptr)
|
if (command == nullptr)
|
||||||
return ImGui::Text("INVALID COMMAND");
|
return ImGui::Text("INVALID COMMAND");
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ namespace big
|
|||||||
player->is_spammer = true;
|
player->is_spammer = true;
|
||||||
if (g.session.kick_chat_spammers)
|
if (g.session.kick_chat_spammers)
|
||||||
{
|
{
|
||||||
((player_command*)command::get(RAGE_JOAAT("breakup")))->call(player, {});
|
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("breakup")))->call(player, {});
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -177,7 +177,7 @@ namespace big
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (g.reactions.breakup_others.karma)
|
if (g.reactions.breakup_others.karma)
|
||||||
((player_command*)command::get(RAGE_JOAAT("breakup")))->call(player, {});
|
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("breakup")))->call(player, {});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -185,7 +185,8 @@ namespace big
|
|||||||
session::add_infraction(player, Infraction::BREAKUP_KICK_DETECTED);
|
session::add_infraction(player, Infraction::BREAKUP_KICK_DETECTED);
|
||||||
|
|
||||||
if (g.reactions.breakup_others.karma)
|
if (g.reactions.breakup_others.karma)
|
||||||
((player_command*)command::get(RAGE_JOAAT("breakup")))->call(player, {});
|
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("breakup")))->call(player, {});
|
||||||
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ namespace big
|
|||||||
break;
|
break;
|
||||||
case eRemoteEvent::Crash: g.reactions.crash.process(plyr); return true;
|
case eRemoteEvent::Crash: g.reactions.crash.process(plyr); return true;
|
||||||
case eRemoteEvent::Crash2:
|
case eRemoteEvent::Crash2:
|
||||||
if (args[2] > 32)// actual crash condition is if args[2] is above 255
|
if (args[2] > 32) // actual crash condition is if args[2] is above 255
|
||||||
{
|
{
|
||||||
g.reactions.crash.process(plyr);
|
g.reactions.crash.process(plyr);
|
||||||
return true;
|
return true;
|
||||||
@ -321,7 +321,7 @@ namespace big
|
|||||||
case eRemoteEvent::InteriorControl:
|
case eRemoteEvent::InteriorControl:
|
||||||
{
|
{
|
||||||
int interior = (int)args[2];
|
int interior = (int)args[2];
|
||||||
if (interior < 0 || interior > 161)// the upper bound will change after an update
|
if (interior < 0 || interior > 161) // the upper bound will change after an update
|
||||||
{
|
{
|
||||||
if (auto plyr = g_player_service->get_by_id(player->m_player_id))
|
if (auto plyr = g_player_service->get_by_id(player->m_player_id))
|
||||||
session::add_infraction(plyr, Infraction::TRIED_KICK_PLAYER);
|
session::add_infraction(plyr, Infraction::TRIED_KICK_PLAYER);
|
||||||
@ -337,7 +337,7 @@ namespace big
|
|||||||
{
|
{
|
||||||
if (auto plyr = g_player_service->get_by_id(player->m_player_id))
|
if (auto plyr = g_player_service->get_by_id(player->m_player_id))
|
||||||
{
|
{
|
||||||
((player_command*)command::get(RAGE_JOAAT("breakup")))->call(plyr, {});
|
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("breakup")))->call(plyr, {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "backend/command.hpp"
|
||||||
|
#include "backend/player_command.hpp"
|
||||||
#include "natives.hpp"
|
#include "natives.hpp"
|
||||||
|
#include "services/gta_data/gta_data_service.hpp"
|
||||||
|
#include "services/vehicle/persist_car_service.hpp"
|
||||||
#include "util/entity.hpp"
|
#include "util/entity.hpp"
|
||||||
#include "util/ped.hpp"
|
#include "util/ped.hpp"
|
||||||
#include "util/teleport.hpp"
|
#include "util/teleport.hpp"
|
||||||
#include "services/vehicle/persist_car_service.hpp"
|
|
||||||
#include "backend/command.hpp"
|
|
||||||
#include "backend/player_command.hpp"
|
|
||||||
#include "services/gta_data/gta_data_service.hpp"
|
|
||||||
|
|
||||||
namespace big
|
namespace big
|
||||||
{
|
{
|
||||||
@ -72,17 +73,16 @@ namespace big
|
|||||||
}},
|
}},
|
||||||
{"COPY VEHICLE",
|
{"COPY VEHICLE",
|
||||||
[this] {
|
[this] {
|
||||||
Vehicle v = persist_car_service::clone_ped_car(PLAYER::PLAYER_PED_ID(), m_handle);
|
Vehicle v = persist_car_service::clone_ped_car(PLAYER::PLAYER_PED_ID(), m_handle);
|
||||||
script::get_current()->yield();
|
script::get_current()->yield();
|
||||||
PED::SET_PED_INTO_VEHICLE(PLAYER::PLAYER_PED_ID(), v, -1);
|
PED::SET_PED_INTO_VEHICLE(PLAYER::PLAYER_PED_ID(), v, -1);
|
||||||
}},
|
}},
|
||||||
{"BOOST",
|
{"BOOST",
|
||||||
[this] {
|
[this] {
|
||||||
if (entity::take_control_of(m_handle))
|
if (entity::take_control_of(m_handle))
|
||||||
VEHICLE::SET_VEHICLE_FORWARD_SPEED(m_handle, 79);
|
VEHICLE::SET_VEHICLE_FORWARD_SPEED(m_handle, 79);
|
||||||
else
|
else
|
||||||
g_notification_service->push_warning("Toxic", "Failed to take control of vehicle.");
|
g_notification_service->push_warning("Toxic", "Failed to take control of vehicle.");
|
||||||
|
|
||||||
}},
|
}},
|
||||||
{"LAUNCH",
|
{"LAUNCH",
|
||||||
[this] {
|
[this] {
|
||||||
@ -95,13 +95,12 @@ namespace big
|
|||||||
[this] {
|
[this] {
|
||||||
if (ped::get_player_from_ped(VEHICLE::GET_PED_IN_VEHICLE_SEAT(m_handle, -1, 0)) != NULL)
|
if (ped::get_player_from_ped(VEHICLE::GET_PED_IN_VEHICLE_SEAT(m_handle, -1, 0)) != NULL)
|
||||||
{
|
{
|
||||||
static player_command* command = (player_command*)command::get(rage::consteval_joaat("vehkick"));
|
static player_command* command = dynamic_cast<player_command*>(command::get(rage::consteval_joaat("vehkick")));
|
||||||
command->call(ped::get_player_from_ped(VEHICLE::GET_PED_IN_VEHICLE_SEAT(m_handle, -1, 0)), {});
|
command->call(ped::get_player_from_ped(VEHICLE::GET_PED_IN_VEHICLE_SEAT(m_handle, -1, 0)), {});
|
||||||
}
|
}
|
||||||
|
|
||||||
TASK::CLEAR_PED_TASKS_IMMEDIATELY(VEHICLE::GET_PED_IN_VEHICLE_SEAT(m_handle, -1, 0));
|
TASK::CLEAR_PED_TASKS_IMMEDIATELY(VEHICLE::GET_PED_IN_VEHICLE_SEAT(m_handle, -1, 0));
|
||||||
TASK::CLEAR_PED_TASKS_IMMEDIATELY(m_handle);
|
TASK::CLEAR_PED_TASKS_IMMEDIATELY(m_handle);
|
||||||
|
|
||||||
}},
|
}},
|
||||||
{"DELETE",
|
{"DELETE",
|
||||||
[this] {
|
[this] {
|
||||||
@ -114,48 +113,54 @@ namespace big
|
|||||||
teleport::into_vehicle(m_handle);
|
teleport::into_vehicle(m_handle);
|
||||||
}}}};
|
}}}};
|
||||||
|
|
||||||
s_context_menu ped_menu{ContextEntityType::PED, 0, {}, {
|
s_context_menu ped_menu{ContextEntityType::PED,
|
||||||
{"DISARM",
|
0,
|
||||||
[this] {
|
{},
|
||||||
for (auto& [_, weapon] : g_gta_data_service->weapons())
|
{{"DISARM",
|
||||||
WEAPON::REMOVE_WEAPON_FROM_PED(m_handle, weapon.m_hash);
|
[this] {
|
||||||
}},
|
for (auto& [_, weapon] : g_gta_data_service->weapons())
|
||||||
{"RAGDOLL",
|
WEAPON::REMOVE_WEAPON_FROM_PED(m_handle, weapon.m_hash);
|
||||||
[this] {
|
}},
|
||||||
PED::SET_PED_TO_RAGDOLL(m_handle, 2000, 2000, 0, 0, 0, 0);
|
{"RAGDOLL",
|
||||||
|
[this] {
|
||||||
|
PED::SET_PED_TO_RAGDOLL(m_handle, 2000, 2000, 0, 0, 0, 0);
|
||||||
}},
|
}},
|
||||||
{"DANCE", [this] {
|
{"DANCE", [this] {
|
||||||
ped::ped_play_animation(m_handle, "mini@strip_club@private_dance@part1", "priv_dance_p1");
|
ped::ped_play_animation(m_handle, "mini@strip_club@private_dance@part1", "priv_dance_p1");
|
||||||
}}
|
}}}};
|
||||||
}};
|
|
||||||
|
|
||||||
s_context_menu object_menu{ContextEntityType::OBJECT, 0, {}, {}};
|
s_context_menu object_menu{ContextEntityType::OBJECT, 0, {}, {}};
|
||||||
|
|
||||||
s_context_menu player_menu{ContextEntityType::PLAYER, 0, {}, {
|
s_context_menu player_menu{ContextEntityType::PLAYER,
|
||||||
{"STEAL IDENTITY", [this] {
|
0,
|
||||||
ped::steal_identity(m_handle);
|
{},
|
||||||
}},
|
{{"STEAL IDENTITY",
|
||||||
{"BREAKUP KICK", [this] {
|
[this] {
|
||||||
static player_command* command = (player_command*)command::get(rage::consteval_joaat("breakup"));
|
ped::steal_identity(m_handle);
|
||||||
|
}},
|
||||||
|
{"BREAKUP KICK",
|
||||||
|
[this] {
|
||||||
|
static player_command* command = dynamic_cast<player_command*>(command::get(rage::consteval_joaat("breakup")));
|
||||||
|
command->call(ped::get_player_from_ped(m_handle), {});
|
||||||
|
}},
|
||||||
|
{"KICK",
|
||||||
|
[this] {
|
||||||
|
static player_command* command = dynamic_cast<player_command*>(command::get(rage::consteval_joaat("nfkick")));
|
||||||
|
static player_command* command1 = dynamic_cast<player_command*>(command::get(rage::consteval_joaat("shkick")));
|
||||||
|
static player_command* command2 = dynamic_cast<player_command*>(command::get(rage::consteval_joaat("endkick")));
|
||||||
|
command->call(ped::get_player_from_ped(m_handle), {});
|
||||||
|
command1->call(ped::get_player_from_ped(m_handle), {});
|
||||||
|
command2->call(ped::get_player_from_ped(m_handle), {});
|
||||||
|
}},
|
||||||
|
{"DISARM",
|
||||||
|
[this] {
|
||||||
|
static player_command* command = dynamic_cast<player_command*>(command::get(rage::consteval_joaat("remweaps")));
|
||||||
|
command->call(ped::get_player_from_ped(m_handle), {});
|
||||||
|
}},
|
||||||
|
{"RAGDOLL", [this] {
|
||||||
|
static player_command* command = dynamic_cast<player_command*>(command::get(rage::consteval_joaat("ragdoll")));
|
||||||
command->call(ped::get_player_from_ped(m_handle), {});
|
command->call(ped::get_player_from_ped(m_handle), {});
|
||||||
}},
|
}}}};
|
||||||
{"KICK", [this] {
|
|
||||||
static player_command* command = (player_command*)command::get(rage::consteval_joaat("nfkick"));
|
|
||||||
static player_command* command1 = (player_command*)command::get(rage::consteval_joaat("shkick"));
|
|
||||||
static player_command* command2 = (player_command*)command::get(rage::consteval_joaat("endkick"));
|
|
||||||
command->call(ped::get_player_from_ped(m_handle), {});
|
|
||||||
command1->call(ped::get_player_from_ped(m_handle), {});
|
|
||||||
command2->call(ped::get_player_from_ped(m_handle), {});
|
|
||||||
}},
|
|
||||||
{"DISARM", [this] {
|
|
||||||
static player_command* command = (player_command*)command::get(rage::consteval_joaat("remweaps"));
|
|
||||||
command->call(ped::get_player_from_ped(m_handle), {});
|
|
||||||
}},
|
|
||||||
{"RAGDOLL", [this] {
|
|
||||||
static player_command* command = (player_command*)command::get(rage::consteval_joaat("ragdoll"));
|
|
||||||
command->call(ped::get_player_from_ped(m_handle), {});
|
|
||||||
}}
|
|
||||||
}};
|
|
||||||
|
|
||||||
s_context_menu shared_menu{ContextEntityType::SHARED,
|
s_context_menu shared_menu{ContextEntityType::SHARED,
|
||||||
0,
|
0,
|
||||||
|
Reference in New Issue
Block a user