diff options
-rw-r--r-- | primedev/server/buildainfile.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/primedev/server/buildainfile.cpp b/primedev/server/buildainfile.cpp index 19a6d0e3..456c84f0 100644 --- a/primedev/server/buildainfile.cpp +++ b/primedev/server/buildainfile.cpp @@ -7,8 +7,6 @@ namespace fs = std::filesystem; -AUTOHOOK_INIT() - const int AINET_VERSION_NUMBER = 57; const int AINET_SCRIPT_VERSION_NUMBER = 21; const int PLACEHOLDER_CRC = 0; @@ -359,22 +357,18 @@ void DumpAINInfo(CAI_Network* aiNetwork) writeStream.close(); } -// clang-format off -AUTOHOOK(CAI_NetworkBuilder__Build, server.dll + 0x385E20, -void, __fastcall, (void* builder, CAI_Network* aiNetwork, void* unknown)) -// clang-format on +static void(__fastcall* o_pCAI_NetworkBuilder__Build)(void* builder, CAI_Network* aiNetwork, void* unknown) = nullptr; +static void __fastcall h_CAI_NetworkBuilder__Build(void* builder, CAI_Network* aiNetwork, void* unknown) { - CAI_NetworkBuilder__Build(builder, aiNetwork, unknown); + o_pCAI_NetworkBuilder__Build(builder, aiNetwork, unknown); DumpAINInfo(aiNetwork); } -// clang-format off -AUTOHOOK(LoadAINFile, server.dll + 0x3933A0, -void, __fastcall, (void* aimanager, void* buf, const char* filename)) -// clang-format on +static void(__fastcall* o_pLoadAINFile)(void* aimanager, void* buf, const char* filename) = nullptr; +static void __fastcall h_LoadAINFile(void* aimanager, void* buf, const char* filename) { - LoadAINFile(aimanager, buf, filename); + o_pLoadAINFile(aimanager, buf, filename); if (Cvar_ns_ai_dumpAINfileFromLoad->GetBool()) { @@ -385,7 +379,11 @@ void, __fastcall, (void* aimanager, void* buf, const char* filename)) ON_DLL_LOAD("server.dll", BuildAINFile, (CModule module)) { - AUTOHOOK_DISPATCH() + o_pCAI_NetworkBuilder__Build = module.Offset(0x385E20).RCast<decltype(o_pCAI_NetworkBuilder__Build)>(); + HookAttach(&(PVOID&)o_pCAI_NetworkBuilder__Build, (PVOID)h_CAI_NetworkBuilder__Build); + + o_pLoadAINFile = module.Offset(0x3933A0).RCast<decltype(o_pLoadAINFile)>(); + HookAttach(&(PVOID&)o_pLoadAINFile, (PVOID)h_LoadAINFile); Cvar_ns_ai_dumpAINfileFromLoad = new ConVar( "ns_ai_dumpAINfileFromLoad", "0", FCVAR_NONE, "For debugging: whether we should dump ain data for ains loaded from disk"); |