Skip to content

Commit 0de2a3a

Browse files
Remove uses of Autohook from clientchathooks.cpp (#819)
* Manually hook CHudChat__AddGameLine * Remove AUTOHOOK_INIT and AUTOHOOK_DISPATCH
1 parent 10041ca commit 0de2a3a

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

primedev/scripts/client/clientchathooks.cpp

+5-8
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@
66

77
#include <rapidjson/document.h>
88

9-
AUTOHOOK_INIT()
10-
11-
// clang-format off
12-
AUTOHOOK(CHudChat__AddGameLine, client.dll + 0x22E580,
13-
void, __fastcall, (void* self, const char* message, int inboxId, bool isTeam, bool isDead))
14-
// clang-format on
9+
static void(__fastcall* o_pCHudChat__AddGameLine)(void* self, const char* message, int inboxId, bool isTeam, bool isDead) = nullptr;
10+
static void __fastcall h_CHudChat__AddGameLine(void* self, const char* message, int inboxId, bool isTeam, bool isDead)
1511
{
1612
// This hook is called for each HUD, but we only want our logic to run once.
1713
if (self != *CHudChat::allHuds)
@@ -36,7 +32,7 @@ void, __fastcall, (void* self, const char* message, int inboxId, bool isTeam, bo
3632
"CHudChat_ProcessMessageStartThread", static_cast<int>(senderId) - 1, payload, isTeam, isDead, type);
3733
if (result == SQRESULT_ERROR)
3834
for (CHudChat* hud = *CHudChat::allHuds; hud != NULL; hud = hud->next)
39-
CHudChat__AddGameLine(hud, message, inboxId, isTeam, isDead);
35+
o_pCHudChat__AddGameLine(hud, message, inboxId, isTeam, isDead);
4036
}
4137

4238
ADD_SQFUNC("void", NSChatWrite, "int context, string text", "", ScriptContext::CLIENT)
@@ -68,5 +64,6 @@ ADD_SQFUNC("void", NSChatWriteLine, "int context, string text", "", ScriptContex
6864

6965
ON_DLL_LOAD_CLIENT("client.dll", ClientChatHooks, (CModule module))
7066
{
71-
AUTOHOOK_DISPATCH()
67+
o_pCHudChat__AddGameLine = module.Offset(0x22E580).RCast<decltype(o_pCHudChat__AddGameLine)>();
68+
HookAttach(&(PVOID&)o_pCHudChat__AddGameLine, (PVOID)h_CHudChat__AddGameLine);
7269
}

0 commit comments

Comments
 (0)