Merge pull request #462 from momo5502/feature/auth-protocol
Finish profile info transmission
This commit is contained in:
commit
2d3ffb5bc6
@ -143,12 +143,22 @@ namespace auth
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto _ = profile_infos::acquire_profile_lock();
|
||||||
|
|
||||||
const utils::info_string info_string(params[1]);
|
const utils::info_string info_string(params[1]);
|
||||||
const auto xuid = strtoull(info_string.get("xuid").data(), nullptr, 16);
|
const auto xuid = strtoull(info_string.get("xuid").data(), nullptr, 16);
|
||||||
|
|
||||||
profile_infos::add_and_distribute_profile_info(target, xuid, info);
|
profile_infos::add_and_distribute_profile_info(target, xuid, info);
|
||||||
|
|
||||||
game::SV_DirectConnect(target);
|
game::SV_DirectConnect(target);
|
||||||
|
|
||||||
|
game::foreach_connected_client([&](game::client_s& client)
|
||||||
|
{
|
||||||
|
if (client.address == target)
|
||||||
|
{
|
||||||
|
client.xuid = xuid;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,9 +182,8 @@ namespace auth
|
|||||||
void post_unpack() override
|
void post_unpack() override
|
||||||
{
|
{
|
||||||
// Skip connect handler
|
// Skip connect handler
|
||||||
//utils::hook::set<uint8_t>(game::select(0x142253EFA, 0x14053714A), 0xEB);
|
utils::hook::set<uint8_t>(game::select(0x142253EFA, 0x14053714A), 0xEB);
|
||||||
//network::on("connect", handle_connect_packet);
|
network::on("connect", handle_connect_packet);
|
||||||
(void)&handle_connect_packet;
|
|
||||||
|
|
||||||
// Patch steam id bit check
|
// Patch steam id bit check
|
||||||
std::vector<std::pair<size_t, size_t>> patches{};
|
std::vector<std::pair<size_t, size_t>> patches{};
|
||||||
@ -221,8 +230,7 @@ namespace auth
|
|||||||
p(0x141EB5992_g, 0x141EB59D5_g);
|
p(0x141EB5992_g, 0x141EB59D5_g);
|
||||||
p(0x141EB74D2_g, 0x141EB7515_g); // ?
|
p(0x141EB74D2_g, 0x141EB7515_g); // ?
|
||||||
|
|
||||||
//utils::hook::call(0x14134BF7D_g, send_connect_data_stub);
|
utils::hook::call(0x14134BF7D_g, send_connect_data_stub);
|
||||||
(void)&send_connect_data_stub;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& patch : patches)
|
for (const auto& patch : patches)
|
||||||
|
@ -20,7 +20,7 @@ namespace profile_infos
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
using profile_map = std::unordered_map<uint64_t, profile_info>;
|
using profile_map = std::unordered_map<uint64_t, profile_info>;
|
||||||
utils::concurrency::container<profile_map> profile_mapping{};
|
utils::concurrency::container<profile_map, std::recursive_mutex> profile_mapping{};
|
||||||
|
|
||||||
std::optional<profile_info> load_profile_info()
|
std::optional<profile_info> load_profile_info()
|
||||||
{
|
{
|
||||||
@ -68,21 +68,6 @@ namespace profile_infos
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void schedule_pcache_update()
|
|
||||||
{
|
|
||||||
static std::atomic_bool update_triggered{false};
|
|
||||||
if (game::is_server() || update_triggered.exchange(true))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
scheduler::once([]
|
|
||||||
{
|
|
||||||
game::PCache_DeleteEntries(game::CONTROLLER_INDEX_FIRST);
|
|
||||||
update_triggered = false;
|
|
||||||
}, scheduler::main, 5s);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unordered_set<uint64_t> get_connected_client_xuids()
|
std::unordered_set<uint64_t> get_connected_client_xuids()
|
||||||
{
|
{
|
||||||
std::unordered_set<uint64_t> connected_clients{};
|
std::unordered_set<uint64_t> connected_clients{};
|
||||||
@ -103,10 +88,10 @@ namespace profile_infos
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
profile_mapping.access([](profile_map& profiles)
|
||||||
|
{
|
||||||
const auto xuids = get_connected_client_xuids();
|
const auto xuids = get_connected_client_xuids();
|
||||||
|
|
||||||
profile_mapping.access([&](profile_map& profiles)
|
|
||||||
{
|
|
||||||
for (auto i = profiles.begin(); i != profiles.end();)
|
for (auto i = profiles.begin(); i != profiles.end();)
|
||||||
{
|
{
|
||||||
if (xuids.contains(i->first))
|
if (xuids.contains(i->first))
|
||||||
@ -145,8 +130,6 @@ namespace profile_infos
|
|||||||
{
|
{
|
||||||
profiles[user_id] = info;
|
profiles[user_id] = info;
|
||||||
});
|
});
|
||||||
|
|
||||||
schedule_pcache_update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void distribute_profile_info_to_user(const game::netadr_t& addr, const uint64_t user_id, const profile_info& info)
|
void distribute_profile_info_to_user(const game::netadr_t& addr, const uint64_t user_id, const profile_info& info)
|
||||||
@ -194,6 +177,11 @@ namespace profile_infos
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_lock<std::recursive_mutex> acquire_profile_lock()
|
||||||
|
{
|
||||||
|
return profile_mapping.acquire_lock();
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<profile_info> get_profile_info()
|
std::optional<profile_info> get_profile_info()
|
||||||
{
|
{
|
||||||
return load_profile_info();
|
return load_profile_info();
|
||||||
@ -201,8 +189,6 @@ namespace profile_infos
|
|||||||
|
|
||||||
std::optional<profile_info> get_profile_info(const uint64_t user_id)
|
std::optional<profile_info> get_profile_info(const uint64_t user_id)
|
||||||
{
|
{
|
||||||
printf("Requesting profile info: %llX\n", user_id);
|
|
||||||
|
|
||||||
if (user_id == steam::SteamUser()->GetSteamID().bits)
|
if (user_id == steam::SteamUser()->GetSteamID().bits)
|
||||||
{
|
{
|
||||||
return get_profile_info();
|
return get_profile_info();
|
||||||
|
@ -19,6 +19,7 @@ namespace profile_infos
|
|||||||
void add_and_distribute_profile_info(const game::netadr_t& addr, uint64_t user_id, const profile_info& info);
|
void add_and_distribute_profile_info(const game::netadr_t& addr, uint64_t user_id, const profile_info& info);
|
||||||
void clear_profile_infos();
|
void clear_profile_infos();
|
||||||
|
|
||||||
|
std::unique_lock<std::recursive_mutex> acquire_profile_lock();
|
||||||
|
|
||||||
std::optional<profile_info> get_profile_info();
|
std::optional<profile_info> get_profile_info();
|
||||||
std::optional<profile_info> get_profile_info(uint64_t user_id);
|
std::optional<profile_info> get_profile_info(uint64_t user_id);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define PROTOCOL 1
|
#define PROTOCOL 2
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
namespace game
|
namespace game
|
||||||
@ -1556,7 +1556,7 @@ namespace game
|
|||||||
char __pad4[0x29DAC];
|
char __pad4[0x29DAC];
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(sizeof(client_s) <= 0xE5110);
|
static_assert(sizeof(client_s) == 0xE5110);
|
||||||
|
|
||||||
static_assert(offsetof(game::client_s, address) == 0x2C);
|
static_assert(offsetof(game::client_s, address) == 0x2C);
|
||||||
static_assert(offsetof(game::client_s, xuid) == 0x55C8);
|
static_assert(offsetof(game::client_s, xuid) == 0x55C8);
|
||||||
|
@ -45,6 +45,11 @@ namespace utils::concurrency
|
|||||||
return object_;
|
return object_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_lock<MutexType> acquire_lock()
|
||||||
|
{
|
||||||
|
return std::unique_lock<MutexType>{mutex_};
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable MutexType mutex_{};
|
mutable MutexType mutex_{};
|
||||||
T object_{};
|
T object_{};
|
||||||
|
Loading…
Reference in New Issue
Block a user