From f3b9cd4a394564a96d7afd1efda3498a3460aa9f Mon Sep 17 00:00:00 2001 From: Lierrmm Date: Mon, 27 Feb 2023 09:01:57 +0000 Subject: [PATCH] fix: handle addtestclient when not host --- src/client/component/client_patches.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/client/component/client_patches.cpp b/src/client/component/client_patches.cpp index 0a2cf29d..aab28323 100644 --- a/src/client/component/client_patches.cpp +++ b/src/client/component/client_patches.cpp @@ -13,6 +13,7 @@ namespace client_patches namespace { utils::hook::detour preload_map_hook; + utils::hook::detour sv_addtestclient_hook; void stop_zombies_intro_if_needed() { @@ -43,6 +44,18 @@ namespace client_patches preload_map_hook.invoke(localClientNum, mapname, gametype); } + int sv_addtestclient_stub() + { + const auto state = reinterpret_cast(0x1576FB318_g); + + if (*state == 0) + { + return 0; + } + + return sv_addtestclient_hook.invoke(); + } + void reduce_process_affinity() { 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); preload_map_hook.create(0x14135A1E0_g, preload_map_stub); + + sv_addtestclient_hook.create(0x1422499A0_g, sv_addtestclient_stub); } }; }