fix(MultiKick): check against player nullptr (#2057)

* fix(MultiKick): check player ptr before using it

* fix(Kick): guard other commands against nullptr player ptr
This commit is contained in:
Andreas Maerten 2023-08-29 23:58:44 +02:00 committed by GitHub
parent 4871dbd705
commit 4c6226d022
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 17 additions and 2 deletions

View File

@ -18,6 +18,9 @@ namespace big
virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override
{
if (!player)
return;
const size_t arg_count = 3;
int64_t args[arg_count] = {(int64_t)eRemoteEvent::NetworkBail,
(int64_t)self::id,

View File

@ -20,7 +20,7 @@ namespace big
virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override
{
if (!g_player_service->get_self()->is_host() || !player->get_net_data())
if (!player || !g_player_service->get_self()->is_host() || !player->get_net_data())
return;
rage::snMsgRemoveGamersFromSessionCmd cmd{};

View File

@ -19,6 +19,8 @@ namespace big
virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override
{
if (!player)
return;
if (gta_util::get_network()->m_game_session_ptr->is_host())
{
gta_util::get_network()->m_game_complaint_mgr.raise_complaint(player->get_net_data()->m_host_token);

View File

@ -17,6 +17,8 @@ namespace big
virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override
{
if (!player)
return;
if (!scripts::force_host(RAGE_JOAAT("freemode")))
{
g_notification_service->push_error("Kick", "Force script host failed!");

View File

@ -14,6 +14,8 @@ namespace big
virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override
{
if (!player)
return;
if (!g_player_service->get_self()->is_host())
{
g_notification_service->push_error("Host kick", "Host kick failed");

View File

@ -25,7 +25,7 @@ namespace big
if (g_player_service->get_self()->is_host())
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("hostkick")))->call(player, {});
if (!player->is_host() && !g_player_service->get_self()->is_host())
if (player && !player->is_host() && !g_player_service->get_self()->is_host())
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("desync")))->call(player, {});
if (g_player_service->get_self()->is_host())

View File

@ -16,6 +16,8 @@ namespace big
virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override
{
if (!player)
return;
const size_t arg_count = 15;
int64_t args[arg_count] = {(int64_t)eRemoteEvent::InteriorControl, (int64_t)self::id, (int64_t)(int)-1};

View File

@ -20,6 +20,8 @@ namespace big
virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override
{
if (!player)
return;
packet msg{};
msg.write_message(rage::eNetMessage::MsgRadioStationSyncRequest);

View File

@ -17,6 +17,8 @@ namespace big
virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override
{
if (!player)
return;
if (!scripts::force_host(RAGE_JOAAT("freemode")))
{
g_notification_service->push_error("Kick", "Force script host failed!");