Skip to content

Commit

Permalink
Manually hook COM_ExplainDisconnection
Browse files Browse the repository at this point in the history
  • Loading branch information
ASpoonPlaysGames committed Aug 29, 2024
1 parent dafd7ab commit 1854482
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions primedev/client/rejectconnectionfixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<decltype(o_pCOM_ExplainDisconnection)>();
HookAttach(&(PVOID&)o_pCOM_ExplainDisconnection, (PVOID)h_COM_ExplainDisconnection);
}

0 comments on commit 1854482

Please sign in to comment.