}
Con_DPrintf("execing %s\n",Cmd_Argv(1));
+ // if executing default.cfg for the first time, lock the cvar defaults
+ // it may seem backwards to insert this text BEFORE the default.cfg
+ // but Cbuf_InsertText inserts before, so this actually ends up after it.
+ if (!strcmp(Cmd_Argv(1), "default.cfg"))
+ Cbuf_InsertText("\ncvar_lockdefaults\n");
+
Cbuf_InsertText (f);
Mem_Free(f);
}
{ // Correct Arguments Specified
// Acquire Potential CVar
cvar_t* cvCVar = Cvar_FindVar( Cmd_Argv(1) );
-
+
if(cvCVar != NULL)
{ // Valid CVar
if(nNumArgs == 2)
Cmd_AddCommand ("cmdlist", Cmd_List_f, "lists all console commands beginning with the specified prefix");
Cmd_AddCommand ("cvarlist", Cvar_List_f, "lists all console variables beginning with the specified prefix");
+ Cmd_AddCommand ("cvar_lockdefaults", Cvar_LockDefaults_f, "stores the current values of all cvars into their default values, only used once during startup after parsing default.cfg");
+ Cmd_AddCommand ("cvar_resettodefaults_all", Cvar_ResetToDefaults_All_f, "sets all cvars to their locked default values");
+ Cmd_AddCommand ("cvar_resettodefaults_nosaveonly", Cvar_ResetToDefaults_NoSaveOnly_f, "sets all non-saved cvars to their locked default values (variables that will not be saved to config.cfg)");
+ Cmd_AddCommand ("cvar_resettodefaults_saveonly", Cvar_ResetToDefaults_SaveOnly_f, "sets all saved cvars to their locked default values (variables that will be saved to config.cfg)");
+
// DRESK - 5/14/06
// Support Doom3-style Toggle Command
Cmd_AddCommand( "toggle", Cmd_Toggle_f, "toggles a console variable's values (use for more info)");
{
cvar->flags |= flags;
Cvar_SetQuick_Internal (cvar, value);
- // also set the default value (but only once)
- if (~cvar->flags & CVAR_DEFAULTSET)
- {
- cvar->flags |= CVAR_DEFAULTSET;
-
- Z_Free(cvar->defstring);
- cvar->defstring = (char *)Z_Malloc(strlen(value) + 1);
- strcpy(cvar->defstring, value);
- }
return cvar;
}
// allocate a new cvar, cvar name, and cvar string
// FIXME: these never get Z_Free'd
cvar = (cvar_t *)Z_Malloc(sizeof(cvar_t));
- cvar->flags = flags | CVAR_ALLOCATED | CVAR_DEFAULTSET;
+ cvar->flags = flags | CVAR_ALLOCATED;
cvar->name = (char *)Z_Malloc(strlen(name)+1);
strcpy(cvar->name, name);
cvar->string = (char *)Z_Malloc(strlen(value)+1);
}
+void Cvar_LockDefaults_f (void)
+{
+ cvar_t *var;
+ // lock in the default values of all cvars
+ for (var = cvar_vars ; var ; var = var->next)
+ {
+ if (!(var->flags & CVAR_DEFAULTSET))
+ {
+ //Con_Printf("locking cvar %s (%s -> %s)\n", var->name, var->string, var->defstring);
+ var->flags |= CVAR_DEFAULTSET;
+ Z_Free(var->defstring);
+ var->defstring = (char *)Z_Malloc(strlen(var->string) + 1);
+ strcpy(var->defstring, var->string);
+ }
+ }
+}
+
+
+void Cvar_ResetToDefaults_All_f (void)
+{
+ cvar_t *var;
+ // restore the default values of all cvars
+ for (var = cvar_vars ; var ; var = var->next)
+ Cvar_SetQuick(var, var->defstring);
+}
+
+
+void Cvar_ResetToDefaults_NoSaveOnly_f (void)
+{
+ cvar_t *var;
+ // restore the default values of all cvars
+ for (var = cvar_vars ; var ; var = var->next)
+ if (!(var->flags & CVAR_SAVE))
+ Cvar_SetQuick(var, var->defstring);
+}
+
+
+void Cvar_ResetToDefaults_SaveOnly_f (void)
+{
+ cvar_t *var;
+ // restore the default values of all cvars
+ for (var = cvar_vars ; var ; var = var->next)
+ if (var->flags & CVAR_SAVE)
+ Cvar_SetQuick(var, var->defstring);
+}
+
+
/*
============
Cvar_WriteVariables
// command. Returns true if the command was a variable reference that
// was handled. (print or change)
+void Cvar_LockDefaults_f (void);
+void Cvar_ResetToDefaults_All_f (void);
+void Cvar_ResetToDefaults_NoSaveOnly_f (void);
+void Cvar_ResetToDefaults_SaveOnly_f (void);
+
void Cvar_WriteVariables (qfile_t *f);
// Writes lines containing "set variable value" for all variables
// with the archive flag set to true.
if (cmd_source == src_command)
{
Cvar_Set ("_cl_playerskin", newPath);
- CL_SetInfo("playermodel", newPath, true, false, false, false);
+ CL_SetInfo("playerskin", newPath, true, false, false, false);
return;
}
PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_playerskin)->string = PRVM_SetEngineString(host_client->playerskin);
if (strcmp(host_client->old_skin, host_client->playerskin))
{
- if (host_client->spawned)
- SV_BroadcastPrintf("%s changed skin to %s\n", host_client->name, host_client->playerskin);
+ //if (host_client->spawned)
+ // SV_BroadcastPrintf("%s changed skin to %s\n", host_client->name, host_client->playerskin);
strcpy(host_client->old_skin, host_client->playerskin);
/*// send notification to all clients
MSG_WriteByte (&sv.reliable_datagram, svc_updatepskin);
{
case 'Y':
case 'y':
- Cbuf_AddText ("exec default.cfg\n");
+ Cbuf_AddText ("cvar_resettodefaults_all;exec default.cfg\n");
// no break here since we also exit the menu
case K_ESCAPE: