Browse Source

engine: common: add printf-like version of Cvar_Get function.

pull/2/head
Andrey Akhmichin 2 years ago committed by Alibek Omarov
parent
commit
a2d459ae84
  1. 17
      engine/common/cvar.c
  2. 1
      engine/common/cvar.h

17
engine/common/cvar.c

@ -469,6 +469,23 @@ convar_t *Cvar_Get( const char *name, const char *value, int flags, const char * @@ -469,6 +469,23 @@ convar_t *Cvar_Get( const char *name, const char *value, int flags, const char *
return var;
}
/*
============
Cvar_Getf
============
*/
convar_t *Cvar_Getf( const char *var_name, int flags, const char *description, const char *format, ... )
{
char value[MAX_VA_STRING];
va_list args;
va_start( args, format );
Q_vsnprintf( value, sizeof( value ), format, args );
va_end( args );
return Cvar_Get( var_name, value, flags, description );
}
/*
============
Cvar_RegisterVariable

1
engine/common/cvar.h

@ -63,6 +63,7 @@ cvar_t *Cvar_GetList( void ); @@ -63,6 +63,7 @@ cvar_t *Cvar_GetList( void );
convar_t *Cvar_FindVarExt( const char *var_name, int ignore_group );
void Cvar_RegisterVariable( convar_t *var );
convar_t *Cvar_Get( const char *var_name, const char *value, int flags, const char *description );
convar_t *Cvar_Getf( const char *var_name, int flags, const char *description, const char *format, ... ) _format( 4 );
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 );

Loading…
Cancel
Save