mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-10 14:52:00 +00:00
- 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.
This commit is contained in:
parent
82e32bdf41
commit
65938da5ae
1 changed files with 30 additions and 11 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue