fix: handle addtestclient when not host

This commit is contained in:
Lierrmm 2023-02-27 09:01:57 +00:00
parent b985026eb1
commit f3b9cd4a39

View File

@ -13,6 +13,7 @@ namespace client_patches
namespace namespace
{ {
utils::hook::detour preload_map_hook; utils::hook::detour preload_map_hook;
utils::hook::detour sv_addtestclient_hook;
void stop_zombies_intro_if_needed() void stop_zombies_intro_if_needed()
{ {
@ -43,6 +44,18 @@ namespace client_patches
preload_map_hook.invoke(localClientNum, mapname, gametype); preload_map_hook.invoke(localClientNum, mapname, gametype);
} }
int sv_addtestclient_stub()
{
const auto state = reinterpret_cast<int*>(0x1576FB318_g);
if (*state == 0)
{
return 0;
}
return sv_addtestclient_hook.invoke<int>();
}
void reduce_process_affinity() void reduce_process_affinity()
{ {
const DWORD_PTR affinity = (1ULL << (std::min(std::thread::hardware_concurrency(), 4U))) - 1; const DWORD_PTR affinity = (1ULL << (std::min(std::thread::hardware_concurrency(), 4U))) - 1;
@ -82,6 +95,8 @@ namespace client_patches
utils::hook::set(0x15AAEB254_g, mixer_open_stub); utils::hook::set(0x15AAEB254_g, mixer_open_stub);
preload_map_hook.create(0x14135A1E0_g, preload_map_stub); preload_map_hook.create(0x14135A1E0_g, preload_map_stub);
sv_addtestclient_hook.create(0x1422499A0_g, sv_addtestclient_stub);
} }
}; };
} }