engine: cvar: add Cvar_DirectSetValue function

This commit is contained in:
Alibek Omarov 2024-01-13 05:18:30 +03:00
parent 6c3fee7f27
commit 9b6518376c
2 changed files with 19 additions and 0 deletions

View File

@ -736,6 +736,24 @@ void Cvar_DirectSet( convar_t *var, const char *value )
Cvar_Changed( var );
}
/*
============
Cvar_DirectSetValue
functionally is the same as Cvar_SetValue but for direct cvar access
============
*/
void Cvar_DirectSetValue( convar_t *var, float value )
{
char val[32];
if( fabs( value - (int)value ) < 0.000001 )
Q_snprintf( val, sizeof( val ), "%d", (int)value );
else Q_snprintf( val, sizeof( val ), "%f", value );
Cvar_DirectSet( var, val );
}
/*
============
Cvar_FullSet

View File

@ -66,6 +66,7 @@ convar_t *Cvar_Getf( const char *var_name, int flags, const char *description, c
void Cvar_LookupVars( int checkbit, void *buffer, void *ptr, setpair_t callback );
void Cvar_FullSet( const char *var_name, const char *value, int flags );
void Cvar_DirectSet( convar_t *var, const char *value );
void Cvar_DirectSetValue( convar_t *var, float value );
void Cvar_Set( const char *var_name, const char *value );
void Cvar_SetValue( const char *var_name, float value );
const char *Cvar_BuildAutoDescription( const char *szName, int flags );