KeyValues: fix singleton accessor compile errors

Make each instance implement the accessor instead of the KeyValues system itself.
This commit is contained in:
Kawe Mazidjatari 2024-01-12 01:51:28 +01:00
parent ab58decd9b
commit 89bb7f35c8
4 changed files with 25 additions and 17 deletions

View File

@ -648,4 +648,12 @@ void DetourRegister() // Register detour classes to be searched and hooked.
REGISTER(VInputSystem);
REGISTER(VDXGI);
#endif // !DEDICATED
}
}
//-----------------------------------------------------------------------------
// Singleton accessors:
//-----------------------------------------------------------------------------
IKeyValuesSystem* KeyValuesSystem()
{
return g_pKeyValuesSystem;
}

View File

@ -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);

View File

@ -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
//-----------------------------------------------------------------------------

View File

@ -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
{