diff --git a/r5dev/core/init.cpp b/r5dev/core/init.cpp index 82f256f3..39c8c8d7 100644 --- a/r5dev/core/init.cpp +++ b/r5dev/core/init.cpp @@ -648,4 +648,12 @@ void DetourRegister() // Register detour classes to be searched and hooked. REGISTER(VInputSystem); REGISTER(VDXGI); #endif // !DEDICATED -} \ No newline at end of file +} + +//----------------------------------------------------------------------------- +// Singleton accessors: +//----------------------------------------------------------------------------- +IKeyValuesSystem* KeyValuesSystem() +{ + return g_pKeyValuesSystem; +} diff --git a/r5dev/revpk/revpk.cpp b/r5dev/revpk/revpk.cpp index 2410c276..70a3ee7c 100644 --- a/r5dev/revpk/revpk.cpp +++ b/r5dev/revpk/revpk.cpp @@ -20,6 +20,14 @@ static CKeyValuesSystem s_KeyValuesSystem; static CFileSystem_Stdio g_FullFileSystem; +//----------------------------------------------------------------------------- +// Purpose: keyvalues singleton accessor +//----------------------------------------------------------------------------- +IKeyValuesSystem* KeyValuesSystem() +{ + return &s_KeyValuesSystem; +} + //----------------------------------------------------------------------------- // Purpose: filesystem singleton accessor //----------------------------------------------------------------------------- @@ -33,10 +41,6 @@ CFileSystem_Stdio* FileSystem() //----------------------------------------------------------------------------- static void ReVPK_Init() { - // Assign global kv accessor to static singleton object as we aren't linked - // to the game!!! - g_pKeyValuesSystem = &s_KeyValuesSystem; - g_CoreMsgVCallback = EngineLoggerSink; lzham_enable_fail_exceptions(true); diff --git a/r5dev/vstdlib/keyvaluessystem.cpp b/r5dev/vstdlib/keyvaluessystem.cpp index 8bd06393..d97df261 100644 --- a/r5dev/vstdlib/keyvaluessystem.cpp +++ b/r5dev/vstdlib/keyvaluessystem.cpp @@ -50,6 +50,9 @@ #define MEM_4BYTES_FROM_0_AND_3BYTES( x03bytes ) ( ( (uint32) (x03bytes) ) & 0x00FFFFFF ) #endif +CKeyValuesSystem* g_pKeyValuesSystem = nullptr; +void* g_pKeyValuesMemPool = nullptr; + //----------------------------------------------------------------------------- // Purpose: Constructor //----------------------------------------------------------------------------- diff --git a/r5dev/vstdlib/keyvaluessystem.h b/r5dev/vstdlib/keyvaluessystem.h index 43905ba9..df888747 100644 --- a/r5dev/vstdlib/keyvaluessystem.h +++ b/r5dev/vstdlib/keyvaluessystem.h @@ -6,7 +6,11 @@ #include "tier1/utlvector.h" #include "tier1/utlmap.h" -inline void* g_pKeyValuesMemPool = nullptr; +class CKeyValuesSystem; + +/* ==== KEYVALUESSYSTEM ================================================================================================================================================= */ +extern CKeyValuesSystem* g_pKeyValuesSystem; +extern void* g_pKeyValuesMemPool; class CKeyValuesSystem : public IKeyValuesSystem// VTABLE @ 0x1413AA1E8 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM { @@ -103,17 +107,6 @@ private: CThreadFastMutex m_Mutex; }; -/* ==== KEYVALUESSYSTEM ================================================================================================================================================= */ -inline CKeyValuesSystem* g_pKeyValuesSystem = nullptr; - -//----------------------------------------------------------------------------- -// Instance singleton and expose interface to rest of code -//----------------------------------------------------------------------------- -FORCEINLINE IKeyValuesSystem* KeyValuesSystem() -{ - return g_pKeyValuesSystem; -} - /////////////////////////////////////////////////////////////////////////////// class HKeyValuesSystem : public IDetour {