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 4b73b46053
commit e5581a6f03
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)
{
if (!g_player_service->get_self()->is_host())
return;
rage::snMsgRemoveGamersFromSessionCmd cmd{};
cmd.m_session_id = gta_util::get_network()->m_game_session_ptr->m_rline_session.m_session_id;
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) {
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

@ -39,14 +39,18 @@ namespace big
if (kick)
{
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("nfkick")))->call(player, {});
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)
{
if (!player->is_valid())

View File

@ -108,6 +108,8 @@ namespace big
}
}
if (plyr->block_join)
{
if (g_player_service->get_self()->is_host())
{
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("breakup")))->call(plyr, {});
g_notification_service->push_warning("Block Join",
@ -115,7 +117,17 @@ namespace big
plyr->get_net_data()->m_name));
LOG(WARNING) << "Sending Breakup Kick due to block join failure... ";
}
if (lock_session)
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 && g_player_service->get_self()->is_host())
{
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("breakup")))->call(plyr, {});
g_notification_service->push_warning("Lock Session",

View File

@ -117,7 +117,12 @@ namespace big
player->is_spammer = true;
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;
}

View File

@ -126,9 +126,14 @@ namespace big
}
components::sub_title("Lobby Lock");
ImGui::BeginDisabled(!g_player_service->get_self()->is_host());
ImGui::Checkbox("Lock", &g.session.lock_session);
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Blocks all players from joining. May not work on some modders.");
ImGui::EndDisabled();
components::sub_title("DECLOAK"_T);
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();
};
//components::player_command_button<"breakup">(g_player_service->get_selected());
//ImGui::SameLine();
//components::command_checkbox<"breakupcheating">();
ImGui::Text("Host/breakup kick require Host");
ImGui::BeginDisabled(!g_player_service->get_self()->is_host());
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());
ImGui::SameLine();