Cleanup party.cpp

This commit is contained in:
momo5502 2023-02-26 10:04:38 +01:00
parent 4b7291cfb0
commit 03d0c384f9

View File

@ -208,28 +208,8 @@ namespace party
const auto address = *reinterpret_cast<uint64_t*>(0x1453DABB8_g) + (0x25780 * local_client_num) + 0x10;
return *reinterpret_cast<game::netadr_t*>(address);
}
}
void query_server(const game::netadr_t& host, query_callback callback)
{
server_query query{};
query.sent = false;
query.host = host;
query.callback = std::move(callback);
get_server_queries().access([&](std::vector<server_query>& server_queries)
{
server_queries.emplace_back(std::move(query));
});
}
struct component final : client_component
{
void post_unpack() override
{
utils::hook::jump(0x141EE6030_g, connect_stub);
network::on("infoResponse", [](const game::netadr_t& target, const network::data_view& data)
void handle_info_response(const game::netadr_t& target, const network::data_view& data)
{
bool found_query = false;
server_query query{};
@ -257,9 +237,9 @@ namespace party
query.callback(true, query.host, info, static_cast<uint32_t>(ping_ms));
}
});
}
scheduler::loop([]
void cleanup_queried_servers()
{
std::vector<server_query> removed_queries{};
@ -297,7 +277,30 @@ namespace party
{
query.callback(false, query.host, empty, 0);
}
}, scheduler::async, 200ms);
}
}
void query_server(const game::netadr_t& host, query_callback callback)
{
server_query query{};
query.sent = false;
query.host = host;
query.callback = std::move(callback);
get_server_queries().access([&](std::vector<server_query>& server_queries)
{
server_queries.emplace_back(std::move(query));
});
}
struct component final : client_component
{
void post_unpack() override
{
utils::hook::jump(0x141EE6030_g, &connect_stub);
network::on("infoResponse", handle_info_response);
scheduler::loop(cleanup_queried_servers, scheduler::async, 200ms);
}
void pre_destroy() override