2007-11-25 22:00:00 +01:00
|
|
|
|
//=======================================================================
|
|
|
|
|
// Copyright XashXT Group 2007 <20>
|
|
|
|
|
// cvar.c -- dynamic variable tracking
|
|
|
|
|
//=======================================================================
|
2007-11-18 22:00:00 +01:00
|
|
|
|
|
2007-11-25 22:00:00 +01:00
|
|
|
|
#include "launch.h"
|
2007-11-18 22:00:00 +01:00
|
|
|
|
|
2007-11-25 22:00:00 +01:00
|
|
|
|
#define MAX_CVARS 2048
|
2007-11-18 22:00:00 +01:00
|
|
|
|
#define FILE_HASH_SIZE 256
|
|
|
|
|
|
|
|
|
|
int cvar_numIndexes;
|
|
|
|
|
int cvar_modifiedFlags;
|
|
|
|
|
cvar_t cvar_indexes[MAX_CVARS];
|
2007-11-25 22:00:00 +01:00
|
|
|
|
cvar_t *cvar_vars;
|
2007-11-18 22:00:00 +01:00
|
|
|
|
static cvar_t* hashTable[FILE_HASH_SIZE];
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
================
|
|
|
|
|
return a hash value for the filename
|
|
|
|
|
================
|
|
|
|
|
*/
|
|
|
|
|
static long Cvar_GetHashValue( const char *fname )
|
|
|
|
|
{
|
|
|
|
|
int i = 0;
|
|
|
|
|
long hash = 0;
|
|
|
|
|
char letter;
|
|
|
|
|
|
|
|
|
|
while (fname[i] != '\0')
|
|
|
|
|
{
|
2007-11-25 22:00:00 +01:00
|
|
|
|
letter = com_tolower(fname[i]);
|
2007-11-18 22:00:00 +01:00
|
|
|
|
hash += (long)(letter)*(i + 119);
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
hash &= (FILE_HASH_SIZE - 1);
|
|
|
|
|
return hash;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_InfoValidate
|
|
|
|
|
============
|
|
|
|
|
*/
|
2008-12-25 22:00:00 +01:00
|
|
|
|
static bool Cvar_ValidateString( const char *s, bool isvalue )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
2008-12-25 22:00:00 +01:00
|
|
|
|
if( !s ) return false;
|
|
|
|
|
if( com.strstr( s, "\\" ) && !isvalue )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
return false;
|
2008-12-25 22:00:00 +01:00
|
|
|
|
if( com.strstr( s, "\"" )) return false;
|
|
|
|
|
if( com.strstr( s, ";" )) return false;
|
2007-11-18 22:00:00 +01:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_FindVar
|
|
|
|
|
============
|
|
|
|
|
*/
|
2007-11-25 22:00:00 +01:00
|
|
|
|
cvar_t *Cvar_FindVar( const char *var_name )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
cvar_t *var;
|
|
|
|
|
long hash;
|
|
|
|
|
|
2009-09-10 22:00:00 +02:00
|
|
|
|
hash = Cvar_GetHashValue( var_name );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
|
2009-09-10 22:00:00 +02:00
|
|
|
|
for( var = hashTable[hash]; var; var = var->hash )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
2009-09-10 22:00:00 +02:00
|
|
|
|
if (!com.stricmp( var_name, var->name ))
|
2007-11-18 22:00:00 +01:00
|
|
|
|
return var;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_VariableValue
|
|
|
|
|
============
|
|
|
|
|
*/
|
2009-09-10 22:00:00 +02:00
|
|
|
|
float Cvar_VariableValue( const char *var_name )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
cvar_t *var;
|
2009-09-10 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
var = Cvar_FindVar( var_name );
|
|
|
|
|
if( !var ) return 0;
|
2007-11-18 22:00:00 +01:00
|
|
|
|
return var->value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_VariableIntegerValue
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
int Cvar_VariableInteger( const char *var_name )
|
|
|
|
|
{
|
|
|
|
|
cvar_t *var;
|
2009-09-10 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
var = Cvar_FindVar( var_name );
|
|
|
|
|
if( !var ) return 0;
|
2007-11-18 22:00:00 +01:00
|
|
|
|
return var->integer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_VariableString
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
char *Cvar_VariableString (const char *var_name)
|
|
|
|
|
{
|
|
|
|
|
cvar_t *var;
|
|
|
|
|
var = Cvar_FindVar (var_name);
|
|
|
|
|
if (!var) return "";
|
|
|
|
|
return var->string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
2007-11-27 22:00:00 +01:00
|
|
|
|
Cvar_LookupVars
|
2007-11-18 22:00:00 +01:00
|
|
|
|
============
|
|
|
|
|
*/
|
2008-08-15 22:00:00 +02:00
|
|
|
|
void Cvar_LookupVars( int checkbit, void *buffer, void *ptr, setpair_t callback )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
2007-11-25 22:00:00 +01:00
|
|
|
|
cvar_t *cvar;
|
2007-11-27 22:00:00 +01:00
|
|
|
|
|
2008-08-15 22:00:00 +02:00
|
|
|
|
// nothing to process ?
|
|
|
|
|
if( !callback ) return;
|
|
|
|
|
|
2007-11-27 22:00:00 +01:00
|
|
|
|
// force checkbit to 0 for lookup all cvars
|
2007-11-18 22:00:00 +01:00
|
|
|
|
for( cvar = cvar_vars; cvar; cvar = cvar->next )
|
2007-11-27 22:00:00 +01:00
|
|
|
|
{
|
2007-11-29 22:00:00 +01:00
|
|
|
|
if(checkbit && !(cvar->flags & checkbit)) continue;
|
2008-08-01 22:00:00 +02:00
|
|
|
|
if( buffer ) callback( cvar->name, cvar->string, buffer, ptr );
|
2007-11-27 22:00:00 +01:00
|
|
|
|
else callback( cvar->name, cvar->string, cvar->description, ptr );
|
|
|
|
|
}
|
2007-11-18 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_Get
|
|
|
|
|
|
|
|
|
|
If the variable already exists, the value will not be set
|
|
|
|
|
The flags will be or'ed in if the variable exists.
|
|
|
|
|
============
|
|
|
|
|
*/
|
2007-11-25 22:00:00 +01:00
|
|
|
|
cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags, const char *var_desc )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
cvar_t *var;
|
|
|
|
|
long hash;
|
|
|
|
|
|
|
|
|
|
if(!var_name || !var_value)
|
|
|
|
|
{
|
|
|
|
|
MsgDev( D_ERROR, "Cvar_Get: NULL parameter" );
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Cvar_ValidateString(var_name, false))
|
|
|
|
|
{
|
|
|
|
|
MsgDev(D_WARN, "invalid info cvar name string %s\n", var_name );
|
|
|
|
|
var_value = "noname";
|
|
|
|
|
}
|
|
|
|
|
if(!Cvar_ValidateString( var_value, true ))
|
|
|
|
|
{
|
|
|
|
|
MsgDev(D_WARN, "invalid cvar value string: %s\n", var_value );
|
|
|
|
|
var_value = "default";
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-25 22:00:00 +01:00
|
|
|
|
// check for command coexisting
|
|
|
|
|
if(Cmd_Exists(var_name))
|
|
|
|
|
{
|
|
|
|
|
MsgDev(D_WARN, "Cvar_Get: %s is a command\n", var_name );
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-04 22:00:00 +02:00
|
|
|
|
var = Cvar_FindVar( var_name );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
if ( var )
|
|
|
|
|
{
|
|
|
|
|
// if the C code is now specifying a variable that the user already
|
|
|
|
|
// set a value for, take the new value as the reset value
|
|
|
|
|
|
|
|
|
|
if(( var->flags & CVAR_USER_CREATED ) && !( flags & CVAR_USER_CREATED ) && var_value[0])
|
|
|
|
|
{
|
|
|
|
|
var->flags &= ~CVAR_USER_CREATED;
|
2007-11-25 22:00:00 +01:00
|
|
|
|
Mem_Free( var->reset_string );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
var->reset_string = copystring( var_value );
|
|
|
|
|
cvar_modifiedFlags |= flags;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var->flags |= flags;
|
|
|
|
|
|
|
|
|
|
// only allow one non-empty reset string without a warning
|
2008-08-04 22:00:00 +02:00
|
|
|
|
if( !var->reset_string )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
// we don't have a reset string yet
|
2007-11-25 22:00:00 +01:00
|
|
|
|
Mem_Free( var->reset_string );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
var->reset_string = copystring( var_value );
|
|
|
|
|
}
|
2008-08-04 22:00:00 +02:00
|
|
|
|
else if( var_value[0] && com_strcmp( var->reset_string, var_value ))
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
2008-08-27 22:00:00 +02:00
|
|
|
|
MsgDev( D_STRING, "cvar \"%s\" given initial values: \"%s\" and \"%s\"\n", var_name, var->reset_string, var_value );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if we have a latched string, take that value now
|
|
|
|
|
if ( var->latched_string )
|
|
|
|
|
{
|
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
|
|
s = var->latched_string;
|
|
|
|
|
var->latched_string = NULL; // otherwise cvar_set2 would free it
|
|
|
|
|
Cvar_Set2( var_name, s, true );
|
2007-11-25 22:00:00 +01:00
|
|
|
|
Mem_Free( s );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
}
|
2009-08-01 22:00:00 +02:00
|
|
|
|
if( var_desc )
|
|
|
|
|
{
|
|
|
|
|
// update description if needs
|
|
|
|
|
if( var->description ) Mem_Free( var->description );
|
|
|
|
|
var->description = copystring( var_desc );
|
|
|
|
|
}
|
2007-11-18 22:00:00 +01:00
|
|
|
|
return var;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// allocate a new cvar
|
|
|
|
|
if( cvar_numIndexes >= MAX_CVARS )
|
|
|
|
|
{
|
2008-06-05 22:00:00 +02:00
|
|
|
|
MsgDev( D_ERROR, "Cvar_Get: MAX_CVARS limit exceeded\n" );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var = &cvar_indexes[cvar_numIndexes];
|
|
|
|
|
cvar_numIndexes++;
|
|
|
|
|
var->name = copystring(var_name);
|
|
|
|
|
var->string = copystring(var_value);
|
2008-06-29 22:00:00 +02:00
|
|
|
|
if( var_desc ) var->description = copystring(var_desc);
|
|
|
|
|
|
2007-11-18 22:00:00 +01:00
|
|
|
|
var->modified = true;
|
|
|
|
|
var->modificationCount = 1;
|
2007-11-25 22:00:00 +01:00
|
|
|
|
var->value = com_atof(var->string);
|
|
|
|
|
var->integer = com_atoi(var->string);
|
2007-11-18 22:00:00 +01:00
|
|
|
|
var->reset_string = copystring( var_value );
|
|
|
|
|
|
|
|
|
|
// link the variable in
|
|
|
|
|
var->next = cvar_vars;
|
|
|
|
|
cvar_vars = var;
|
|
|
|
|
|
|
|
|
|
var->flags = flags;
|
|
|
|
|
hash = Cvar_GetHashValue(var_name);
|
|
|
|
|
var->hash = hashTable[hash];
|
|
|
|
|
hashTable[hash] = var;
|
|
|
|
|
|
|
|
|
|
return var;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_Set2
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
cvar_t *Cvar_Set2 (const char *var_name, const char *value, bool force)
|
|
|
|
|
{
|
|
|
|
|
cvar_t *var;
|
|
|
|
|
|
|
|
|
|
if( !Cvar_ValidateString( var_name, false ))
|
|
|
|
|
{
|
|
|
|
|
MsgDev(D_WARN, "invalid cvar name string: %s\n", var_name );
|
|
|
|
|
var_name = "unknown";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( value && !Cvar_ValidateString( value, true ))
|
|
|
|
|
{
|
|
|
|
|
MsgDev(D_WARN, "invalid cvar value string: %s\n", value );
|
|
|
|
|
value = "default";
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-05 22:00:00 +02:00
|
|
|
|
var = Cvar_FindVar( var_name );
|
2007-11-25 22:00:00 +01:00
|
|
|
|
if(!var)
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
if( !value ) return NULL;
|
|
|
|
|
|
|
|
|
|
// create it
|
2008-06-29 22:00:00 +02:00
|
|
|
|
if ( !force ) return Cvar_Get( var_name, value, CVAR_USER_CREATED, NULL );
|
|
|
|
|
else return Cvar_Get (var_name, value, 0, NULL );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!value ) value = var->reset_string;
|
2007-11-25 22:00:00 +01:00
|
|
|
|
if(!com_strcmp(value, var->string)) return var;
|
2007-11-18 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
// note what types of cvars have been modified (userinfo, archive, serverinfo, systeminfo)
|
|
|
|
|
cvar_modifiedFlags |= var->flags;
|
|
|
|
|
|
|
|
|
|
if (!force)
|
|
|
|
|
{
|
|
|
|
|
if (var->flags & CVAR_READ_ONLY)
|
|
|
|
|
{
|
|
|
|
|
MsgDev(D_INFO, "%s is read only.\n", var_name);
|
|
|
|
|
return var;
|
|
|
|
|
}
|
|
|
|
|
if (var->flags & CVAR_INIT)
|
|
|
|
|
{
|
|
|
|
|
MsgDev(D_INFO, "%s is write protected.\n", var_name);
|
|
|
|
|
return var;
|
|
|
|
|
}
|
2008-06-05 22:00:00 +02:00
|
|
|
|
if (var->flags & CVAR_SYSTEMINFO)
|
|
|
|
|
{
|
|
|
|
|
MsgDev(D_INFO, "%s is system variable.\n", var_name);
|
|
|
|
|
return var;
|
|
|
|
|
}
|
2009-10-02 22:00:00 +02:00
|
|
|
|
if( var->flags & (CVAR_LATCH|CVAR_LATCH_VIDEO|CVAR_LATCH_AUDIO))
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
2008-08-01 22:00:00 +02:00
|
|
|
|
if( var->latched_string )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
2009-07-12 22:00:00 +02:00
|
|
|
|
if(!com.strcmp( value, var->latched_string ))
|
2007-11-18 22:00:00 +01:00
|
|
|
|
return var;
|
2008-08-01 22:00:00 +02:00
|
|
|
|
Mem_Free( var->latched_string );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-07-12 22:00:00 +02:00
|
|
|
|
if (!com.strcmp( value, var->string ))
|
2007-11-18 22:00:00 +01:00
|
|
|
|
return var;
|
|
|
|
|
}
|
2009-07-12 22:00:00 +02:00
|
|
|
|
|
2009-10-02 22:00:00 +02:00
|
|
|
|
if( var->flags & CVAR_LATCH && Cvar_VariableInteger( "host_serverstate" ))
|
2009-07-12 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
MsgDev( D_INFO, "%s will be changed upon restarting.\n", var->name );
|
|
|
|
|
var->latched_string = copystring( value );
|
|
|
|
|
}
|
2009-10-02 22:00:00 +02:00
|
|
|
|
else if( var->flags & CVAR_LATCH_VIDEO )
|
|
|
|
|
{
|
|
|
|
|
MsgDev( D_INFO, "%s will be changed upon restarting video.\n", var->name );
|
|
|
|
|
var->latched_string = copystring( value );
|
|
|
|
|
}
|
|
|
|
|
else if( var->flags & CVAR_LATCH_AUDIO )
|
|
|
|
|
{
|
|
|
|
|
MsgDev( D_INFO, "%s will be changed upon restarting audio.\n", var->name );
|
|
|
|
|
var->latched_string = copystring( value );
|
|
|
|
|
}
|
2009-07-12 22:00:00 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
2009-10-02 22:00:00 +02:00
|
|
|
|
Mem_Free( var->string ); // free the old value string
|
|
|
|
|
var->string = copystring( value );
|
|
|
|
|
var->value = com.atof( var->string );
|
|
|
|
|
var->integer = com.atoi( var->string );
|
2009-07-12 22:00:00 +02:00
|
|
|
|
}
|
2009-10-02 22:00:00 +02:00
|
|
|
|
|
2007-11-18 22:00:00 +01:00
|
|
|
|
var->modified = true;
|
|
|
|
|
var->modificationCount++;
|
|
|
|
|
return var;
|
|
|
|
|
}
|
2008-12-17 22:00:00 +01:00
|
|
|
|
if((var->flags & CVAR_CHEAT) && !Cvar_VariableInteger( "sv_cheats" ))
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
2008-08-01 22:00:00 +02:00
|
|
|
|
MsgDev( D_INFO, "%s is cheat protected.\n", var_name );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
return var;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2008-08-01 22:00:00 +02:00
|
|
|
|
if( var->latched_string )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
2009-07-12 22:00:00 +02:00
|
|
|
|
Mem_Free( var->latched_string );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
var->latched_string = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-25 22:00:00 +01:00
|
|
|
|
// nothing to change
|
2009-07-12 22:00:00 +02:00
|
|
|
|
if(!com.strcmp( value, var->string )) return var;
|
2007-11-18 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
var->modified = true;
|
|
|
|
|
var->modificationCount++;
|
|
|
|
|
|
2007-11-25 22:00:00 +01:00
|
|
|
|
// free the old value string
|
2009-07-12 22:00:00 +02:00
|
|
|
|
Mem_Free( var->string );
|
|
|
|
|
var->string = copystring( value );
|
|
|
|
|
var->value = com.atof( var->string );
|
|
|
|
|
var->integer = com.atoi( var->string );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
return var;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_Set
|
|
|
|
|
============
|
|
|
|
|
*/
|
2007-11-25 22:00:00 +01:00
|
|
|
|
void Cvar_Set( const char *var_name, const char *value )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
Cvar_Set2 (var_name, value, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_SetLatched
|
|
|
|
|
============
|
|
|
|
|
*/
|
2007-11-25 22:00:00 +01:00
|
|
|
|
void Cvar_SetLatched( const char *var_name, const char *value )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
2008-08-01 22:00:00 +02:00
|
|
|
|
Cvar_Set2( var_name, value, false );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_FullSet
|
|
|
|
|
============
|
|
|
|
|
*/
|
2007-11-25 22:00:00 +01:00
|
|
|
|
void Cvar_FullSet( char *var_name, char *value, int flags )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
cvar_t *var;
|
|
|
|
|
|
|
|
|
|
var = Cvar_FindVar (var_name);
|
2008-06-05 22:00:00 +02:00
|
|
|
|
if(!var)
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
// create it
|
2008-06-05 22:00:00 +02:00
|
|
|
|
Cvar_Get( var_name, value, flags, "" );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var->modified = true;
|
|
|
|
|
|
2008-08-01 22:00:00 +02:00
|
|
|
|
if( var->flags & CVAR_USERINFO )
|
2007-11-25 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
// transmit at next oportunity
|
2007-11-30 22:00:00 +01:00
|
|
|
|
com.userinfo_modified = true;
|
2007-11-25 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Mem_Free( var->string ); // free the old value string
|
2007-11-18 22:00:00 +01:00
|
|
|
|
var->string = copystring(value);
|
2007-11-25 22:00:00 +01:00
|
|
|
|
var->value = com_atof(var->string);
|
|
|
|
|
var->integer = com_atoi(var->string);
|
2007-11-18 22:00:00 +01:00
|
|
|
|
var->flags = flags;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_SetValue
|
|
|
|
|
============
|
|
|
|
|
*/
|
2007-11-25 22:00:00 +01:00
|
|
|
|
void Cvar_SetValue( const char *var_name, float value )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
char val[32];
|
|
|
|
|
|
2009-09-10 22:00:00 +02:00
|
|
|
|
if( value == (int)value )
|
|
|
|
|
com.sprintf( val, "%i", (int)value );
|
|
|
|
|
else com.sprintf( val, "%f", value );
|
|
|
|
|
Cvar_Set( var_name, val );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_Reset
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
void Cvar_Reset( const char *var_name )
|
|
|
|
|
{
|
|
|
|
|
Cvar_Set2( var_name, NULL, false );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_SetCheatState
|
|
|
|
|
|
|
|
|
|
Any testing variables will be reset to the safe values
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
void Cvar_SetCheatState( void )
|
|
|
|
|
{
|
|
|
|
|
cvar_t *var;
|
|
|
|
|
|
|
|
|
|
// set all default vars to the safe value
|
2009-07-12 22:00:00 +02:00
|
|
|
|
for( var = cvar_vars; var; var = var->next )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
if( var->flags & CVAR_CHEAT )
|
|
|
|
|
{
|
|
|
|
|
// the CVAR_LATCHED|CVAR_CHEAT vars might escape the reset here
|
|
|
|
|
// because of a different var->latched_string
|
2009-07-12 22:00:00 +02:00
|
|
|
|
if( var->latched_string )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
2009-07-12 22:00:00 +02:00
|
|
|
|
Mem_Free( var->latched_string );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
var->latched_string = NULL;
|
|
|
|
|
}
|
2009-07-12 22:00:00 +02:00
|
|
|
|
if( com.strcmp( var->reset_string, var->string ))
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
Cvar_Set( var->name, var->reset_string );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_Command
|
|
|
|
|
|
|
|
|
|
Handles variable inspection and changing from the console
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
bool Cvar_Command( void )
|
|
|
|
|
{
|
|
|
|
|
cvar_t *v;
|
|
|
|
|
|
|
|
|
|
// check variables
|
2009-07-12 22:00:00 +02:00
|
|
|
|
v = Cvar_FindVar( Cmd_Argv( 0 ));
|
|
|
|
|
if( !v ) return false;
|
2007-11-18 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
// perform a variable print or set
|
2007-11-25 22:00:00 +01:00
|
|
|
|
if( Cmd_Argc() == 1 )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
2009-07-12 22:00:00 +02:00
|
|
|
|
if( v->flags & CVAR_INIT ) Msg( "%s: %s\n", v->name, v->string );
|
|
|
|
|
else Msg( "%s: %s ( ^3%s^7 )\n", v->name, v->string, v->reset_string );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
if ( v->latched_string ) Msg( "%s: %s\n", v->name, v->latched_string );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// set the value if forcing isn't required
|
2009-07-12 22:00:00 +02:00
|
|
|
|
Cvar_Set2( v->name, Cmd_Argv(1), false );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_Toggle_f
|
|
|
|
|
|
|
|
|
|
Toggles a cvar for easy single key binding
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
void Cvar_Toggle_f( void )
|
|
|
|
|
{
|
|
|
|
|
int v;
|
|
|
|
|
|
|
|
|
|
if( Cmd_Argc() != 2 )
|
|
|
|
|
{
|
2009-07-12 22:00:00 +02:00
|
|
|
|
Msg( "Usage: toggle <variable>\n" );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-25 22:00:00 +01:00
|
|
|
|
v = Cvar_VariableValue(Cmd_Argv( 1 ));
|
2007-11-18 22:00:00 +01:00
|
|
|
|
v = !v;
|
|
|
|
|
|
2009-07-12 22:00:00 +02:00
|
|
|
|
Cvar_Set2( Cmd_Argv( 1 ), va( "%i", v ), false );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_Set_f
|
|
|
|
|
|
|
|
|
|
Allows setting and defining of arbitrary cvars from console, even if they
|
|
|
|
|
weren't declared in C code.
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
void Cvar_Set_f( void )
|
|
|
|
|
{
|
|
|
|
|
int i, c, l = 0, len;
|
|
|
|
|
char combined[MAX_STRING_TOKENS];
|
|
|
|
|
|
|
|
|
|
c = Cmd_Argc();
|
2009-07-12 22:00:00 +02:00
|
|
|
|
if( c < 3 )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
2009-07-12 22:00:00 +02:00
|
|
|
|
Msg( "Usage: set <variable> <value>\n" );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
combined[0] = 0;
|
|
|
|
|
|
2009-07-12 22:00:00 +02:00
|
|
|
|
for( i = 2; i < c; i++ )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
2009-07-12 22:00:00 +02:00
|
|
|
|
len = com.strlen( Cmd_Argv(i) + 1 );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
if ( l + len >= MAX_STRING_TOKENS - 2 )
|
|
|
|
|
break;
|
2008-10-29 22:00:00 +01:00
|
|
|
|
com.strcat( combined, Cmd_Argv(i));
|
|
|
|
|
if ( i != c-1 ) com.strcat( combined, " " );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
l += len;
|
|
|
|
|
}
|
2009-07-12 22:00:00 +02:00
|
|
|
|
Cvar_Set2( Cmd_Argv( 1 ), combined, false );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_SetU_f
|
|
|
|
|
|
|
|
|
|
As Cvar_Set, but also flags it as userinfo
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
void Cvar_SetU_f( void )
|
|
|
|
|
{
|
|
|
|
|
cvar_t *v;
|
|
|
|
|
|
2009-07-12 22:00:00 +02:00
|
|
|
|
if( Cmd_Argc() != 3 )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
2009-07-12 22:00:00 +02:00
|
|
|
|
Msg( "Usage: setu <variable> <value>\n" );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Cvar_Set_f();
|
2009-07-12 22:00:00 +02:00
|
|
|
|
v = Cvar_FindVar( Cmd_Argv( 1 ));
|
2007-11-18 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
if( !v ) return;
|
|
|
|
|
v->flags |= CVAR_USERINFO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_SetS_f
|
|
|
|
|
|
|
|
|
|
As Cvar_Set, but also flags it as userinfo
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
void Cvar_SetS_f( void )
|
|
|
|
|
{
|
|
|
|
|
cvar_t *v;
|
|
|
|
|
|
2009-07-12 22:00:00 +02:00
|
|
|
|
if( Cmd_Argc() != 3 )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
2009-07-12 22:00:00 +02:00
|
|
|
|
Msg( "Usage: sets <variable> <value>\n" );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Cvar_Set_f();
|
2009-07-12 22:00:00 +02:00
|
|
|
|
v = Cvar_FindVar( Cmd_Argv( 1 ));
|
2007-11-18 22:00:00 +01:00
|
|
|
|
|
2009-07-12 22:00:00 +02:00
|
|
|
|
if( !v ) return;
|
2007-11-18 22:00:00 +01:00
|
|
|
|
v->flags |= CVAR_SERVERINFO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_SetA_f
|
|
|
|
|
|
|
|
|
|
As Cvar_Set, but also flags it as archived
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
void Cvar_SetA_f( void )
|
|
|
|
|
{
|
|
|
|
|
cvar_t *v;
|
|
|
|
|
|
2009-07-12 22:00:00 +02:00
|
|
|
|
if( Cmd_Argc() != 3 )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
2009-07-12 22:00:00 +02:00
|
|
|
|
Msg( "Usage: seta <variable> <value>\n" );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2007-11-25 22:00:00 +01:00
|
|
|
|
|
2007-11-18 22:00:00 +01:00
|
|
|
|
Cvar_Set_f();
|
2009-07-12 22:00:00 +02:00
|
|
|
|
v = Cvar_FindVar( Cmd_Argv( 1 ));
|
|
|
|
|
|
|
|
|
|
if( !v ) return;
|
2007-11-18 22:00:00 +01:00
|
|
|
|
v->flags |= CVAR_ARCHIVE;
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-05 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_SetC_f
|
|
|
|
|
|
|
|
|
|
As Cvar_Set, but also flags it as systeminfo
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
void Cvar_SetC_f( void )
|
|
|
|
|
{
|
|
|
|
|
if( Cmd_Argc() != 3 )
|
|
|
|
|
{
|
2009-07-12 22:00:00 +02:00
|
|
|
|
Msg( "Usage: setc <variable> <value>\n" );
|
2008-06-05 22:00:00 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-12 22:00:00 +02:00
|
|
|
|
Cvar_FullSet( Cmd_Argv( 1 ), Cmd_Argv( 2 ), CVAR_SYSTEMINFO );
|
2008-06-05 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2007-11-18 22:00:00 +01:00
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_Reset_f
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
void Cvar_Reset_f( void )
|
|
|
|
|
{
|
2009-07-12 22:00:00 +02:00
|
|
|
|
if( Cmd_Argc() != 2 )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
2009-07-12 22:00:00 +02:00
|
|
|
|
Msg( "Usage: reset <variable>\n" );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Cvar_Reset( Cmd_Argv( 1 ));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_List_f
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
void Cvar_List_f( void )
|
|
|
|
|
{
|
|
|
|
|
cvar_t *var;
|
|
|
|
|
char *match;
|
2009-08-05 22:00:00 +02:00
|
|
|
|
int i = 0, j = 0;
|
2007-11-18 22:00:00 +01:00
|
|
|
|
|
2008-11-18 22:00:00 +01:00
|
|
|
|
if( Cmd_Argc() > 1 ) match = Cmd_Argv(1);
|
2007-11-18 22:00:00 +01:00
|
|
|
|
else match = NULL;
|
|
|
|
|
|
2008-11-18 22:00:00 +01:00
|
|
|
|
for( var = cvar_vars; var; var = var->next, i++ )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
2009-08-05 22:00:00 +02:00
|
|
|
|
if( match && !com_stricmpext( match, var->name ))
|
2007-11-18 22:00:00 +01:00
|
|
|
|
continue;
|
|
|
|
|
|
2009-10-02 22:00:00 +02:00
|
|
|
|
if( var->flags & CVAR_SERVERINFO ) Msg( "SV " );
|
|
|
|
|
else Msg( " " );
|
|
|
|
|
|
|
|
|
|
if( var->flags & CVAR_USERINFO ) Msg( "USER " );
|
2009-07-12 22:00:00 +02:00
|
|
|
|
else Msg( " " );
|
|
|
|
|
|
2009-10-02 22:00:00 +02:00
|
|
|
|
if( var->flags & CVAR_READ_ONLY ) Msg( "READ " );
|
2009-07-12 22:00:00 +02:00
|
|
|
|
else Msg( " " );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
|
2009-10-02 22:00:00 +02:00
|
|
|
|
if( var->flags & CVAR_INIT ) Msg( "INIT " );
|
2009-07-12 22:00:00 +02:00
|
|
|
|
else Msg( " " );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
|
2009-10-02 22:00:00 +02:00
|
|
|
|
if( var->flags & CVAR_ARCHIVE ) Msg( "ARCH " );
|
2009-07-12 22:00:00 +02:00
|
|
|
|
else Msg( " " );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
|
2009-10-02 22:00:00 +02:00
|
|
|
|
if( var->flags & CVAR_LATCH ) Msg( "LATCH" );
|
2009-07-12 22:00:00 +02:00
|
|
|
|
else Msg( " " );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
|
2009-10-02 22:00:00 +02:00
|
|
|
|
if( var->flags & CVAR_LATCH_VIDEO ) Msg( "VIDEO" );
|
2009-07-12 22:00:00 +02:00
|
|
|
|
else Msg( " " );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
|
2009-10-02 22:00:00 +02:00
|
|
|
|
if( var->flags & CVAR_LATCH_AUDIO ) Msg( "AUDIO" );
|
2009-07-12 22:00:00 +02:00
|
|
|
|
else Msg( " " );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
|
2009-10-02 22:00:00 +02:00
|
|
|
|
if( var->flags & CVAR_CHEAT ) Msg( "CHEAT" );
|
2009-07-12 22:00:00 +02:00
|
|
|
|
else Msg( " " );
|
|
|
|
|
Msg(" %s \"%s\"\n", var->name, var->string );
|
2009-08-05 22:00:00 +02:00
|
|
|
|
j++;
|
2007-11-18 22:00:00 +01:00
|
|
|
|
}
|
2009-07-12 22:00:00 +02:00
|
|
|
|
|
2009-08-05 22:00:00 +02:00
|
|
|
|
Msg( "\n%i cvars\n", j );
|
|
|
|
|
Msg( "%i total cvars\n", i );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_Restart_f
|
|
|
|
|
|
|
|
|
|
Resets all cvars to their hardcoded values
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
void Cvar_Restart_f( void )
|
|
|
|
|
{
|
|
|
|
|
cvar_t *var;
|
|
|
|
|
cvar_t **prev;
|
|
|
|
|
|
|
|
|
|
prev = &cvar_vars;
|
|
|
|
|
|
2009-09-24 22:00:00 +02:00
|
|
|
|
while( 1 )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
var = *prev;
|
2007-11-25 22:00:00 +01:00
|
|
|
|
if( !var ) break;
|
2007-11-18 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
// don't mess with rom values, or some inter-module
|
|
|
|
|
// communication will get broken (com_cl_running, etc)
|
2009-07-12 22:00:00 +02:00
|
|
|
|
if( var->flags & ( CVAR_READ_ONLY|CVAR_INIT|CVAR_SYSTEMINFO ))
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
prev = &var->next;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// throw out any variables the user created
|
2009-07-12 22:00:00 +02:00
|
|
|
|
if( var->flags & CVAR_USER_CREATED )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
*prev = var->next;
|
2007-11-25 22:00:00 +01:00
|
|
|
|
if( var->name ) Mem_Free( var->name );
|
|
|
|
|
if( var->string ) Mem_Free( var->string );
|
|
|
|
|
if( var->latched_string ) Mem_Free( var->latched_string );
|
|
|
|
|
if( var->reset_string ) Mem_Free( var->reset_string );
|
|
|
|
|
if( var->description ) Mem_Free( var->description );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
// clear the var completely, since we
|
|
|
|
|
// can't remove the index from the list
|
2008-10-27 22:00:00 +01:00
|
|
|
|
Mem_Set( var, 0, sizeof( var ));
|
2007-11-18 22:00:00 +01:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
Cvar_Set( var->name, var->reset_string );
|
|
|
|
|
prev = &var->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-01 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_Latched_f
|
|
|
|
|
|
|
|
|
|
Now all latched strings is valid
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
void Cvar_Latched_f( void )
|
|
|
|
|
{
|
|
|
|
|
cvar_t *var;
|
|
|
|
|
cvar_t **prev;
|
|
|
|
|
|
|
|
|
|
prev = &cvar_vars;
|
|
|
|
|
|
2009-07-12 22:00:00 +02:00
|
|
|
|
while( 1 )
|
|
|
|
|
{
|
|
|
|
|
var = *prev;
|
|
|
|
|
if( !var ) break;
|
|
|
|
|
|
|
|
|
|
if( var->flags & CVAR_LATCH && var->latched_string )
|
|
|
|
|
{
|
|
|
|
|
Cvar_FullSet( var->name, var->latched_string, var->flags );
|
|
|
|
|
Mem_Free( var->latched_string );
|
|
|
|
|
var->latched_string = NULL;
|
|
|
|
|
}
|
|
|
|
|
prev = &var->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_Latched_f
|
|
|
|
|
|
|
|
|
|
Now all latched video strings is valid
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
void Cvar_LatchedVideo_f( void )
|
|
|
|
|
{
|
|
|
|
|
cvar_t *var;
|
|
|
|
|
cvar_t **prev;
|
|
|
|
|
|
|
|
|
|
prev = &cvar_vars;
|
|
|
|
|
|
2008-08-01 22:00:00 +02:00
|
|
|
|
while ( 1 )
|
|
|
|
|
{
|
|
|
|
|
var = *prev;
|
|
|
|
|
if( !var ) break;
|
|
|
|
|
|
2009-07-12 22:00:00 +02:00
|
|
|
|
if( var->flags & CVAR_LATCH_VIDEO && var->latched_string )
|
2008-08-01 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
Cvar_FullSet( var->name, var->latched_string, var->flags );
|
|
|
|
|
Mem_Free( var->latched_string );
|
|
|
|
|
var->latched_string = NULL;
|
|
|
|
|
}
|
|
|
|
|
prev = &var->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-02 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_Latched_f
|
|
|
|
|
|
|
|
|
|
Now all latched audio strings is valid
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
void Cvar_LatchedAudio_f( void )
|
|
|
|
|
{
|
|
|
|
|
cvar_t *var;
|
|
|
|
|
cvar_t **prev;
|
|
|
|
|
|
|
|
|
|
prev = &cvar_vars;
|
|
|
|
|
|
|
|
|
|
while ( 1 )
|
|
|
|
|
{
|
|
|
|
|
var = *prev;
|
|
|
|
|
if( !var ) break;
|
|
|
|
|
|
|
|
|
|
if( var->flags & CVAR_LATCH_AUDIO && var->latched_string )
|
|
|
|
|
{
|
|
|
|
|
Cvar_FullSet( var->name, var->latched_string, var->flags );
|
|
|
|
|
Mem_Free( var->latched_string );
|
|
|
|
|
var->latched_string = NULL;
|
|
|
|
|
}
|
|
|
|
|
prev = &var->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-18 22:00:00 +01:00
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
Cvar_Init
|
|
|
|
|
|
|
|
|
|
Reads in all archived cvars
|
|
|
|
|
============
|
|
|
|
|
*/
|
2008-08-04 22:00:00 +02:00
|
|
|
|
void Cvar_Init( void )
|
2007-11-18 22:00:00 +01:00
|
|
|
|
{
|
2008-08-04 22:00:00 +02:00
|
|
|
|
cvar_vars = NULL;
|
|
|
|
|
cvar_numIndexes = cvar_modifiedFlags = 0;
|
2009-07-12 22:00:00 +02:00
|
|
|
|
ZeroMemory( cvar_indexes, sizeof( cvar_t ) * MAX_CVARS );
|
|
|
|
|
ZeroMemory( hashTable, sizeof(*hashTable ) * FILE_HASH_SIZE );
|
2008-08-04 22:00:00 +02:00
|
|
|
|
|
2007-11-18 22:00:00 +01:00
|
|
|
|
Cmd_AddCommand ("toggle", Cvar_Toggle_f, "toggles a console variable's values (use for more info)" );
|
|
|
|
|
Cmd_AddCommand ("set", Cvar_Set_f, "create or change the value of a console variable" );
|
|
|
|
|
Cmd_AddCommand ("sets", Cvar_SetS_f, "create or change the value of a serverinfo variable");
|
|
|
|
|
Cmd_AddCommand ("setu", Cvar_SetU_f, "create or change the value of a userinfo variable");
|
2008-06-05 22:00:00 +02:00
|
|
|
|
Cmd_AddCommand ("setc", Cvar_SetC_f, "create or change the value of a systeminfo variable");
|
2007-11-18 22:00:00 +01:00
|
|
|
|
Cmd_AddCommand ("seta", Cvar_SetA_f, "create or change the value of a console variable that will be saved to vars.rc");
|
|
|
|
|
Cmd_AddCommand ("reset", Cvar_Reset_f, "reset any type variable to initial value" );
|
2008-08-01 22:00:00 +02:00
|
|
|
|
Cmd_AddCommand ("latch", Cvar_Latched_f, "apply latched values" );
|
2009-10-02 22:00:00 +02:00
|
|
|
|
Cmd_AddCommand ("vidlatch", Cvar_LatchedVideo_f, "apply latched values for video subsystem" );
|
|
|
|
|
Cmd_AddCommand ("sndlatch", Cvar_LatchedAudio_f, "apply latched values for audio subsytem" );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
Cmd_AddCommand ("cvarlist", Cvar_List_f, "display all console variables beginning with the specified prefix" );
|
|
|
|
|
Cmd_AddCommand ("unsetall", Cvar_Restart_f, "reset all console variables to their default values" );
|
|
|
|
|
|
|
|
|
|
}
|