mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-09-20 04:26:03 +08:00
KeyValues & ICommandLine fixes after 7/2/24 CS2 update (#201)
Co-authored-by: GAMMACASE <31375974+GAMMACASE@users.noreply.github.com>
This commit is contained in:
Binary file not shown.
Binary file not shown.
@ -1,4 +1,4 @@
|
|||||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||||
//
|
//
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//
|
//
|
||||||
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
|
|
||||||
|
class CBufferString;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: Interface to engine command line
|
// Purpose: Interface to engine command line
|
||||||
@ -21,12 +22,11 @@ abstract_class ICommandLine
|
|||||||
public:
|
public:
|
||||||
virtual void CreateCmdLine( const char *commandline ) = 0;
|
virtual void CreateCmdLine( const char *commandline ) = 0;
|
||||||
virtual void CreateCmdLine( int argc, char **argv ) = 0;
|
virtual void CreateCmdLine( int argc, char **argv ) = 0;
|
||||||
virtual const char *GetCmdLine( void ) const = 0;
|
virtual void CreateCmdLinePrependAppName( const char *commandline ) = 0;
|
||||||
|
|
||||||
// Check whether a particular parameter exists
|
// Check whether a particular parameter exists
|
||||||
virtual const char *CheckParm( const char *psz, const char **ppszValue = 0 ) const = 0;
|
virtual const char *CheckParm( const char *psz, const char **ppszValue = 0 ) const = 0;
|
||||||
virtual bool HasParm( const char *psz ) const = 0;
|
virtual bool HasParm( const char *psz ) const = 0;
|
||||||
virtual void AppendParm( const char *pszParm, const char *pszValues ) = 0;
|
|
||||||
|
|
||||||
// Gets at particular parameters
|
// Gets at particular parameters
|
||||||
virtual int ParmCount() const = 0;
|
virtual int ParmCount() const = 0;
|
||||||
@ -37,14 +37,16 @@ public:
|
|||||||
virtual const char *ParmValue( const char *psz, const char *pDefaultVal = 0 ) const = 0;
|
virtual const char *ParmValue( const char *psz, const char *pDefaultVal = 0 ) const = 0;
|
||||||
virtual int ParmValue( const char *psz, int nDefaultVal ) const = 0;
|
virtual int ParmValue( const char *psz, int nDefaultVal ) const = 0;
|
||||||
virtual float ParmValue( const char *psz, float flDefaultVal ) const = 0;
|
virtual float ParmValue( const char *psz, float flDefaultVal ) const = 0;
|
||||||
virtual bool ParmValue( const char *psz, const char *pDefaultVal, char *pszOut, unsigned int size ) = 0;
|
virtual bool ParmValue( const char *psz, const char *pDefaultVal, CBufferString *bufOut ) = 0;
|
||||||
|
|
||||||
virtual const char *ParmValueByIndex( int nIndex, const char *pDefaultVal ) const = 0;
|
|
||||||
|
|
||||||
virtual void CreateCmdLinePrependAppName( const char *commandline ) = 0;
|
|
||||||
virtual const char **GetParms() const = 0;
|
virtual const char **GetParms() const = 0;
|
||||||
|
virtual const char *GetCmdLine( void ) const = 0;
|
||||||
|
virtual void AppendParm( const char *pszParm, const char *pszValues ) = 0;
|
||||||
|
|
||||||
virtual bool IsWellInitialized( void ) const = 0;
|
// Returns true if there's atleast one parm available
|
||||||
|
virtual bool HasParms( void ) const = 0;
|
||||||
|
|
||||||
|
virtual const char *GetUnkString() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -85,6 +85,12 @@ public:
|
|||||||
TYPE_NUMTYPES,
|
TYPE_NUMTYPES,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// AMNOTE: Valve scrapped the public-facing version of these,
|
||||||
|
// so we have to expose as protected for the scaffolds below in KeyValues.
|
||||||
|
char const *Internal_GetString( const char *defaultValue, char *szBuf, size_t maxlen );
|
||||||
|
const wchar_t *Internal_GetWString( const wchar_t *defaultValue, wchar_t *szBuf, size_t maxlen );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IKeyValuesSystem *KVSystem() const;
|
IKeyValuesSystem *KVSystem() const;
|
||||||
|
|
||||||
@ -119,8 +125,6 @@ private:
|
|||||||
float Internal_GetFloat() const;
|
float Internal_GetFloat() const;
|
||||||
int Internal_GetInt() const;
|
int Internal_GetInt() const;
|
||||||
uint64 Internal_GetUint64() const;
|
uint64 Internal_GetUint64() const;
|
||||||
char const *Internal_GetString( const char *defaultValue, char *szBuf, size_t maxlen );
|
|
||||||
const wchar_t *Internal_GetWString( const wchar_t *defaultValue, wchar_t *szBuf, size_t maxlen );
|
|
||||||
void *Internal_GetPtr() const;
|
void *Internal_GetPtr() const;
|
||||||
|
|
||||||
void Internal_SetColor( Color value );
|
void Internal_SetColor( Color value );
|
||||||
@ -254,9 +258,9 @@ public:
|
|||||||
|
|
||||||
// Find a keyValue, create it if it is not found.
|
// Find a keyValue, create it if it is not found.
|
||||||
// Set bCreate to true to create the key if it doesn't already exist (which ensures a valid pointer will be returned)
|
// Set bCreate to true to create the key if it doesn't already exist (which ensures a valid pointer will be returned)
|
||||||
KeyValues *FindKey( const char *keyName, bool bCreate );
|
KeyValues *FindKey( const char *keyName, bool bCreate = false );
|
||||||
const KeyValues *FindKey( const char *keyName ) const;
|
const KeyValues *FindKey( const char *keyName ) const;
|
||||||
KeyValues *FindKey( HKeySymbol keySymbol ) const;
|
KeyValues *FindKey( HKeySymbol keySymbol );
|
||||||
KeyValues *FindKeyAndParent( const char *keyName, KeyValues **pParent, bool );
|
KeyValues *FindKeyAndParent( const char *keyName, KeyValues **pParent, bool );
|
||||||
bool FindAndDeleteSubKey( const char *keyName );
|
bool FindAndDeleteSubKey( const char *keyName );
|
||||||
|
|
||||||
@ -281,9 +285,9 @@ public:
|
|||||||
// NOTE: GetFirstSubKey/GetNextKey will iterate keys AND values. Use the functions
|
// NOTE: GetFirstSubKey/GetNextKey will iterate keys AND values. Use the functions
|
||||||
// below if you want to iterate over just the keys or just the values.
|
// below if you want to iterate over just the keys or just the values.
|
||||||
//
|
//
|
||||||
KeyValues *GetFirstSubKey() const; // returns the first subkey in the list
|
KeyValues *GetFirstSubKey(); // returns the first subkey in the list
|
||||||
KeyValues *FindLastSubKey() const;
|
KeyValues *FindLastSubKey();
|
||||||
KeyValues *GetNextKey() const; // returns the next subkey
|
KeyValues *GetNextKey(); // returns the next subkey
|
||||||
void SetNextKey( KeyValues *pDat );
|
void SetNextKey( KeyValues *pDat );
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -299,11 +303,11 @@ public:
|
|||||||
// {
|
// {
|
||||||
// Msg( "Int value: %d\n", pValue->GetInt() ); // Assuming pValue->GetDataType() == TYPE_INT...
|
// Msg( "Int value: %d\n", pValue->GetInt() ); // Assuming pValue->GetDataType() == TYPE_INT...
|
||||||
// }
|
// }
|
||||||
KeyValues *GetFirstTrueSubKey() const;
|
KeyValues *GetFirstTrueSubKey();
|
||||||
KeyValues *GetNextTrueSubKey() const;
|
KeyValues *GetNextTrueSubKey();
|
||||||
|
|
||||||
KeyValues *GetFirstValue() const; // When you get a value back, you can use GetX and pass in NULL to get the value.
|
KeyValues *GetFirstValue(); // When you get a value back, you can use GetX and pass in NULL to get the value.
|
||||||
KeyValues *GetNextValue() const;
|
KeyValues *GetNextValue();
|
||||||
|
|
||||||
|
|
||||||
// Data access
|
// Data access
|
||||||
@ -318,15 +322,15 @@ public:
|
|||||||
bool IsEmpty( const char *keyName = NULL ) const;
|
bool IsEmpty( const char *keyName = NULL ) const;
|
||||||
|
|
||||||
// Data access
|
// Data access
|
||||||
int GetInt( HKeySymbol keySymbol, int defaultValue = 0 ) const;
|
int GetInt( HKeySymbol keySymbol, int defaultValue = 0 );
|
||||||
uint64 GetUint64( HKeySymbol keySymbol, uint64 defaultValue = 0 ) const;
|
uint64 GetUint64( HKeySymbol keySymbol, uint64 defaultValue = 0 );
|
||||||
float GetFloat( HKeySymbol keySymbol, float defaultValue = 0.0f ) const;
|
float GetFloat( HKeySymbol keySymbol, float defaultValue = 0.0f );
|
||||||
const char *GetString( HKeySymbol keySymbol, const char *defaultValue = "", char *pszOut = NULL, size_t maxlen = 0 );
|
const char *GetString( HKeySymbol keySymbol, const char *defaultValue = "", char *pszOut = NULL, size_t maxlen = 0 );
|
||||||
const wchar_t *GetWString( HKeySymbol keySymbol, const wchar_t *defaultValue = L"", wchar_t *pszOut = NULL, size_t maxlen = 0 );
|
const wchar_t *GetWString( HKeySymbol keySymbol, const wchar_t *defaultValue = L"", wchar_t *pszOut = NULL, size_t maxlen = 0 );
|
||||||
void *GetPtr( HKeySymbol keySymbol, void *defaultValue = (void *)0 ) const;
|
void *GetPtr( HKeySymbol keySymbol, void *defaultValue = (void *)0 );
|
||||||
Color GetColor( HKeySymbol keySymbol, const Color &defaultColor = Color( 0, 0, 0, 0 ) ) const;
|
Color GetColor( HKeySymbol keySymbol, const Color &defaultColor = Color( 0, 0, 0, 0 ) );
|
||||||
bool GetBool( HKeySymbol keySymbol, bool defaultValue = false ) const { return GetInt( keySymbol, defaultValue ? 1 : 0 ) ? true : false; }
|
bool GetBool( HKeySymbol keySymbol, bool defaultValue = false ) { return GetInt( keySymbol, defaultValue ? 1 : 0 ) ? true : false; }
|
||||||
bool IsEmpty( HKeySymbol keySymbol ) const;
|
bool IsEmpty( HKeySymbol keySymbol );
|
||||||
|
|
||||||
// Key writing
|
// Key writing
|
||||||
void SetWString( const char *keyName, const wchar_t *value );
|
void SetWString( const char *keyName, const wchar_t *value );
|
||||||
@ -353,7 +357,7 @@ public:
|
|||||||
|
|
||||||
KeyValues &operator=( KeyValues &src );
|
KeyValues &operator=( KeyValues &src );
|
||||||
|
|
||||||
void RecursiveSaveToFile( CUtlBuffer &buf, int indentLevel, bool bSortKeys = false, bool bAllowEmptyString = false );
|
void RecursiveSaveToFile( CUtlBuffer &buf, int indentLevel, bool bSortKeys = false, bool bAllowEmptyString = false ) const;
|
||||||
void RecursiveSaveToLocalizationFile( IFileSystem *filesystem, void *buf, int indentLevel, bool bAllowEmptyString = false );
|
void RecursiveSaveToLocalizationFile( IFileSystem *filesystem, void *buf, int indentLevel, bool bAllowEmptyString = false );
|
||||||
|
|
||||||
bool WriteAsBinary( CUtlBuffer &buffer );
|
bool WriteAsBinary( CUtlBuffer &buffer );
|
||||||
@ -375,7 +379,7 @@ public:
|
|||||||
|
|
||||||
int Count( void ) const;
|
int Count( void ) const;
|
||||||
|
|
||||||
KeyValues *Element( int nIndex ) const;
|
KeyValues *Element( int nIndex );
|
||||||
|
|
||||||
CKeyValues_Data::types_t GetDataType( const char *keyName = NULL ) const;
|
CKeyValues_Data::types_t GetDataType( const char *keyName = NULL ) const;
|
||||||
|
|
||||||
@ -441,19 +445,19 @@ struct KeyValuesUnpackStructure
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// inline methods
|
// inline methods
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
inline int KeyValues::GetInt( HKeySymbol keySymbol, int defaultValue ) const
|
inline int KeyValues::GetInt( HKeySymbol keySymbol, int defaultValue )
|
||||||
{
|
{
|
||||||
KeyValues *dat = FindKey( keySymbol );
|
KeyValues *dat = FindKey( keySymbol );
|
||||||
return dat ? dat->GetInt( (const char *)NULL, defaultValue ) : defaultValue;
|
return dat ? dat->GetInt( (const char *)NULL, defaultValue ) : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint64 KeyValues::GetUint64( HKeySymbol keySymbol, uint64 defaultValue ) const
|
inline uint64 KeyValues::GetUint64( HKeySymbol keySymbol, uint64 defaultValue )
|
||||||
{
|
{
|
||||||
KeyValues *dat = FindKey( keySymbol );
|
KeyValues *dat = FindKey( keySymbol );
|
||||||
return dat ? dat->GetUint64( (const char *)NULL, defaultValue ) : defaultValue;
|
return dat ? dat->GetUint64( (const char *)NULL, defaultValue ) : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float KeyValues::GetFloat( HKeySymbol keySymbol, float defaultValue ) const
|
inline float KeyValues::GetFloat( HKeySymbol keySymbol, float defaultValue )
|
||||||
{
|
{
|
||||||
KeyValues *dat = FindKey( keySymbol );
|
KeyValues *dat = FindKey( keySymbol );
|
||||||
return dat ? dat->GetFloat( (const char *)NULL, defaultValue ) : defaultValue;
|
return dat ? dat->GetFloat( (const char *)NULL, defaultValue ) : defaultValue;
|
||||||
@ -471,24 +475,35 @@ inline const wchar_t *KeyValues::GetWString( HKeySymbol keySymbol, const wchar_t
|
|||||||
return dat ? dat->GetWString( (const char *)NULL, defaultValue, pszOut, maxlen ) : defaultValue;
|
return dat ? dat->GetWString( (const char *)NULL, defaultValue, pszOut, maxlen ) : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void *KeyValues::GetPtr( HKeySymbol keySymbol, void *defaultValue ) const
|
inline void *KeyValues::GetPtr( HKeySymbol keySymbol, void *defaultValue )
|
||||||
{
|
{
|
||||||
KeyValues *dat = FindKey( keySymbol );
|
KeyValues *dat = FindKey( keySymbol );
|
||||||
return dat ? dat->GetPtr( (const char *)NULL, defaultValue ) : defaultValue;
|
return dat ? dat->GetPtr( (const char *)NULL, defaultValue ) : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Color KeyValues::GetColor( HKeySymbol keySymbol, const Color &defaultColor ) const
|
inline Color KeyValues::GetColor( HKeySymbol keySymbol, const Color &defaultColor )
|
||||||
{
|
{
|
||||||
KeyValues *dat = FindKey( keySymbol );
|
KeyValues *dat = FindKey( keySymbol );
|
||||||
return dat ? dat->GetColor( (const char *)NULL, defaultColor ) : defaultColor;
|
return dat ? dat->GetColor( (const char *)NULL, defaultColor ) : defaultColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool KeyValues::IsEmpty( HKeySymbol keySymbol ) const
|
inline bool KeyValues::IsEmpty( HKeySymbol keySymbol )
|
||||||
{
|
{
|
||||||
KeyValues *dat = FindKey( keySymbol );
|
KeyValues *dat = FindKey( keySymbol );
|
||||||
return dat ? dat->IsEmpty() : true;
|
return dat ? dat->IsEmpty() : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const char *KeyValues::GetString( const char *keyName, const char *defaultValue, char *pszOut, size_t maxlen )
|
||||||
|
{
|
||||||
|
KeyValues *dat = FindKey( keyName );
|
||||||
|
return dat ? dat->Internal_GetString( defaultValue, pszOut, maxlen ) : defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const wchar_t *KeyValues::GetWString( const char *keyName, const wchar_t *defaultValue, wchar_t *pszOut, size_t maxlen )
|
||||||
|
{
|
||||||
|
KeyValues *dat = FindKey( keyName );
|
||||||
|
return dat ? dat->Internal_GetWString( defaultValue, pszOut, maxlen ) : defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// KeyValuesDumpContext and generic implementations
|
// KeyValuesDumpContext and generic implementations
|
||||||
|
Reference in New Issue
Block a user