1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2025-01-03 16:13:22 +08:00

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

(cherry picked from commit 802ae03f3fb1464b9dcc7c015572e8de6d2970be)
This commit is contained in:
Maxim Telezhenko 2019-10-10 02:05:47 +03:00 committed by Nick Hastings
parent 9f9530c54b
commit 01e36b41b9

View File

@ -62,13 +62,14 @@ public:
virtual CVarDLLIdentifier_t AllocateDLLIdentifier() = 0; virtual CVarDLLIdentifier_t AllocateDLLIdentifier() = 0;
// Register, unregister commands // 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 UnregisterConCommand( ConCommandBase *pCommandBase ) = 0;
virtual void UnregisterConCommands( CVarDLLIdentifier_t id ) = 0; virtual void UnregisterConCommands( CVarDLLIdentifier_t id ) = 0;
// If there is a +<varname> <value> on the command line, this returns the value. // If there is a +<varname> <value> on the command line, this returns the value.
// Otherwise, it returns NULL. // 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 // Try to find the cvar pointer by name
virtual ConCommandBase *FindCommandBase( const char *name ) = 0; virtual ConCommandBase *FindCommandBase( const char *name ) = 0;
@ -197,6 +198,19 @@ inline ConCommandBase * ICvar::Iterator::Get( void )
return m_pIter->Get(); 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 // These global names are defined by tier1.h, duplicated here so you