From 1d18d35be6f8e1991d78d83e50b35d76f5c25695 Mon Sep 17 00:00:00 2001 From: quaK Date: Thu, 1 Feb 2024 15:01:59 +0200 Subject: [PATCH] fix bots --- src/client/component/profile_infos.cpp | 13 +++++++++---- src/client/game/game.cpp | 10 ++++++++++ src/client/game/game.hpp | 3 +++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/client/component/profile_infos.cpp b/src/client/component/profile_infos.cpp index 257e922a..dcb5552f 100644 --- a/src/client/component/profile_infos.cpp +++ b/src/client/component/profile_infos.cpp @@ -193,7 +193,7 @@ namespace profile_infos const auto* svs_clients = *game::svs_clients; for (unsigned int i = 0; i < *game::svs_numclients; ++i) { - if (svs_clients[i].header.state >= 1 && !game::SV_BotIsBot(i) && !game::Session_IsHost(game::SV_MainMP_GetServerLobby(), i)) + if (svs_clients[i].header.state >= 1 && !game::SV_ClientIsBot(i) && !game::Session_IsHost(game::SV_MainMP_GetServerLobby(), i)) { send_profile_info(svs_clients[i].remoteAddress, user_id, info); } @@ -205,7 +205,7 @@ namespace profile_infos const auto* svs_clients = *game::svs_clients; for (unsigned int i = 0; i < *game::svs_numclients; ++i) { - if (svs_clients[i].header.state >= 1 && !game::SV_BotIsBot(i) && game::Session_IsHost(game::SV_MainMP_GetServerLobby(), i)) + if (svs_clients[i].header.state >= 1 && !game::SV_ClientIsBot(i) && game::Session_IsHost(game::SV_MainMP_GetServerLobby(), i)) { assert(i == 0); @@ -310,7 +310,7 @@ namespace profile_infos const auto* svs_clients = *game::svs_clients; for (unsigned int i = 0; i < *game::svs_numclients; ++i) { - if (svs_clients[i].header.state >= 1 && !game::SV_BotIsBot(i) && !game::Session_IsHost(game::SV_MainMP_GetServerLobby(), i)) + if (svs_clients[i].header.state >= 1 && !game::SV_ClientIsBot(i) && !game::Session_IsHost(game::SV_MainMP_GetServerLobby(), i)) { send_xuid(svs_clients[i].remoteAddress, xuid, client_index); } @@ -344,6 +344,11 @@ namespace profile_infos { auto result = client_connect_hook.invoke(client_num, script_pers_id); + if (game::SV_ClientIsBot(client_num)) + { + return result; + } + const auto client = game::svs_clients[client_num]; std::uint64_t xuid{}; game::StringToXUID(client->playerGuid, &xuid); @@ -367,7 +372,7 @@ namespace profile_infos { session_unregister_remote_player_hook.invoke(session, slot); - set_client_xuid_to_session(game::SV_MainMP_GetServerLobby(), slot); + set_client_xuid_to_session(session, slot); } } diff --git a/src/client/game/game.cpp b/src/client/game/game.cpp index 6b50efd5..ea467fcb 100644 --- a/src/client/game/game.cpp +++ b/src/client/game/game.cpp @@ -214,6 +214,16 @@ namespace game Cbuf_AddCall(0, SV_CmdsMP_CheckLoadGame); } } + + bool SV_ClientIsBot(client_t* client) + { + return client->remoteAddress.type == NA_BOT; + } + + bool SV_ClientIsBot(unsigned int client_num) + { + return svs_clients[client_num]->remoteAddress.type == NA_BOT; + } } size_t operator"" _b(const size_t ptr) diff --git a/src/client/game/game.hpp b/src/client/game/game.hpp index d616e6b5..177e8823 100644 --- a/src/client/game/game.hpp +++ b/src/client/game/game.hpp @@ -64,6 +64,9 @@ namespace game void DB_EnumXAssets(const std::int32_t type, const std::function& callback); void SV_CmdsMP_RequestMapRestart(bool loadScripts, bool migrate); + + bool SV_ClientIsBot(client_t* client); + bool SV_ClientIsBot(unsigned int client_num); } size_t operator"" _b(const size_t ptr);