2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 // cvar.c -- dynamic variable tracking
24 const char *cvar_dummy_description = "custom cvar";
26 cvar_t *cvar_vars = NULL;
27 cvar_t *cvar_hashtable[CVAR_HASHSIZE];
28 const char *cvar_null_string = "";
35 cvar_t *Cvar_FindVar (const char *var_name)
40 // use hash lookup to minimize search time
41 hashindex = CRC_Block((const unsigned char *)var_name, strlen(var_name)) % CVAR_HASHSIZE;
42 for (var = cvar_hashtable[hashindex];var;var = var->nextonhashchain)
43 if (!strcmp (var_name, var->name))
49 cvar_t *Cvar_FindVarAfter (const char *prev_var_name, int neededflags)
55 var = Cvar_FindVar (prev_var_name);
63 // search for the next cvar matching the needed flags
66 if ((var->flags & neededflags) || !neededflags)
73 cvar_t *Cvar_FindVarLink (const char *var_name, cvar_t **parent, cvar_t ***link, cvar_t **prev_alpha)
78 // use hash lookup to minimize search time
79 hashindex = CRC_Block((const unsigned char *)var_name, strlen(var_name));
80 if(parent) *parent = NULL;
81 if(prev_alpha) *prev_alpha = NULL;
82 if(link) *link = &cvar_hashtable[hashindex];
83 for (var = cvar_hashtable[hashindex];var;var = var->nextonhashchain)
85 if (!strcmp (var_name, var->name))
87 if(!prev_alpha || var == cvar_vars)
90 *prev_alpha = cvar_vars;
91 // if prev_alpha happens to become NULL then there has been some inconsistency elsewhere
92 // already - should I still insert '*prev_alpha &&' in the loop?
93 while((*prev_alpha)->next != var)
94 *prev_alpha = (*prev_alpha)->next;
97 if(parent) *parent = var;
108 float Cvar_VariableValue (const char *var_name)
112 var = Cvar_FindVar (var_name);
115 return atof (var->string);
124 const char *Cvar_VariableString (const char *var_name)
128 var = Cvar_FindVar (var_name);
130 return cvar_null_string;
136 Cvar_VariableDefString
139 const char *Cvar_VariableDefString (const char *var_name)
143 var = Cvar_FindVar (var_name);
145 return cvar_null_string;
146 return var->defstring;
151 Cvar_VariableDescription
154 const char *Cvar_VariableDescription (const char *var_name)
158 var = Cvar_FindVar (var_name);
160 return cvar_null_string;
161 return var->description;
167 Cvar_CompleteVariable
170 const char *Cvar_CompleteVariable (const char *partial)
175 len = strlen(partial);
181 for (cvar=cvar_vars ; cvar ; cvar=cvar->next)
182 if (!strncasecmp (partial,cvar->name, len))
190 CVar_CompleteCountPossible
192 New function for tab-completion system
194 Thanks to Fett erich@heintz.com
197 int Cvar_CompleteCountPossible (const char *partial)
204 len = strlen(partial);
209 // Loop through the cvars and count all possible matches
210 for (cvar = cvar_vars; cvar; cvar = cvar->next)
211 if (!strncasecmp(partial, cvar->name, len))
218 CVar_CompleteBuildList
220 New function for tab-completion system
222 Thanks to Fett erich@heintz.com
226 const char **Cvar_CompleteBuildList (const char *partial)
231 size_t sizeofbuf = (Cvar_CompleteCountPossible (partial) + 1) * sizeof (const char *);
234 len = strlen(partial);
235 buf = (const char **)Mem_Alloc(tempmempool, sizeofbuf + sizeof (const char *));
236 // Loop through the alias list and print all matches
237 for (cvar = cvar_vars; cvar; cvar = cvar->next)
238 if (!strncasecmp(partial, cvar->name, len))
239 buf[bpos++] = cvar->name;
245 // written by LordHavoc
246 void Cvar_CompleteCvarPrint (const char *partial)
249 size_t len = strlen(partial);
250 // Loop through the command list and print all matches
251 for (cvar = cvar_vars; cvar; cvar = cvar->next)
252 if (!strncasecmp(partial, cvar->name, len))
253 Con_Printf ("^3%s^7 is \"%s\" [\"%s\"] %s\n", cvar->name, cvar->string, cvar->defstring, cvar->description);
256 // we assume that prog is already set to the target progs
257 static void Cvar_UpdateAutoCvar(cvar_t *var)
261 Host_Error("Cvar_UpdateAutoCvar: no prog set");
262 i = PRVM_GetProgNr();
263 if(var->globaldefindex_progid[i] == prog->id)
265 // MUST BE SYNCED WITH prvm_edict.c PRVM_LoadProgs
269 switch(prog->globaldefs[var->globaldefindex[i]].type & ~DEF_SAVEGLOBAL)
272 PRVM_GLOBALFIELDFLOAT(prog->globaldefs[var->globaldefindex[i]].ofs) = var->value;
277 for (j = 0;j < 3;j++)
279 while (*s && ISWHITESPACE(*s))
284 while (!ISWHITESPACE(*s))
289 VectorCopy(v, PRVM_GLOBALFIELDVECTOR(prog->globaldefs[var->globaldefindex[i]].ofs));
292 PRVM_ChangeEngineString(var->globaldefindex_stringno[i], var->string);
293 PRVM_GLOBALFIELDSTRING(prog->globaldefs[var->globaldefindex[i]].ofs) = var->globaldefindex_stringno[i];
299 // called after loading a savegame
300 void Cvar_UpdateAllAutoCvars(void)
303 for (var = cvar_vars ; var ; var = var->next)
304 Cvar_UpdateAutoCvar(var);
312 void Cvar_SetQuick_Internal (cvar_t *var, const char *value)
316 prvm_prog_t *tmpprog;
319 changed = strcmp(var->string, value) != 0;
320 // LordHavoc: don't reallocate when there is no change
324 // LordHavoc: don't reallocate when the buffer is the same size
325 valuelen = strlen(value);
326 if (!var->string || strlen(var->string) != valuelen)
328 Z_Free ((char *)var->string); // free the old value string
330 var->string = (char *)Z_Malloc (valuelen + 1);
332 memcpy ((char *)var->string, value, valuelen + 1);
333 var->value = atof (var->string);
334 var->integer = (int) var->value;
335 if ((var->flags & CVAR_NOTIFY) && changed && sv.active)
336 SV_BroadcastPrintf("\"%s\" changed to \"%s\"\n", var->name, var->string);
338 // TODO: add infostring support to the server?
339 if ((var->flags & CVAR_SERVERINFO) && changed && sv.active)
341 InfoString_SetValue(svs.serverinfo, sizeof(svs.serverinfo), var->name, var->string);
344 MSG_WriteByte (&sv.reliable_datagram, svc_serverinfostring);
345 MSG_WriteString (&sv.reliable_datagram, var->name);
346 MSG_WriteString (&sv.reliable_datagram, var->string);
350 if ((var->flags & CVAR_USERINFO) && cls.state != ca_dedicated)
351 CL_SetInfo(var->name, var->string, true, false, false, false);
352 else if ((var->flags & CVAR_NQUSERINFOHACK) && cls.state != ca_dedicated)
354 // update the cls.userinfo to have proper values for the
355 // silly nq config variables.
357 // this is done when these variables are changed rather than at
358 // connect time because if the user or code checks the userinfo and it
359 // holds weird values it may cause confusion...
360 if (!strcmp(var->name, "_cl_color"))
362 int top = (var->integer >> 4) & 15, bottom = var->integer & 15;
363 CL_SetInfo("topcolor", va("%i", top), true, false, false, false);
364 CL_SetInfo("bottomcolor", va("%i", bottom), true, false, false, false);
365 if (cls.protocol != PROTOCOL_QUAKEWORLD && cls.netcon)
367 MSG_WriteByte(&cls.netcon->message, clc_stringcmd);
368 MSG_WriteString(&cls.netcon->message, va("color %i %i", top, bottom));
371 else if (!strcmp(var->name, "_cl_rate"))
372 CL_SetInfo("rate", va("%i", var->integer), true, false, false, false);
373 else if (!strcmp(var->name, "_cl_playerskin"))
374 CL_SetInfo("playerskin", var->string, true, false, false, false);
375 else if (!strcmp(var->name, "_cl_playermodel"))
376 CL_SetInfo("playermodel", var->string, true, false, false, false);
377 else if (!strcmp(var->name, "_cl_name"))
378 CL_SetInfo("name", var->string, true, false, false, false);
379 else if (!strcmp(var->name, "rcon_secure"))
381 // whenever rcon_secure is changed to 0, clear rcon_password for
382 // security reasons (prevents a send-rcon-password-as-plaintext
383 // attack based on NQ protocol session takeover and svc_stufftext)
384 if(var->integer <= 0)
385 Cvar_Set("rcon_password", "");
387 else if (!strcmp(var->name, "net_slist_favorites"))
388 NetConn_UpdateFavorites();
392 for(i = 0; i < PRVM_MAXPROGS; ++i)
394 if(PRVM_ProgLoaded(i))
397 Cvar_UpdateAutoCvar(var);
403 void Cvar_SetQuick (cvar_t *var, const char *value)
407 Con_Print("Cvar_SetQuick: var == NULL\n");
411 if (developer_extra.integer)
412 Con_DPrintf("Cvar_SetQuick({\"%s\", \"%s\", %i, \"%s\"}, \"%s\");\n", var->name, var->string, var->flags, var->defstring, value);
414 Cvar_SetQuick_Internal(var, value);
417 void Cvar_Set (const char *var_name, const char *value)
420 var = Cvar_FindVar (var_name);
423 Con_Printf("Cvar_Set: variable %s not found\n", var_name);
426 Cvar_SetQuick(var, value);
434 void Cvar_SetValueQuick(cvar_t *var, float value)
436 char val[MAX_INPUTLINE];
438 if ((float)((int)value) == value)
439 dpsnprintf(val, sizeof(val), "%i", (int)value);
441 dpsnprintf(val, sizeof(val), "%f", value);
442 Cvar_SetQuick(var, val);
445 void Cvar_SetValue(const char *var_name, float value)
447 char val[MAX_INPUTLINE];
449 if ((float)((int)value) == value)
450 dpsnprintf(val, sizeof(val), "%i", (int)value);
452 dpsnprintf(val, sizeof(val), "%f", value);
453 Cvar_Set(var_name, val);
458 Cvar_RegisterVariable
460 Adds a freestanding variable to the variable list.
463 void Cvar_RegisterVariable (cvar_t *variable)
466 cvar_t *current, *next, *cvar;
470 if (developer_extra.integer)
471 Con_DPrintf("Cvar_RegisterVariable({\"%s\", \"%s\", %i});\n", variable->name, variable->string, variable->flags);
473 // first check to see if it has already been defined
474 cvar = Cvar_FindVar (variable->name);
477 if (cvar->flags & CVAR_ALLOCATED)
479 if (developer_extra.integer)
480 Con_DPrintf("... replacing existing allocated cvar {\"%s\", \"%s\", %i}\n", cvar->name, cvar->string, cvar->flags);
481 // fixed variables replace allocated ones
482 // (because the engine directly accesses fixed variables)
483 // NOTE: this isn't actually used currently
484 // (all cvars are registered before config parsing)
485 variable->flags |= (cvar->flags & ~CVAR_ALLOCATED);
486 // cvar->string is now owned by variable instead
487 variable->string = cvar->string;
488 variable->defstring = cvar->defstring;
489 variable->value = atof (variable->string);
490 variable->integer = (int) variable->value;
491 // replace cvar with this one...
492 variable->next = cvar->next;
493 if (cvar_vars == cvar)
495 // head of the list is easy to change
496 cvar_vars = variable;
500 // otherwise find it somewhere in the list
501 for (current = cvar_vars;current->next != cvar;current = current->next)
503 current->next = variable;
506 // get rid of old allocated cvar
507 // (but not cvar->string and cvar->defstring, because we kept those)
508 Z_Free((char *)cvar->name);
512 Con_DPrintf("Can't register variable %s, already defined\n", variable->name);
516 // check for overlap with a command
517 if (Cmd_Exists (variable->name))
519 Con_Printf("Cvar_RegisterVariable: %s is a command\n", variable->name);
523 // copy the value off, because future sets will Z_Free it
524 oldstr = (char *)variable->string;
525 alloclen = strlen(variable->string) + 1;
526 variable->string = (char *)Z_Malloc (alloclen);
527 memcpy ((char *)variable->string, oldstr, alloclen);
528 variable->defstring = (char *)Z_Malloc (alloclen);
529 memcpy ((char *)variable->defstring, oldstr, alloclen);
530 variable->value = atof (variable->string);
531 variable->integer = (int) variable->value;
533 // link the variable in
534 // alphanumerical order
535 for( current = NULL, next = cvar_vars ; next && strcmp( next->name, variable->name ) < 0 ; current = next, next = next->next )
538 current->next = variable;
540 cvar_vars = variable;
542 variable->next = next;
544 // link to head of list in this hash table index
545 hashindex = CRC_Block((const unsigned char *)variable->name, strlen(variable->name)) % CVAR_HASHSIZE;
546 variable->nextonhashchain = cvar_hashtable[hashindex];
547 cvar_hashtable[hashindex] = variable;
554 Adds a newly allocated variable to the variable list or sets its value.
557 cvar_t *Cvar_Get (const char *name, const char *value, int flags, const char *newdescription)
560 cvar_t *current, *next, *cvar;
562 if (developer_extra.integer)
563 Con_DPrintf("Cvar_Get(\"%s\", \"%s\", %i);\n", name, value, flags);
565 // first check to see if it has already been defined
566 cvar = Cvar_FindVar (name);
569 cvar->flags |= flags;
570 Cvar_SetQuick_Internal (cvar, value);
571 if(newdescription && (cvar->flags & CVAR_ALLOCATED))
573 if(cvar->description != cvar_dummy_description)
574 Z_Free((char *)cvar->description);
577 cvar->description = (char *)Mem_strdup(zonemempool, newdescription);
579 cvar->description = cvar_dummy_description;
584 // check for pure evil
587 Con_Printf("Cvar_Get: invalid variable name\n");
591 // check for overlap with a command
592 if (Cmd_Exists (name))
594 Con_Printf("Cvar_Get: %s is a command\n", name);
598 // allocate a new cvar, cvar name, and cvar string
599 // TODO: factorize the following code with the one at the end of Cvar_RegisterVariable()
600 // FIXME: these never get Z_Free'd
601 cvar = (cvar_t *)Z_Malloc(sizeof(cvar_t));
602 cvar->flags = flags | CVAR_ALLOCATED;
603 cvar->name = (char *)Mem_strdup(zonemempool, name);
604 cvar->string = (char *)Mem_strdup(zonemempool, value);
605 cvar->defstring = (char *)Mem_strdup(zonemempool, value);
606 cvar->value = atof (cvar->string);
607 cvar->integer = (int) cvar->value;
609 if(newdescription && *newdescription)
610 cvar->description = (char *)Mem_strdup(zonemempool, newdescription);
612 cvar->description = cvar_dummy_description; // actually checked by VM_cvar_type
614 // link the variable in
615 // alphanumerical order
616 for( current = NULL, next = cvar_vars ; next && strcmp( next->name, cvar->name ) < 0 ; current = next, next = next->next )
619 current->next = cvar;
624 // link to head of list in this hash table index
625 hashindex = CRC_Block((const unsigned char *)cvar->name, strlen(cvar->name)) % CVAR_HASHSIZE;
626 cvar->nextonhashchain = cvar_hashtable[hashindex];
627 cvar_hashtable[hashindex] = cvar;
637 Handles variable inspection and changing from the console
640 qboolean Cvar_Command (void)
645 v = Cvar_FindVar (Cmd_Argv(0));
649 // perform a variable print or set
652 Con_Printf("\"%s\" is \"%s\" [\"%s\"]\n", v->name, ((v->flags & CVAR_PRIVATE) ? "********"/*hunter2*/ : v->string), v->defstring);
656 if (developer_extra.integer)
657 Con_DPrint("Cvar_Command: ");
659 if (v->flags & CVAR_READONLY)
661 Con_Printf("%s is read-only\n", v->name);
664 Cvar_Set (v->name, Cmd_Argv(1));
665 if (developer_extra.integer)
671 void Cvar_UnlockDefaults (void)
674 // unlock the default values of all cvars
675 for (var = cvar_vars ; var ; var = var->next)
676 var->flags &= ~CVAR_DEFAULTSET;
680 void Cvar_LockDefaults_f (void)
683 // lock in the default values of all cvars
684 for (var = cvar_vars ; var ; var = var->next)
686 if (!(var->flags & CVAR_DEFAULTSET))
690 //Con_Printf("locking cvar %s (%s -> %s)\n", var->name, var->string, var->defstring);
691 var->flags |= CVAR_DEFAULTSET;
692 Z_Free((char *)var->defstring);
693 alloclen = strlen(var->string) + 1;
694 var->defstring = (char *)Z_Malloc(alloclen);
695 memcpy((char *)var->defstring, var->string, alloclen);
700 void Cvar_SaveInitState(void)
703 for (c = cvar_vars;c;c = c->next)
706 c->initflags = c->flags;
707 c->initdefstring = Mem_strdup(zonemempool, c->defstring);
708 c->initstring = Mem_strdup(zonemempool, c->string);
709 c->initvalue = c->value;
710 c->initinteger = c->integer;
711 VectorCopy(c->vector, c->initvector);
715 void Cvar_RestoreInitState(void)
720 for (cp = &cvar_vars;(c = *cp);)
724 // restore this cvar, it existed at init
725 if (((c->flags ^ c->initflags) & CVAR_MAXFLAGSVAL)
726 || strcmp(c->defstring ? c->defstring : "", c->initdefstring ? c->initdefstring : "")
727 || strcmp(c->string ? c->string : "", c->initstring ? c->initstring : ""))
729 Con_DPrintf("Cvar_RestoreInitState: Restoring cvar \"%s\"\n", c->name);
731 Z_Free((char *)c->defstring);
732 c->defstring = Mem_strdup(zonemempool, c->initdefstring);
734 Z_Free((char *)c->string);
735 c->string = Mem_strdup(zonemempool, c->initstring);
737 c->flags = c->initflags;
738 c->value = c->initvalue;
739 c->integer = c->initinteger;
740 VectorCopy(c->initvector, c->vector);
745 if (!(c->flags & CVAR_ALLOCATED))
747 Con_DPrintf("Cvar_RestoreInitState: Unable to destroy cvar \"%s\", it was registered after init!\n", c->name);
750 // remove this cvar, it did not exist at init
751 Con_DPrintf("Cvar_RestoreInitState: Destroying cvar \"%s\"\n", c->name);
752 // unlink struct from hash
753 hashindex = CRC_Block((const unsigned char *)c->name, strlen(c->name)) % CVAR_HASHSIZE;
754 for (cp2 = &cvar_hashtable[hashindex];(c2 = *cp2);)
758 *cp2 = c2->nextonhashchain;
762 cp2 = &c2->nextonhashchain;
764 // unlink struct from main list
768 Z_Free((char *)c->defstring);
770 Z_Free((char *)c->string);
771 if (c->description && c->description != cvar_dummy_description)
772 Z_Free((char *)c->description);
779 void Cvar_ResetToDefaults_All_f (void)
782 // restore the default values of all cvars
783 for (var = cvar_vars ; var ; var = var->next)
784 if((var->flags & CVAR_NORESETTODEFAULTS) == 0)
785 Cvar_SetQuick(var, var->defstring);
789 void Cvar_ResetToDefaults_NoSaveOnly_f (void)
792 // restore the default values of all cvars
793 for (var = cvar_vars ; var ; var = var->next)
794 if ((var->flags & (CVAR_NORESETTODEFAULTS | CVAR_SAVE)) == 0)
795 Cvar_SetQuick(var, var->defstring);
799 void Cvar_ResetToDefaults_SaveOnly_f (void)
802 // restore the default values of all cvars
803 for (var = cvar_vars ; var ; var = var->next)
804 if ((var->flags & (CVAR_NORESETTODEFAULTS | CVAR_SAVE)) == CVAR_SAVE)
805 Cvar_SetQuick(var, var->defstring);
813 Writes lines containing "set variable value" for all variables
814 with the archive flag set to true.
817 void Cvar_WriteVariables (qfile_t *f)
820 char buf1[MAX_INPUTLINE], buf2[MAX_INPUTLINE];
822 // don't save cvars that match their default value
823 for (var = cvar_vars ; var ; var = var->next)
824 if ((var->flags & CVAR_SAVE) && (strcmp(var->string, var->defstring) || !(var->flags & CVAR_DEFAULTSET)))
826 Cmd_QuoteString(buf1, sizeof(buf1), var->name, "\"\\$", false);
827 Cmd_QuoteString(buf2, sizeof(buf2), var->string, "\"\\$", false);
828 FS_Printf(f, "%s\"%s\" \"%s\"\n", var->flags & CVAR_ALLOCATED ? "seta " : "", buf1, buf2);
833 // Added by EvilTypeGuy eviltypeguy@qeradiant.com
834 // 2000-01-09 CvarList command By Matthias "Maddes" Buecher, http://www.inside3d.com/qip/
840 void Cvar_List_f (void)
850 partial = Cmd_Argv (1);
851 len = strlen(partial);
859 ispattern = partial && (strchr(partial, '*') || strchr(partial, '?'));
862 for (cvar = cvar_vars; cvar; cvar = cvar->next)
864 if (len && (ispattern ? !matchpattern_with_separator(cvar->name, partial, false, "", false) : strncmp (partial,cvar->name,len)))
867 Con_Printf("%s is \"%s\" [\"%s\"] %s\n", cvar->name, ((cvar->flags & CVAR_PRIVATE) ? "********"/*hunter2*/ : cvar->string), cvar->defstring, cvar->description);
874 Con_Printf("%i cvar%s matching \"%s\"\n", count, (count > 1) ? "s" : "", partial);
876 Con_Printf("%i cvar%s beginning with \"%s\"\n", count, (count > 1) ? "s" : "", partial);
879 Con_Printf("%i cvar(s)\n", count);
881 // 2000-01-09 CvarList command by Maddes
883 void Cvar_Set_f (void)
887 // make sure it's the right number of parameters
890 Con_Printf("Set: wrong number of parameters, usage: set <variablename> <value> [<description>]\n");
894 // check if it's read-only
895 cvar = Cvar_FindVar(Cmd_Argv(1));
896 if (cvar && cvar->flags & CVAR_READONLY)
898 Con_Printf("Set: %s is read-only\n", cvar->name);
902 if (developer_extra.integer)
905 // all looks ok, create/modify the cvar
906 Cvar_Get(Cmd_Argv(1), Cmd_Argv(2), 0, Cmd_Argc() > 3 ? Cmd_Argv(3) : NULL);
909 void Cvar_SetA_f (void)
913 // make sure it's the right number of parameters
916 Con_Printf("SetA: wrong number of parameters, usage: seta <variablename> <value> [<description>]\n");
920 // check if it's read-only
921 cvar = Cvar_FindVar(Cmd_Argv(1));
922 if (cvar && cvar->flags & CVAR_READONLY)
924 Con_Printf("SetA: %s is read-only\n", cvar->name);
928 if (developer_extra.integer)
929 Con_DPrint("SetA: ");
931 // all looks ok, create/modify the cvar
932 Cvar_Get(Cmd_Argv(1), Cmd_Argv(2), CVAR_SAVE, Cmd_Argc() > 3 ? Cmd_Argv(3) : NULL);
935 void Cvar_Del_f (void)
938 cvar_t *cvar, *parent, **link, *prev;
942 Con_Printf("Del: wrong number of parameters, useage: unset <variablename1> [<variablename2> ...]\n");
945 for(i = 1; i < Cmd_Argc(); ++i)
947 cvar = Cvar_FindVarLink(Cmd_Argv(i), &parent, &link, &prev);
950 Con_Printf("Del: %s is not defined\n", Cmd_Argv(i));
953 if(cvar->flags & CVAR_READONLY)
955 Con_Printf("Del: %s is read-only\n", cvar->name);
958 if(!(cvar->flags & CVAR_ALLOCATED))
960 Con_Printf("Del: %s is static and cannot be deleted\n", cvar->name);
963 if(cvar == cvar_vars)
965 cvar_vars = cvar->next;
969 // in this case, prev must be set, otherwise there has been some inconsistensy
970 // elsewhere already... should I still check for prev != NULL?
971 prev->next = cvar->next;
975 parent->nextonhashchain = cvar->nextonhashchain;
977 *link = cvar->nextonhashchain;
979 if(cvar->description != cvar_dummy_description)
980 Z_Free((char *)cvar->description);
982 Z_Free((char *)cvar->name);
983 Z_Free((char *)cvar->string);
984 Z_Free((char *)cvar->defstring);
989 #ifdef FILLALLCVARSWITHRUBBISH
990 void Cvar_FillAll_f()
998 Con_Printf("Usage: %s length to plant rubbish\n", Cmd_Argv(0));
999 Con_Printf("Usage: %s -length to verify that the rubbish is still there\n", Cmd_Argv(0));
1002 n = atoi(Cmd_Argv(1));
1006 buf = Z_Malloc(n + 1);
1008 for(var = cvar_vars; var; var = var->next)
1010 for(i = 0, p = buf, q = var->name; i < n; ++i)
1016 if(verify && strcmp(var->string, buf))
1018 Con_Printf("\n%s does not contain the right rubbish, either this is the first run or a possible overrun was detected, or something changed it intentionally; it DOES contain: %s\n", var->name, var->string);
1020 Cvar_SetQuick(var, buf);
1024 #endif /* FILLALLCVARSWITHRUBBISH */