Browse Source

engine: cvar: add Cvar_DirectSetValue function

pull/4/head
Alibek Omarov 10 months ago
parent
commit
9b6518376c
  1. 18
      engine/common/cvar.c
  2. 1
      engine/common/cvar.h

18
engine/common/cvar.c

@ -736,6 +736,24 @@ void Cvar_DirectSet( convar_t *var, const char *value ) @@ -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

1
engine/common/cvar.h

@ -66,6 +66,7 @@ convar_t *Cvar_Getf( const char *var_name, int flags, const char *description, c @@ -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 );

Loading…
Cancel
Save