cvar_vars is no longer known by files other than cvar.c, this meant adding a Cvar_Fin...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 15 Aug 2002 18:51:33 +0000 (18:51 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 15 Aug 2002 18:51:33 +0000 (18:51 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2245 d7cf8633-e32d-0410-b094-e92efae38249

cvar.c
cvar.h
net_dgrm.c
pr_cmds.c

diff --git a/cvar.c b/cvar.c
index 152a86a..3349986 100644 (file)
--- a/cvar.c
+++ b/cvar.c
@@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "quakedef.h"
 
-cvar_t *cvar_vars;
+cvar_t *cvar_vars = NULL;
 char   *cvar_null_string = "";
 
 /*
@@ -31,15 +31,39 @@ Cvar_FindVar
 */
 cvar_t *Cvar_FindVar (char *var_name)
 {
-       cvar_t  *var;
+       cvar_t *var;
 
-       for (var=cvar_vars ; var ; var=var->next)
+       for (var = cvar_vars;var;var = var->next)
                if (!strcmp (var_name, var->name))
                        return var;
 
        return NULL;
 }
 
+cvar_t *Cvar_FindVarAfter (char *prev_var_name, int neededflags)
+{
+       cvar_t *var;
+
+       if (*prev_var_name)
+       {
+               var = Cvar_FindVar (prev_var_name);
+               if (!var)
+                       return NULL;
+               var = var->next;
+       }
+       else
+               var = cvar_vars;
+
+       // search for the next cvar matching the needed flags
+       while (var)
+       {
+               if ((var->flags & neededflags) || !neededflags)
+                       break;
+               var = var->next;
+       }
+       return var;
+}
+
 /*
 ============
 Cvar_VariableValue
diff --git a/cvar.h b/cvar.h
index 4e3e979..89ad8fc 100644 (file)
--- a/cvar.h
+++ b/cvar.h
@@ -145,8 +145,7 @@ void        Cvar_WriteVariables (QFile *f);
 // with the archive flag set to true.
 
 cvar_t *Cvar_FindVar (char *var_name);
-
-extern cvar_t  *cvar_vars;
+cvar_t *Cvar_FindVarAfter (char *prev_var_name, int neededflags);
 
 int            Cvar_CompleteCountPossible (char *partial);
 char   **Cvar_CompleteBuildList (char *partial);
index c8956e6..7829b1c 100644 (file)
@@ -923,23 +923,7 @@ static qsocket_t *_Datagram_CheckNewConnections (void)
 
                // find the search start location
                prevCvarName = MSG_ReadString();
-               if (*prevCvarName)
-               {
-                       var = Cvar_FindVar (prevCvarName);
-                       if (!var)
-                               return NULL;
-                       var = var->next;
-               }
-               else
-                       var = cvar_vars;
-
-               // search for the next server cvar
-               while (var)
-               {
-                       if (var->flags & CVAR_NOTIFY)
-                               break;
-                       var = var->next;
-               }
+               var = Cvar_FindVarAfter(prevCvarName, CVAR_NOTIFY);
 
                // send the response
 
index 1c3032d..fc67d6c 100644 (file)
--- a/pr_cmds.c
+++ b/pr_cmds.c
@@ -1889,8 +1889,8 @@ int currentqc_cvar;
 
 void PF_registercvar (void)
 {
-       char    *name, *value;
-       cvar_t  *variable;
+       char *name, *value;
+       cvar_t *variable;
        name = G_STRING(OFS_PARM0);
        value = G_STRING(OFS_PARM1);
        G_FLOAT(OFS_RETURN) = 0;
@@ -1916,9 +1916,7 @@ void PF_registercvar (void)
        strcpy (variable->string, value);
        variable->value = atof (value);
 
-// link the variable in
-       variable->next = cvar_vars;
-       cvar_vars = variable;
+       Cvar_RegisterVariable(variable);
        G_FLOAT(OFS_RETURN) = 1; // success
 }