Fix guid distribution for bots

This commit is contained in:
momo5502 2023-04-17 20:33:41 +02:00
parent fa144b7dd6
commit e6e2805466

View File

@ -171,10 +171,13 @@ namespace auth
buffer.write(xuid);
game::foreach_connected_client([&](const game::client_s& client, size_t index)
{
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<uint32_t>(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<std::pair<size_t, size_t>> patches{};
const auto p = [&patches](const size_t a, const size_t b)