From c85a468602c6f59c1f852c19f3a12e6d3fa90131 Mon Sep 17 00:00:00 2001 From: "Anton E. Gavrilov" Date: Fri, 22 Sep 2000 15:32:52 +0000 Subject: [PATCH] 1. Cvar_CvarList_f() prints cvar flags (like Q2/Q3 do) 2. CVAR_HEAP makes no sense now that ALL cvar are stored in heap. 3. No need to allocate memory for cvar descriptions 4. ^= CVAR_USER_CREATED ---> &= ~CVAR_USER_CREATED --- source/cvar.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/source/cvar.c b/source/cvar.c index 4957297..6cbe296 100644 --- a/source/cvar.c +++ b/source/cvar.c @@ -311,7 +311,7 @@ void Cvar_Set_f(void) } else { - var = Cvar_Get (var_name, value, CVAR_USER_CREATED|CVAR_HEAP, + var = Cvar_Get (var_name, value, CVAR_USER_CREATED, "User created cvar"); } } @@ -393,9 +393,13 @@ void Cvar_CvarList_f (void) int i; for (var=cvar_vars, i=0 ; var ; var=var->next, i++) - { - Con_Printf("%s\n",var->name); - } + Con_Printf("%c%c%c %s\n", + var->flags & CVAR_ARCHIVE ? '*' : ' ', + var->flags & CVAR_USERINFO ? 'u' : ' ', + var->flags & CVAR_SERVERINFO ? 's' : ' ', + var->name); + + Con_Printf ("------------\n%d variables\n", i); } @@ -420,7 +424,6 @@ void Cvar_Shutdown (void) while(var) { next = var->next; - free(var->description); free(var->string); free(var->name); free(var); @@ -459,20 +462,15 @@ cvar_t *Cvar_Get(char *name, char *string, int cvarflags, char *description) v->string = malloc (strlen(string)+1); strcpy (v->string, string); v->flags = cvarflags; - v->description = strdup(description); + v->description = description; v->value = atof (v->string); return v; } // Cvar does exist, so we update the flags and return. - v->flags ^= CVAR_USER_CREATED; - v->flags ^= CVAR_HEAP; + v->flags &= ~CVAR_USER_CREATED; v->flags |= cvarflags; - if (!strcmp (v->description,"User created cvar")) - { - // Set with the real description - free(v->description); - v->description = strdup (description); - } + v->description = description; + return v; }