return var;
}
+cvar_t *Cvar_FindVarLink (const char *var_name, cvar_t **parent, cvar_t ***link, cvar_t **prev_alpha)
+{
+ int hashindex;
+ cvar_t *var;
+
+ // use hash lookup to minimize search time
+ hashindex = CRC_Block((const unsigned char *)var_name, strlen(var_name));
+ if(parent) *parent = NULL;
+ if(prev_alpha) *prev_alpha = NULL;
+ if(link) *link = &cvar_hashtable[hashindex];
+ for (var = cvar_hashtable[hashindex];var;var = var->nextonhashchain)
+ {
+ if (!strcmp (var_name, var->name))
+ {
+ if(!prev_alpha || var == cvar_vars)
+ return var;
+
+ *prev_alpha = cvar_vars;
+ // if prev_alpha happens to become NULL then there has been some inconsistency elsewhere
+ // already - should I still insert '*prev_alpha &&' in the loop?
+ while((*prev_alpha)->next != var)
+ *prev_alpha = (*prev_alpha)->next;
+ return var;
+ }
+ if(parent) *parent = var;
+ }
+
+ return NULL;
+}
+
/*
============
Cvar_VariableValue
return;
}
- if (developer.integer >= 100)
- Con_Printf("Cvar_SetQuick({\"%s\", \"%s\", %i, \"%s\"}, \"%s\");\n", var->name, var->string, var->flags, var->defstring, value);
+ if (developer_extra.integer)
+ Con_DPrintf("Cvar_SetQuick({\"%s\", \"%s\", %i, \"%s\"}, \"%s\");\n", var->name, var->string, var->flags, var->defstring, value);
Cvar_SetQuick_Internal(var, value);
}
char *oldstr;
size_t alloclen;
- if (developer.integer >= 100)
- Con_Printf("Cvar_RegisterVariable({\"%s\", \"%s\", %i});\n", variable->name, variable->string, variable->flags);
+ if (developer_extra.integer)
+ Con_DPrintf("Cvar_RegisterVariable({\"%s\", \"%s\", %i});\n", variable->name, variable->string, variable->flags);
// first check to see if it has already been defined
cvar = Cvar_FindVar (variable->name);
{
if (cvar->flags & CVAR_ALLOCATED)
{
- if (developer.integer >= 100)
- Con_Printf("... replacing existing allocated cvar {\"%s\", \"%s\", %i}\n", cvar->name, cvar->string, cvar->flags);
+ if (developer_extra.integer)
+ Con_DPrintf("... replacing existing allocated cvar {\"%s\", \"%s\", %i}\n", cvar->name, cvar->string, cvar->flags);
// fixed variables replace allocated ones
// (because the engine directly accesses fixed variables)
// NOTE: this isn't actually used currently
Z_Free(cvar);
}
else
- Con_Printf("Can't register variable %s, already defined\n", variable->name);
+ Con_DPrintf("Can't register variable %s, already defined\n", variable->name);
return;
}
cvar_t *current, *next, *cvar;
size_t alloclen;
- if (developer.integer >= 100)
- Con_Printf("Cvar_Get(\"%s\", \"%s\", %i);\n", name, value, flags);
+ if (developer_extra.integer)
+ Con_DPrintf("Cvar_Get(\"%s\", \"%s\", %i);\n", name, value, flags);
// first check to see if it has already been defined
cvar = Cvar_FindVar (name);
return true;
}
- if (developer.integer >= 100)
+ if (developer_extra.integer)
Con_DPrint("Cvar_Command: ");
if (v->flags & CVAR_READONLY)
return true;
}
Cvar_Set (v->name, Cmd_Argv(1));
- if (developer.integer >= 100)
+ if (developer_extra.integer)
Con_DPrint("\n");
return true;
}
return;
}
- if (developer.integer >= 100)
+ if (developer_extra.integer)
Con_DPrint("Set: ");
// all looks ok, create/modify the cvar
return;
}
- if (developer.integer >= 100)
+ if (developer_extra.integer)
Con_DPrint("SetA: ");
// all looks ok, create/modify the cvar
Cvar_Get(Cmd_Argv(1), Cmd_Argv(2), CVAR_SAVE, Cmd_Argc() > 3 ? Cmd_Argv(3) : NULL);
}
+void Cvar_Del_f (void)
+{
+ int i;
+ cvar_t *cvar, *parent, **link, *prev;
+
+ if(Cmd_Argc() < 2)
+ {
+ Con_Printf("Del: wrong number of parameters, useage: unset <variablename1> [<variablename2> ...]\n");
+ return;
+ }
+ for(i = 1; i < Cmd_Argc(); ++i)
+ {
+ cvar = Cvar_FindVarLink(Cmd_Argv(i), &parent, &link, &prev);
+ if(!cvar)
+ {
+ Con_Printf("Del: %s is not defined\n", Cmd_Argv(i));
+ continue;
+ }
+ if(cvar->flags & CVAR_READONLY)
+ {
+ Con_Printf("Del: %s is read-only\n", cvar->name);
+ continue;
+ }
+ if(!(cvar->flags & CVAR_ALLOCATED))
+ {
+ Con_Printf("Del: %s is static and cannot be deleted\n", cvar->name);
+ continue;
+ }
+ if(cvar == cvar_vars)
+ {
+ cvar_vars = cvar->next;
+ }
+ else
+ {
+ // in this case, prev must be set, otherwise there has been some inconsistensy
+ // elsewhere already... should I still check for prev != NULL?
+ prev->next = cvar->next;
+ }
+
+ if(parent)
+ parent->nextonhashchain = cvar->nextonhashchain;
+ else if(link)
+ *link = cvar->nextonhashchain;
+
+ if(cvar->description != cvar_dummy_description)
+ Z_Free(cvar->description);
+
+ Z_Free(cvar->name);
+ Z_Free(cvar->string);
+ Z_Free(cvar->defstring);
+ Z_Free(cvar);
+ }
+}
+
#ifdef FILLALLCVARSWITHRUBBISH
void Cvar_FillAll_f()
{