+/// For "quiet" mode pass NULL as the callername.
+/// Returns true if the cvar was deleted.
+static qbool Cvar_Delete(cvar_state_t *cvars, const char *name, const char *callername)
+{
+ cvar_t *cvar, *prev;
+ cvar_hash_t **hashlinkptr, *oldhashlink;
+ const char *progname;
+
+ hashlinkptr = Cvar_FindVarLink(cvars, name, &prev, ~0);
+ if(!hashlinkptr)
+ {
+ if (callername)
+ Con_Printf("%s: cvar \"%s\" is not defined.\n", callername, name);
+ return false;
+ }
+ cvar = (*hashlinkptr)->cvar;
+
+ if(!(cvar->flags & CF_ALLOCATED))
+ {
+ if (callername)
+ Con_Printf(CON_WARN "%s: engine cvar \"%s\" cannot be deleted!\n", callername, cvar->name);
+ return false;
+ }
+ if ((progname = Cvar_IsAutoCvar(cvar)))
+ {
+ if (callername)
+ Con_Printf(CON_WARN "%s: unable to delete cvar \"%s\", it is an autocvar used by running %s progs!\n", callername, cvar->name, progname);
+ return false;
+ }
+
+ if(cvar == cvars->vars)
+ cvars->vars = cvar->next;
+ else
+ prev->next = cvar->next;
+
+ if(cvar->description != cvar_dummy_description)
+ Z_Free((char *)cvar->description);
+ Z_Free((char *)cvar->name);
+ Z_Free((char *)cvar->string);
+ Z_Free((char *)cvar->defstring);
+ Z_Free(cvar);
+
+ oldhashlink = *hashlinkptr;
+ *hashlinkptr = (*hashlinkptr)->next;
+ Z_Free(oldhashlink);
+
+ return true;
+}
+