fix: Made breakup conditional (being host) (#1436)

Closes #1448
This commit is contained in:
DayibBaba 2023-06-17 15:49:48 +02:00 committed by GitHub
parent 853061a7b7
commit dca82a4060
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 79 additions and 13 deletions

View File

@ -20,6 +20,9 @@ namespace big
virtual void execute(player_ptr player, const std::vector<std::uint64_t>& _args, const std::shared_ptr<command_context> ctx) virtual void execute(player_ptr player, const std::vector<std::uint64_t>& _args, const std::shared_ptr<command_context> ctx)
{ {
if (!g_player_service->get_self()->is_host())
return;
rage::snMsgRemoveGamersFromSessionCmd cmd{}; rage::snMsgRemoveGamersFromSessionCmd cmd{};
cmd.m_session_id = gta_util::get_network()->m_game_session_ptr->m_rline_session.m_session_id; cmd.m_session_id = gta_util::get_network()->m_game_session_ptr->m_rline_session.m_session_id;
cmd.m_num_peers = 1; cmd.m_num_peers = 1;

View File

@ -0,0 +1,28 @@
#include "backend/player_command.hpp"
#include "natives.hpp"
namespace big
{
class host_kick : player_command
{
using player_command::player_command;
virtual CommandAccessLevel get_access_level()
{
return CommandAccessLevel::TOXIC;
}
virtual void execute(player_ptr player, const std::vector<std::uint64_t>& _args, const std::shared_ptr<command_context> ctx)
{
if (!g_player_service->get_self()->is_host())
{
g_notification_service->push_error("Host kick", "Host kick failed");
return;
}
NETWORK::NETWORK_SESSION_KICK_PLAYER(player->id());
}
};
host_kick g_host_kick("hostkick", "Host Kick", "Host kick that only works when host", 0, false);
}

View File

@ -14,7 +14,9 @@ namespace big
g_player_service->iterate([](auto& plyr) { g_player_service->iterate([](auto& plyr) {
if (plyr.second->is_host()) if (plyr.second->is_host())
{ {
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("breakup")))->call(plyr.second, {}); dynamic_cast<player_command*>(command::get(RAGE_JOAAT("bailkick")))->call(plyr.second, {});
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("nfkick")))->call(plyr.second, {});
//dynamic_cast<player_command*>(command::get(RAGE_JOAAT("breakup")))->call(plyr.second, {});
} }
}); });
} }

View File

@ -36,17 +36,21 @@ namespace big
} }
} }
if (kick) if (kick)
{ {
g_fiber_pool->queue_job([player] { g_fiber_pool->queue_job([player] {
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("bailkick")))->call(player, {}); dynamic_cast<player_command*>(command::get(RAGE_JOAAT("bailkick")))->call(player, {});
dynamic_cast<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);
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("breakup")))->call(player, {}); if(g_player_service->get_self()->is_host())
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("breakup")))->call(player, {}),
NETWORK::NETWORK_SESSION_KICK_PLAYER(player->id());
}); });
} }
} }
void reaction::process(player_ptr player) void reaction::process(player_ptr player)
{ {
if (!player->is_valid()) if (!player->is_valid())

View File

@ -109,13 +109,25 @@ namespace big
} }
if (plyr->block_join) if (plyr->block_join)
{ {
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("breakup")))->call(plyr, {}); if (g_player_service->get_self()->is_host())
g_notification_service->push_warning("Block Join", {
std::format("Block Join method failed for {}, sending breakup kick instead...", dynamic_cast<player_command*>(command::get(RAGE_JOAAT("breakup")))->call(plyr, {});
plyr->get_net_data()->m_name)); g_notification_service->push_warning("Block Join",
LOG(WARNING) << "Sending Breakup Kick due to block join failure... "; std::format("Block Join method failed for {}, sending breakup kick instead...",
plyr->get_net_data()->m_name));
LOG(WARNING) << "Sending Breakup Kick due to block join failure... ";
}
else
{
g_notification_service->push_warning("Block Join",
std::format("Block Join method failed for {}, can't send breakup without host...\n trying Desync",
plyr->get_net_data()->m_name));
LOG(WARNING) << "Failed blocking join due to not being host... trying Desync ";
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("desync")))->call(plyr, {});
}
} }
if (lock_session) if (lock_session && g_player_service->get_self()->is_host())
{ {
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("breakup")))->call(plyr, {}); dynamic_cast<player_command*>(command::get(RAGE_JOAAT("breakup")))->call(plyr, {});
g_notification_service->push_warning("Lock Session", g_notification_service->push_warning("Lock Session",

View File

@ -117,7 +117,12 @@ namespace big
player->is_spammer = true; player->is_spammer = true;
if (g.session.kick_chat_spammers) if (g.session.kick_chat_spammers)
{ {
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("breakup")))->call(player, {}); if(g_player_service->get_self()->is_host())
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("breakup")))->call(player, {}),
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("hostkick")))->call(player, {});
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("bailkick")))->call(player, {});
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("nfkick")))->call(player, {});
} }
return true; return true;
} }

View File

@ -126,9 +126,14 @@ namespace big
} }
components::sub_title("Lobby Lock"); components::sub_title("Lobby Lock");
ImGui::BeginDisabled(!g_player_service->get_self()->is_host());
ImGui::Checkbox("Lock", &g.session.lock_session); ImGui::Checkbox("Lock", &g.session.lock_session);
if (ImGui::IsItemHovered()) if (ImGui::IsItemHovered())
ImGui::SetTooltip("Blocks all players from joining. May not work on some modders."); ImGui::SetTooltip("Blocks all players from joining. May not work on some modders.");
ImGui::EndDisabled();
components::sub_title("DECLOAK"_T); components::sub_title("DECLOAK"_T);
components::script_patch_checkbox("REVEAL_OTR_PLAYERS"_T, &g.session.decloak_players); components::script_patch_checkbox("REVEAL_OTR_PLAYERS"_T, &g.session.decloak_players);

View File

@ -12,9 +12,16 @@ namespace big
return gta_util::get_network()->m_game_session_ptr->is_host(); return gta_util::get_network()->m_game_session_ptr->is_host();
}; };
//components::player_command_button<"breakup">(g_player_service->get_selected()); ImGui::Text("Host/breakup kick require Host");
//ImGui::SameLine(); ImGui::BeginDisabled(!g_player_service->get_self()->is_host());
//components::command_checkbox<"breakupcheating">();
components::player_command_button<"hostkick">(g_player_service->get_selected());
components::player_command_button<"breakup">(g_player_service->get_selected());
ImGui::EndDisabled();
ImGui::SameLine();
components::command_checkbox<"breakupcheating">();
components::player_command_button<"bailkick">(g_player_service->get_selected()); components::player_command_button<"bailkick">(g_player_service->get_selected());
ImGui::SameLine(); ImGui::SameLine();