aboutsummaryrefslogtreecommitdiffstats
path: root/code/qcommon
diff options
context:
space:
mode:
Diffstat (limited to 'code/qcommon')
-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;
}