Re-add kick host during join (#3450)

This commit is contained in:
CringeArab 2024-07-28 23:18:00 +03:00 committed by GitHub
parent c6ce5da315
commit 61c32b24f6
4 changed files with 19 additions and 14 deletions

View File

@ -8,13 +8,14 @@ namespace big
static bool bLastKickHost = false;
void looped::session_auto_kick_host()
{
bool kick_host = false; // *g_pointers->m_gta.m_is_session_started && g.session.force_session_host && g.session.kick_host_when_forcing_host;
bool kick_host = *g_pointers->m_gta.m_is_session_started && g.session.spoof_host_token_type != 0 && g.session.kick_host_when_forcing_host;
if (kick_host && !bLastKickHost) [[unlikely]]
{
g_player_service->iterate([](auto& plyr) {
// Don't kick trusted players
if (plyr.second->is_trusted || (g.session.trust_friends && plyr.second->is_friend()))
return;
if (plyr.second->is_trusted || (g.session.trust_friends && plyr.second->is_friend())
|| (plyr.second->is_modder && g.session.exclude_modders_from_kick_host))
return;
if (plyr.second->is_host())
{

View File

@ -446,6 +446,7 @@ namespace big
CommandAccessLevel chat_command_default_access_level = CommandAccessLevel::FRIENDLY;
bool kick_host_when_forcing_host = false;
bool exclude_modders_from_kick_host = false;
bool explosion_karma = false;
bool damage_karma = false;
@ -495,7 +496,7 @@ namespace big
NLOHMANN_DEFINE_TYPE_INTRUSIVE(chat_translator, enabled, print_result, draw_result, bypass_same_language, target_language, endpoint);
} chat_translator{};
NLOHMANN_DEFINE_TYPE_INTRUSIVE(session, log_chat_messages, log_text_messages, decloak_players, spoof_host_token_type, custom_host_token, hide_token_spoofing_when_host, force_script_host, player_magnet_enabled, player_magnet_count, is_team, join_in_sctv_slots, kick_host_when_forcing_host, explosion_karma, damage_karma, disable_traffic, disable_peds, force_thunder, block_ceo_money, randomize_ceo_colors, block_jobs, block_muggers, block_ceo_raids, block_ceo_creation, send_to_apartment_idx, send_to_warehouse_idx, chat_commands, chat_command_default_access_level, anonymous_bounty, lock_session, fast_join, unhide_players_from_player_list, allow_friends_into_locked_session, trust_friends, use_spam_timer, spam_timer, spam_length, chat_translator, script_block_opts)
NLOHMANN_DEFINE_TYPE_INTRUSIVE(session, log_chat_messages, log_text_messages, decloak_players, spoof_host_token_type, custom_host_token, hide_token_spoofing_when_host, force_script_host, player_magnet_enabled, player_magnet_count, is_team, join_in_sctv_slots, kick_host_when_forcing_host, exclude_modders_from_kick_host, explosion_karma, damage_karma, disable_traffic, disable_peds, force_thunder, block_ceo_money, randomize_ceo_colors, block_jobs, block_muggers, block_ceo_raids, block_ceo_creation, send_to_apartment_idx, send_to_warehouse_idx, chat_commands, chat_command_default_access_level, anonymous_bounty, lock_session, fast_join, unhide_players_from_player_list, allow_friends_into_locked_session, trust_friends, use_spam_timer, spam_timer, spam_length, chat_translator, script_block_opts)
} session{};
struct settings

View File

@ -323,18 +323,14 @@ namespace big
first_time = false;
}
static auto last_update = std::chrono::high_resolution_clock::now() - 45s;
while (g_running && g.player_db.update_player_online_states)
{
const auto cur = std::chrono::high_resolution_clock::now();
if (cur - last_update > 45s && !updating)
if (!updating)
{
updating = true;
g_fiber_pool->queue_job([this] {
update_player_states(true);
updating = false;
last_update = std::chrono::high_resolution_clock::now();
});
}

View File

@ -171,11 +171,18 @@ namespace big
ImGui::EndDisabled();
//if (g.session.force_session_host)
//{
// ImGui::SameLine();
// ImGui::Checkbox("KICK_HOST_ON_JOIN"_T.data(), &g.session.kick_host_when_forcing_host);
//}
if (g.session.spoof_host_token_type != 0)
{
ImGui::Checkbox("KICK_HOST_ON_JOIN"_T.data(), &g.session.kick_host_when_forcing_host);
if (g.session.kick_host_when_forcing_host)
{
ImGui::SameLine();
ImGui::Checkbox("EXCLUDE_MODDERS_FROM_KICK_HOST"_T.data(), &g.session.exclude_modders_from_kick_host);
if (ImGui::IsItemHovered())
ImGui::SetTooltip("EXCLUDE_MODDERS_FROM_KICK_HOST_DESC"_T.data());
}
}
ImGui::Checkbox("FORCE_SCRIPT_HOST"_T.data(), &g.session.force_script_host);
if (ImGui::IsItemHovered())