]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cvar.c
fix ESC in disconnected state. FINALLY!
[xonotic/darkplaces.git] / cvar.c
diff --git a/cvar.c b/cvar.c
index d3df0c421ebc71fce219e56cfe59b2c10e525ddd..24fb2b2eab6d661da659e566c1d20fda32d3fb99 100644 (file)
--- a/cvar.c
+++ b/cvar.c
@@ -250,6 +250,34 @@ void Cvar_SetQuick_Internal (cvar_t *var, const char *value)
 #endif
        if ((var->flags & CVAR_USERINFO) && cls.state != ca_dedicated)
                CL_SetInfo(var->name, var->string, true, false, false, false);
+       else if ((var->flags & CVAR_NQUSERINFOHACK) && cls.state != ca_dedicated)
+       {
+               // update the cls.userinfo to have proper values for the
+               // silly nq config variables.
+               //
+               // this is done when these variables are changed rather than at
+               // connect time because if the user or code checks the userinfo and it
+               // holds weird values it may cause confusion...
+               if (!strcmp(var->name, "_cl_color"))
+               {
+                       int top = (var->integer >> 4) & 15, bottom = var->integer & 15;
+                       CL_SetInfo("topcolor", va("%i", top), true, false, false, false);
+                       CL_SetInfo("bottomcolor", va("%i", bottom), true, false, false, false);
+                       if (cls.protocol != PROTOCOL_QUAKEWORLD && cls.netcon)
+                       {
+                               MSG_WriteByte(&cls.netcon->message, clc_stringcmd);
+                               MSG_WriteString(&cls.netcon->message, va("color %i %i", top, bottom));
+                       }
+               }
+               else if (!strcmp(var->name, "_cl_rate"))
+                       CL_SetInfo("rate", va("%i", var->integer), true, false, false, false);
+               else if (!strcmp(var->name, "_cl_playerskin"))
+                       CL_SetInfo("playerskin", var->string, true, false, false, false);
+               else if (!strcmp(var->name, "_cl_playermodel"))
+                       CL_SetInfo("playermodel", var->string, true, false, false, false);
+               else if (!strcmp(var->name, "_cl_name"))
+                       CL_SetInfo("name", var->string, true, false, false, false);
+       }
 }
 
 void Cvar_SetQuick (cvar_t *var, const char *value)
@@ -288,9 +316,9 @@ void Cvar_SetValueQuick(cvar_t *var, float value)
        char val[MAX_INPUTLINE];
 
        if ((float)((int)value) == value)
-               sprintf(val, "%i", (int)value);
+               dpsnprintf(val, sizeof(val), "%i", (int)value);
        else
-               sprintf(val, "%f", value);
+               dpsnprintf(val, sizeof(val), "%f", value);
        Cvar_SetQuick(var, val);
 }
 
@@ -299,9 +327,9 @@ void Cvar_SetValue(const char *var_name, float value)
        char val[MAX_INPUTLINE];
 
        if ((float)((int)value) == value)
-               sprintf(val, "%i", (int)value);
+               dpsnprintf(val, sizeof(val), "%i", (int)value);
        else
-               sprintf(val, "%f", value);
+               dpsnprintf(val, sizeof(val), "%f", value);
        Cvar_Set(var_name, val);
 }
 
@@ -446,7 +474,7 @@ cvar_t *Cvar_Get (const char *name, const char *value, int flags)
        memcpy(cvar->defstring, value, alloclen);
        cvar->value = atof (cvar->string);
        cvar->integer = (int) cvar->value;
-       cvar->description = "custom cvar";
+       cvar->description = "custom cvar"; // actually checked by VM_cvar_type
 
 // link the variable in
 // alphanumerical order
@@ -644,7 +672,8 @@ void Cvar_Set_f (void)
                return;
        }
 
-       Con_DPrint("Set: ");
+       if (developer.integer >= 100)
+               Con_DPrint("Set: ");
 
        // all looks ok, create/modify the cvar
        Cvar_Get(Cmd_Argv(1), Cmd_Argv(2), 0);
@@ -669,7 +698,8 @@ void Cvar_SetA_f (void)
                return;
        }
 
-       Con_DPrint("SetA: ");
+       if (developer.integer >= 100)
+               Con_DPrint("SetA: ");
 
        // all looks ok, create/modify the cvar
        Cvar_Get(Cmd_Argv(1), Cmd_Argv(2), CVAR_SAVE);