From 802ae03f3fb1464b9dcc7c015572e8de6d2970be Mon Sep 17 00:00:00 2001 From: Maxim Telezhenko Date: Thu, 10 Oct 2019 02:05:47 +0300 Subject: [PATCH] csgo: Update ICvar interface (#61) * csgo: Update ICvar interface GetCommandLineValue was replaced by HasCommandLineValue. Update RegisterConCommand param name. * Restore ICvar::GetCommandLineValue * Make ICvar::GetCommandLineValue non-static --- public/icvar.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/public/icvar.h b/public/icvar.h index ffb795bd..7a2c1204 100644 --- a/public/icvar.h +++ b/public/icvar.h @@ -62,13 +62,14 @@ public: virtual CVarDLLIdentifier_t AllocateDLLIdentifier() = 0; // Register, unregister commands - virtual void RegisterConCommand( ConCommandBase *pCommandBase, bool unknown=true ) = 0; + virtual void RegisterConCommand( ConCommandBase *pCommandBase, bool cmdline=true ) = 0; virtual void UnregisterConCommand( ConCommandBase *pCommandBase ) = 0; virtual void UnregisterConCommands( CVarDLLIdentifier_t id ) = 0; // If there is a + on the command line, this returns the value. // Otherwise, it returns NULL. - virtual const char* GetCommandLineValue( const char *pVariableName ) = 0; + inline const char* GetCommandLineValue( const char *pVariableName ); + virtual bool HasCommandLineValue( const char *pVariableName ) = 0; // Try to find the cvar pointer by name virtual ConCommandBase *FindCommandBase( const char *name ) = 0; @@ -197,6 +198,19 @@ inline ConCommandBase * ICvar::Iterator::Get( void ) return m_pIter->Get(); } +inline const char *ICvar::GetCommandLineValue( const char *pVariableName ) +{ + if (pVariableName[0] == '\0') + return NULL; + size_t len = strlen(pVariableName); + char *search = new char[len + 2]; + search[0] = '+'; + memcpy(&search[1], pVariableName, len + 1); + const char *value = CommandLine()->ParmValue(search); + delete[] search; + return value; +} + //----------------------------------------------------------------------------- // These global names are defined by tier1.h, duplicated here so you