From e2b43b97532c075b9273538f4c8fa7063595240e Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sat, 28 May 2022 16:14:53 +0200 Subject: [PATCH] Update keyvaluesystem * Return global pointer with 'KeyValuesSystem()'. * Declare 'bCreate' as false by default for 'GetSymbolForString()' and 'GetSymbolForStringCaseSensitive()'. --- r5dev/vstdlib/keyvaluessystem.cpp | 8 ++++++++ r5dev/vstdlib/keyvaluessystem.h | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/r5dev/vstdlib/keyvaluessystem.cpp b/r5dev/vstdlib/keyvaluessystem.cpp index 82076459..7a9213e5 100644 --- a/r5dev/vstdlib/keyvaluessystem.cpp +++ b/r5dev/vstdlib/keyvaluessystem.cpp @@ -8,6 +8,14 @@ #include "core/stdafx.h" #include "vstdlib/keyvaluessystem.h" +//----------------------------------------------------------------------------- +// Instance singleton and expose interface to rest of code +//----------------------------------------------------------------------------- +CKeyValuesSystem* KeyValuesSystem() +{ + return &(*g_pKeyValuesSystem); +} + //----------------------------------------------------------------------------- // Purpose: registers the size of the KeyValues in the specified instance // so it can build a properly sized memory pool for the KeyValues objects diff --git a/r5dev/vstdlib/keyvaluessystem.h b/r5dev/vstdlib/keyvaluessystem.h index aa6cc597..4869d77e 100644 --- a/r5dev/vstdlib/keyvaluessystem.h +++ b/r5dev/vstdlib/keyvaluessystem.h @@ -9,13 +9,13 @@ public: void RegisterSizeofKeyValues(int64_t size); void* AllocKeyValuesMemory(int64_t size); void FreeKeyValuesMemory(void* pMem); - HKeySymbol GetSymbolForString(const char* name, bool bCreate); + HKeySymbol GetSymbolForString(const char* name, bool bCreate = false); const char* GetStringForSymbol(HKeySymbol symbol); void* GetMemPool(void); // GetMemPool returns a global variable called m_pMemPool, it gets modified by AllocKeyValuesMemory and with FreeKeyValuesMemory you can see where to find it in FreeKeyValuesMemory. void SetKeyValuesExpressionSymbol(const char* name, bool bValue); bool GetKeyValuesExpressionSymbol(const char* name); - HKeySymbol GetSymbolForStringCaseSensitive(HKeySymbol& hCaseInsensitiveSymbol, const char* name, bool bCreate); + HKeySymbol GetSymbolForStringCaseSensitive(HKeySymbol& hCaseInsensitiveSymbol, const char* name, bool bCreate = false); // Datatypes aren't accurate. But full fill the actual byte distance. public: @@ -35,6 +35,7 @@ public: int m_mutex; // 0x0130 }; +CKeyValuesSystem* KeyValuesSystem(); /* ==== KEYVALUESSYSTEM ================================================================================================================================================= */ inline void* g_pKeyValuesMemPool = nullptr; inline CKeyValuesSystem* g_pKeyValuesSystem = nullptr;