From 32165afe41c4cf4d3b261ee7a9c69c369253cc13 Mon Sep 17 00:00:00 2001 From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com> Date: Thu, 23 Feb 2023 00:19:48 +0000 Subject: Add `FUNCTION_AT` and `VAR_AT` macros (#416) * add FUNCTION_AT and VAR_AT macros * fix build issues oops * fix formatting * add PREDEFINED_VAR_AT * change func name * fixup formatting * update to use DEFINED_VAR_AT --- NorthstarDLL/engine/host.cpp | 3 +++ NorthstarDLL/engine/hoststate.cpp | 7 ++----- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'NorthstarDLL/engine') diff --git a/NorthstarDLL/engine/host.cpp b/NorthstarDLL/engine/host.cpp index 436a169d..49cc3663 100644 --- a/NorthstarDLL/engine/host.cpp +++ b/NorthstarDLL/engine/host.cpp @@ -5,7 +5,9 @@ #include "shared/misccommands.h" #include "r2engine.h" #include "core/tier0.h" + AUTOHOOK_INIT() + // clang-format off AUTOHOOK(Host_Init, engine.dll + 0x155EA0, void, __fastcall, (bool bDedicated)) @@ -24,6 +26,7 @@ void, __fastcall, (bool bDedicated)) else R2::Cbuf_AddText(R2::Cbuf_GetCurrentPlayer(), "exec autoexec_ns_client", R2::cmd_source_t::kCommandSrcCode); } + ON_DLL_LOAD("engine.dll", Host_Init, (CModule module)) { AUTOHOOK_DISPATCH() diff --git a/NorthstarDLL/engine/hoststate.cpp b/NorthstarDLL/engine/hoststate.cpp index 5a295425..44a66113 100644 --- a/NorthstarDLL/engine/hoststate.cpp +++ b/NorthstarDLL/engine/hoststate.cpp @@ -18,10 +18,10 @@ namespace R2 CHostState* g_pHostState; } // namespace R2 -ConVar* Cvar_hostport; std::string sLastMode; -void (*_fastcall _Cmd_Exec_f)(const CCommand& arg, bool bOnlyIfExists, bool bUseWhitelists); +VAR_AT(engine.dll + 0x13FA6070, ConVar*, Cvar_hostport); +FUNCTION_AT(engine.dll + 0x1232C0, void, __fastcall, _Cmd_Exec_f, (const CCommand& arg, bool bOnlyIfExists, bool bUseWhitelists)); void ServerStartingOrChangingMap() { @@ -194,7 +194,4 @@ ON_DLL_LOAD_RELIESON("engine.dll", HostState, ConVar, (CModule module)) AUTOHOOK_DISPATCH() g_pHostState = module.Offset(0x7CF180).As(); - Cvar_hostport = module.Offset(0x13FA6070).As(); - - _Cmd_Exec_f = module.Offset(0x1232C0).As(); } -- cgit v1.2.3