Skip to content

Commit

Permalink
Add SetStringValue to ConVar
Browse files Browse the repository at this point in the history
  • Loading branch information
qubka committed Dec 6, 2024
1 parent 476d025 commit 721b71f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions public/tier1/convar.h
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,18 @@ class ConVar : public BaseConVar
this->UpdateValue( newValue, index, (const CVValue_t*)&newValue, (const CVValue_t*)&oldValue, szNewValue, szOldValue );
}

inline void SetStringValue( const char* szNewValue, size_t len, const CSplitScreenSlot& index = CSplitScreenSlot() )
{
auto newValue = CConVarData<T>::ValueFromString(szNewValue);

char szOldValue[256];
GetConVarData()->GetStringValue( szOldValue, sizeof(szOldValue), index );

// Deep copy
T oldValue = this->GetValue( );
this->UpdateValue( newValue, index, (const CVValue_t*)&newValue, (const CVValue_t*)&oldValue, szNewValue, szOldValue );
}

inline void GetStringValue( char* dst, size_t len, const CSplitScreenSlot& index = 0 ) const { GetConVarData()->GetStringValue( dst, len, index ); }

inline void GetStringDefaultValue( char* dst, size_t len ) const { GetConVarData()->GetStringDefaultValue( dst, len ); }
Expand Down

0 comments on commit 721b71f

Please sign in to comment.