diff --git a/code/client/cl_main.c b/code/client/cl_main.c index e44ab855..75f0dca0 100644 --- a/code/client/cl_main.c +++ b/code/client/cl_main.c @@ -3237,6 +3237,7 @@ void CL_InitRef( void ) { ri.Cvar_Set = Cvar_Set; ri.Cvar_SetValue = Cvar_SetValue; ri.Cvar_CheckRange = Cvar_CheckRange; + ri.Cvar_SetDescription = Cvar_SetDescription; ri.Cvar_VariableIntegerValue = Cvar_VariableIntegerValue; // cinematic stuff diff --git a/code/qcommon/common.c b/code/qcommon/common.c index 36cb4ce6..3f06c75b 100644 --- a/code/qcommon/common.c +++ b/code/qcommon/common.c @@ -1537,6 +1537,7 @@ void Com_InitHunkMemory( void ) { // allocate the stack based hunk allocator cv = Cvar_Get( "com_hunkMegs", DEF_COMHUNKMEGS_S, CVAR_LATCH | CVAR_ARCHIVE ); + Cvar_SetDescription(cv, "The size of the hunk memory segment"); // if we are not dedicated min allocation is 56, otherwise min is 1 if (com_dedicated && com_dedicated->integer) { diff --git a/code/qcommon/cvar.c b/code/qcommon/cvar.c index 53a36845..88d2e891 100644 --- a/code/qcommon/cvar.c +++ b/code/qcommon/cvar.c @@ -438,6 +438,7 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) { var->integer = atoi(var->string); var->resetString = CopyString( var_value ); var->validate = qfalse; + var->description = NULL; // link the variable in var->next = cvar_vars; @@ -489,6 +490,10 @@ void Cvar_Print( cvar_t *v ) { if ( v->latchedString ) { Com_Printf( "latched: \"%s\"\n", v->latchedString ); } + + if ( v->description ) { + Com_Printf( "%s\n", v->description ); + } } /* @@ -1036,6 +1041,8 @@ cvar_t *Cvar_Unset(cvar_t *cv) Z_Free(cv->latchedString); if(cv->resetString) Z_Free(cv->resetString); + if(cv->description) + Z_Free(cv->description); if(cv->prev) cv->prev->next = cv->next; @@ -1205,6 +1212,23 @@ void Cvar_CheckRange( cvar_t *var, float min, float max, qboolean integral ) Cvar_Set( var->name, var->string ); } +/* +===================== +Cvar_SetDescription +===================== +*/ +void Cvar_SetDescription( cvar_t *var, const char *var_description ) +{ + if( var_description && var_description[0] != '\0' ) + { + if( var->description != NULL ) + { + Z_Free( var->description ); + } + var->description = CopyString( var_description ); + } +} + /* ===================== Cvar_Register diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h index baed3f89..90996a29 100644 --- a/code/qcommon/q_shared.h +++ b/code/qcommon/q_shared.h @@ -921,6 +921,7 @@ struct cvar_s { qboolean integral; float min; float max; + char *description; cvar_t *next; cvar_t *prev; diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index 414b341b..62f753e3 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -562,6 +562,7 @@ char *Cvar_InfoString_Big( int bit ); // in their flags ( CVAR_USERINFO, CVAR_SERVERINFO, CVAR_SYSTEMINFO, etc ) void Cvar_InfoStringBuffer( int bit, char *buff, int buffsize ); void Cvar_CheckRange( cvar_t *cv, float minVal, float maxVal, qboolean shouldBeIntegral ); +void Cvar_SetDescription( cvar_t *var, const char *var_description ); void Cvar_Restart(qboolean unsetVM); void Cvar_Restart_f( void ); diff --git a/code/renderercommon/tr_public.h b/code/renderercommon/tr_public.h index b93bbdbb..38d647f6 100644 --- a/code/renderercommon/tr_public.h +++ b/code/renderercommon/tr_public.h @@ -133,6 +133,7 @@ typedef struct { void (*Cvar_Set)( const char *name, const char *value ); void (*Cvar_SetValue) (const char *name, float value); void (*Cvar_CheckRange)( cvar_t *cv, float minVal, float maxVal, qboolean shouldBeIntegral ); + void (*Cvar_SetDescription)( cvar_t *cv, const char *description ); int (*Cvar_VariableIntegerValue) (const char *var_name);