From e6e2805466d1d85b460b5675e8612eff7f8239f2 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Mon, 17 Apr 2023 20:33:41 +0200 Subject: [PATCH] Fix guid distribution for bots --- src/client/component/auth.cpp | 53 ++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/src/client/component/auth.cpp b/src/client/component/auth.cpp index 3b56585e..8a750cde 100644 --- a/src/client/component/auth.cpp +++ b/src/client/component/auth.cpp @@ -172,9 +172,12 @@ namespace auth game::foreach_connected_client([&](const game::client_s& client, size_t index) { - network::send(client.address, "playerXuid", buffer.get_buffer()); + if (client.address.type != game::NA_BOT) + { + network::send(client.address, "playerXuid", buffer.get_buffer()); + } - if (index != player_index) + if (index != player_index && target.type != game::NA_BOT) { utils::byte_buffer current_buffer{}; current_buffer.write(static_cast(index)); @@ -185,6 +188,30 @@ namespace auth }); } + void handle_new_player(const game::netadr_t& target) + { + const command::params_sv params{}; + if (params.size() < 2) + { + return; + } + + const utils::info_string info_string(params[1]); + const auto xuid = strtoull(info_string.get("xuid").data(), nullptr, 16); + + size_t player_index = 18; + game::foreach_connected_client([&](game::client_s& client, size_t index) + { + if (client.address == target) + { + client.xuid = xuid; + player_index = index; + } + }); + + distribute_player_xuid(target, player_index, xuid); + } + void dispatch_connect_packet(const game::netadr_t& target, const std::string& data) { utils::byte_buffer buffer(data); @@ -206,18 +233,7 @@ namespace auth profile_infos::add_and_distribute_profile_info(target, xuid, info); game::SV_DirectConnect(target); - - size_t player_index = 18; - game::foreach_connected_client([&](game::client_s& client, size_t index) - { - if (client.address == target) - { - client.xuid = xuid; - player_index = index; - } - }); - - distribute_player_xuid(target, player_index, xuid); + handle_new_player(target); } void handle_connect_packet_fragment(const game::netadr_t& target, const network::data_view& data) @@ -256,6 +272,12 @@ namespace auth client_xuids[player_id] = xuid; } } + + void direct_connect_bots_stub(const game::netadr_t address) + { + game::SV_DirectConnect(address); + handle_new_player(address); + } } uint64_t get_guid() @@ -308,6 +330,9 @@ namespace auth network::on("connect", handle_connect_packet_fragment); network::on("playerXuid", handle_player_xuid_packet); + // Intercept SV_DirectConnect in SV_AddTestClient + utils::hook::call(game::select(0x1422490DC, 0x14052E582), direct_connect_bots_stub); + // Patch steam id bit check std::vector> patches{}; const auto p = [&patches](const size_t a, const size_t b)