diff --git a/src/client/component/auth.cpp b/src/client/component/auth.cpp index cc909f66..a8bfd8eb 100644 --- a/src/client/component/auth.cpp +++ b/src/client/component/auth.cpp @@ -100,6 +100,8 @@ namespace auth std::string serialize_connect_data(const char* data, const int length) { utils::byte_buffer buffer{}; + profile_infos::get_profile_info().value_or(profile_infos::profile_info{}).serialize(buffer); + buffer.write_string(data, static_cast(length)); return buffer.move_buffer(); @@ -128,18 +130,18 @@ namespace auth // TODO: SV running? utils::byte_buffer buffer(data); - profile_infos::profile_info info(buffer); + const profile_infos::profile_info info(buffer); const auto connect_data = buffer.read_string(); const command::params_sv params(connect_data); - if (params.size() != 2) + if (params.size() < 2) { return; } const utils::info_string info_string(params[1]); - const auto xuid = strtoull(info_string.get("xuid").data(), nullptr, 10); + const auto xuid = strtoull(info_string.get("xuid").data(), nullptr, 16); profile_infos::add_and_distribute_profile_info(target, xuid, info); diff --git a/src/client/component/profile_infos.cpp b/src/client/component/profile_infos.cpp index 576217b1..24c9ba68 100644 --- a/src/client/component/profile_infos.cpp +++ b/src/client/component/profile_infos.cpp @@ -72,6 +72,11 @@ namespace profile_infos void distribute_profile_info(const uint64_t user_id, const profile_info& info) { + if (user_id == steam::SteamUser()->GetSteamID().bits) + { + return; + } + utils::byte_buffer buffer{}; buffer.write(user_id); info.serialize(buffer); @@ -132,6 +137,15 @@ namespace profile_infos distribute_profile_info_to_user(addr, entry.first, entry.second); } }); + + if (!game::is_server()) + { + const auto info = get_profile_info(); + if (info) + { + distribute_profile_info_to_user(addr, steam::SteamUser()->GetSteamID().bits, *info); + } + } } void add_and_distribute_profile_info(const game::netadr_t& addr, const uint64_t user_id, const profile_info& info) @@ -150,13 +164,18 @@ namespace profile_infos }); } + std::optional get_profile_info() + { + return load_profile_info(); + } + std::optional get_profile_info(const uint64_t user_id) { printf("Requesting profile info: %llX\n", user_id); if (user_id == steam::SteamUser()->GetSteamID().bits) { - return load_profile_info(); + return get_profile_info(); } return profile_mapping.access>([user_id](const profile_map& profiles) diff --git a/src/client/component/profile_infos.hpp b/src/client/component/profile_infos.hpp index a417a545..c1cfd1f8 100644 --- a/src/client/component/profile_infos.hpp +++ b/src/client/component/profile_infos.hpp @@ -19,6 +19,8 @@ namespace profile_infos void add_and_distribute_profile_info(const game::netadr_t& addr, uint64_t user_id, const profile_info& info); void clear_profile_infos(); + + std::optional get_profile_info(); std::optional get_profile_info(uint64_t user_id); void update_profile_info(const profile_info& info); }