aboutsummaryrefslogtreecommitdiffstats
path: root/code
diff options
context:
space:
mode:
authorthilo <thilo@edf5b092-35ff-0310-97b2-ce42778d08ea>2008-05-01 11:29:49 +0000
committerthilo <thilo@edf5b092-35ff-0310-97b2-ce42778d08ea>2008-05-01 11:29:49 +0000
commite02f31a31c7cf4bccb2bbaaf5cbc0565be173552 (patch)
tree404b568fedeb8d7fb7ce3898937ead5748542661 /code
parent85058284a009de6f425843e29ce6529edcb80688 (diff)
downloadioquake3-aero-e02f31a31c7cf4bccb2bbaaf5cbc0565be173552.tar.gz
ioquake3-aero-e02f31a31c7cf4bccb2bbaaf5cbc0565be173552.zip
- variables with CVAR_ROM set get now overwritten by Cvar_Get() if the cvar exists already but was created by the user.
- Fix null pointer crash in Cvar_Print_f(), thanks to humancontroller for reporting. git-svn-id: svn://svn.icculus.org/quake3/trunk@1334 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code')
-rw-r--r--code/qcommon/cvar.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/code/qcommon/cvar.c b/code/qcommon/cvar.c
index cd0e8aa..9dfff2e 100644
--- a/code/qcommon/cvar.c
+++ b/code/qcommon/cvar.c
@@ -239,6 +239,16 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) {
// we don't have a reset string yet
Z_Free( var->resetString );
var->resetString = CopyString( var_value );
+
+ // if there is no reset string yet this means the variable was set by the user,
+ // so force it to value given by the engine.
+ if(var->flags & CVAR_ROM)
+ {
+ if(var->latchedString)
+ Z_Free(var->latchedString);
+
+ var->latchedString = CopyString(var_value);
+ }
} else if ( var_value[0] && strcmp( var->resetString, var_value ) ) {
Com_DPrintf( "Warning: cvar \"%s\" given initial values: \"%s\" and \"%s\"\n",
var_name, var->resetString, var_value );
@@ -253,13 +263,6 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) {
Z_Free( s );
}
-// use a CVAR_SET for rom sets, get won't override
-#if 0
- // CVAR_ROM always overrides
- if ( flags & CVAR_ROM ) {
- Cvar_Set2( var_name, var_value, qtrue );
- }
-#endif
return var;
}
@@ -553,8 +556,25 @@ Prints the contents of a cvar
(preferred over Cvar_Command where cvar names and commands conflict)
============
*/
-void Cvar_Print_f( void ) {
- Cvar_Print (Cvar_FindVar (Cmd_Argv(1)) );
+void Cvar_Print_f(void)
+{
+ char *name;
+ cvar_t *cv;
+
+ if(Cmd_Argc() != 2)
+ {
+ Com_Printf ("usage: print <variable>\n");
+ return;
+ }
+
+ name = Cmd_Argv(1);
+
+ cv = Cvar_FindVar(name);
+
+ if(cv)
+ Cvar_Print(cv);
+ else
+ Com_Printf ("Cvar %s does not exist.\n", name);
}
/*
@@ -599,8 +619,7 @@ void Cvar_Set_f( void ) {
return;
}
if ( c == 2 ) {
- v = Cvar_FindVar (Cmd_Argv(1));
- Cvar_Print( v );
+ Cvar_Print_f();
return;
}