diff options
Diffstat (limited to 'NorthstarDLL/convar.cpp')
-rw-r--r-- | NorthstarDLL/convar.cpp | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/NorthstarDLL/convar.cpp b/NorthstarDLL/convar.cpp index bf8edbf9..c8f63922 100644 --- a/NorthstarDLL/convar.cpp +++ b/NorthstarDLL/convar.cpp @@ -1,13 +1,11 @@ -#include <float.h> - #include "pch.h" #include "bits.h" #include "cvar.h" #include "convar.h" -#include "hookutils.h" -#include "gameutils.h" #include "sourceinterface.h" +#include <float.h> + typedef void (*ConVarRegisterType)( ConVar* pConVar, const char* pszName, @@ -27,25 +25,19 @@ ConVarMallocType conVarMalloc; void* g_pConVar_Vtable = nullptr; void* g_pIConVar_Vtable = nullptr; -typedef bool (*CvarIsFlagSetType)(ConVar* self, int flags); -CvarIsFlagSetType CvarIsFlagSet; - //----------------------------------------------------------------------------- // Purpose: ConVar interface initialization //----------------------------------------------------------------------------- -void InitialiseConVars(HMODULE baseAddress) +ON_DLL_LOAD("engine.dll", ConVar, (CModule module)) { - conVarMalloc = (ConVarMallocType)((char*)baseAddress + 0x415C20); - conVarRegister = (ConVarRegisterType)((char*)baseAddress + 0x417230); - - g_pConVar_Vtable = (char*)baseAddress + 0x67FD28; - g_pIConVar_Vtable = (char*)baseAddress + 0x67FDC8; + conVarMalloc = module.Offset(0x415C20).As<ConVarMallocType>(); + conVarRegister = module.Offset(0x417230).As<ConVarRegisterType>(); - g_pCVarInterface = new SourceInterface<CCvar>("vstdlib.dll", "VEngineCvar007"); - g_pCVar = *g_pCVarInterface; + g_pConVar_Vtable = module.Offset(0x67FD28); + g_pIConVar_Vtable = module.Offset(0x67FDC8); - HookEnabler hook; - ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x417FA0, &ConVar::IsFlagSet, reinterpret_cast<LPVOID*>(&CvarIsFlagSet)); + R2::g_pCVarInterface = new SourceInterface<CCvar>("vstdlib.dll", "VEngineCvar007"); + R2::g_pCVar = *R2::g_pCVarInterface; } //----------------------------------------------------------------------------- @@ -74,7 +66,7 @@ ConVar::ConVar( float fMin, bool bMax, float fMax, - void* pCallback) + FnChangeCallback_t pCallback) { spdlog::info("Registering Convar {}", pszName); @@ -476,16 +468,12 @@ bool ConVar::IsCommand(void) const //----------------------------------------------------------------------------- // Purpose: Test each ConVar query before setting the value. -// Input : *pConVar - nFlags +// Input : nFlags // Output : False if change is permitted, true if not. //----------------------------------------------------------------------------- -bool ConVar::IsFlagSet(ConVar* pConVar, int nFlags) +bool ConVar::IsFlagSet(int nFlags) const { - // unrestrict FCVAR_DEVELOPMENTONLY and FCVAR_HIDDEN - if (pConVar && (nFlags == FCVAR_DEVELOPMENTONLY || nFlags == FCVAR_HIDDEN)) - return false; - - return CvarIsFlagSet(pConVar, nFlags); + return m_ConCommandBase.m_nFlags & nFlags; } //----------------------------------------------------------------------------- |