From 1854482e85c8583e5fa8fbcf7026b07d39fbda73 Mon Sep 17 00:00:00 2001 From: ASpoonPlaysGames <66967891+ASpoonPlaysGames@users.noreply.github.com> Date: Thu, 29 Aug 2024 18:32:08 +0100 Subject: [PATCH] Manually hook COM_ExplainDisconnection --- primedev/client/rejectconnectionfixes.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/primedev/client/rejectconnectionfixes.cpp b/primedev/client/rejectconnectionfixes.cpp index 1b326a3c8..dd7e5f4d2 100644 --- a/primedev/client/rejectconnectionfixes.cpp +++ b/primedev/client/rejectconnectionfixes.cpp @@ -3,10 +3,8 @@ AUTOHOOK_INIT() // this is called from when our connection is rejected, this is the only case we're hooking this for -// clang-format off -AUTOHOOK(COM_ExplainDisconnection, engine.dll + 0x1342F0, -void,, (bool a1, const char* fmt, ...)) -// clang-format on +static void (*o_pCOM_ExplainDisconnection)(bool a1, const char* fmt, ...) = nullptr; +static void h_COM_ExplainDisconnection(bool a1, const char* fmt, ...) { va_list va; va_start(va, fmt); @@ -25,10 +23,12 @@ void,, (bool a1, const char* fmt, ...)) Cbuf_AddText(Cbuf_GetCurrentPlayer(), "disconnect", cmd_source_t::kCommandSrcCode); } - return COM_ExplainDisconnection(a1, "%s", buf); + return o_pCOM_ExplainDisconnection(a1, "%s", buf); } ON_DLL_LOAD_CLIENT("engine.dll", RejectConnectionFixes, (CModule module)) { AUTOHOOK_DISPATCH() + o_pCOM_ExplainDisconnection = module.Offset(0x1342F0).RCast(); + HookAttach(&(PVOID&)o_pCOM_ExplainDisconnection, (PVOID)h_COM_ExplainDisconnection); }