From: havoc Date: Thu, 1 Mar 2007 23:11:26 +0000 (+0000) Subject: fixed problems with playing on QW server caused by the use of _cl_name and similar... X-Git-Tag: xonotic-v0.1.0preview~3487 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=ae1c97f4f08efad7eea978393eaf0ab418310e20 fixed problems with playing on QW server caused by the use of _cl_name and similar config variables git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6929 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cvar.c b/cvar.c index d3df0c42..98892d70 100644 --- a/cvar.c +++ b/cvar.c @@ -250,6 +250,28 @@ 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")) + { + CL_SetInfo("topcolor", va("%i", (var->integer >> 4) & 15), true, false, false, false); + CL_SetInfo("bottomcolor", va("%i", (var->integer) & 15), true, false, false, false); + } + 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) diff --git a/cvar.h b/cvar.h index 4224653e..63b1b5e4 100644 --- a/cvar.h +++ b/cvar.h @@ -65,8 +65,10 @@ interface from being ambiguous. #define CVAR_USERINFO 16 // CVAR_PRIVATE means do not $ expand or sendcvar this cvar under any circumstances (rcon_password uses this) #define CVAR_PRIVATE 32 +// this means that this cvar should update a userinfo key but the name does not correspond directly to the userinfo key to update, and may require additional conversion ("_cl_color" for example should update "topcolor" and "bottomcolor") +#define CVAR_NQUSERINFOHACK 64 // used to determine if flags is valid -#define CVAR_MAXFLAGSVAL 63 +#define CVAR_MAXFLAGSVAL 127 // for internal use only! #define CVAR_DEFAULTSET (1<<30) #define CVAR_ALLOCATED (1<<31) diff --git a/host_cmd.c b/host_cmd.c index 57859b5c..2c466d1f 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -756,7 +756,7 @@ void Host_Loadgame_f (void) Host_Name_f ====================== */ -cvar_t cl_name = {CVAR_SAVE, "_cl_name", "player", "internal storage cvar for current player name (changed by name command)"}; +cvar_t cl_name = {CVAR_SAVE | CVAR_NQUSERINFOHACK, "_cl_name", "player", "internal storage cvar for current player name (changed by name command)"}; void Host_Name_f (void) { int i, j; @@ -813,7 +813,7 @@ void Host_Name_f (void) Host_Playermodel_f ====================== */ -cvar_t cl_playermodel = {CVAR_SAVE, "_cl_playermodel", "", "internal storage cvar for current player model in Nexuiz (changed by playermodel command)"}; +cvar_t cl_playermodel = {CVAR_SAVE | CVAR_NQUSERINFOHACK, "_cl_playermodel", "", "internal storage cvar for current player model in Nexuiz (changed by playermodel command)"}; // the old cl_playermodel in cl_main has been renamed to __cl_playermodel void Host_Playermodel_f (void) { @@ -872,7 +872,7 @@ void Host_Playermodel_f (void) Host_Playerskin_f ====================== */ -cvar_t cl_playerskin = {CVAR_SAVE, "_cl_playerskin", "", "internal storage cvar for current player skin in Nexuiz (changed by playerskin command)"}; +cvar_t cl_playerskin = {CVAR_SAVE | CVAR_NQUSERINFOHACK, "_cl_playerskin", "", "internal storage cvar for current player skin in Nexuiz (changed by playerskin command)"}; void Host_Playerskin_f (void) { int i, j; @@ -1144,7 +1144,7 @@ void Host_Tell_f(void) Host_Color_f ================== */ -cvar_t cl_color = {CVAR_SAVE, "_cl_color", "0", "internal storage cvar for current player colors (changed by color command)"}; +cvar_t cl_color = {CVAR_SAVE | CVAR_NQUSERINFOHACK, "_cl_color", "0", "internal storage cvar for current player colors (changed by color command)"}; void Host_Color(int changetop, int changebottom) { int top, bottom, playercolor; @@ -1256,7 +1256,7 @@ void Host_BottomColor_f(void) Host_Color(-1, atoi(Cmd_Argv(1))); } -cvar_t cl_rate = {CVAR_SAVE, "_cl_rate", "10000", "internal storage cvar for current rate (changed by rate command)"}; +cvar_t cl_rate = {CVAR_SAVE | CVAR_NQUSERINFOHACK, "_cl_rate", "10000", "internal storage cvar for current rate (changed by rate command)"}; void Host_Rate_f(void) { int rate; @@ -1325,7 +1325,7 @@ LordHavoc: only supported for Nehahra, I personally think this is dumb, but Mind LordHavoc: correction, Mindcrime will be removing pmodel in the future, but it's still stuck here for compatibility. ====================== */ -cvar_t cl_pmodel = {CVAR_SAVE, "_cl_pmodel", "0", "internal storage cvar for current player model number in nehahra (changed by pmodel command)"}; +cvar_t cl_pmodel = {CVAR_SAVE | CVAR_NQUSERINFOHACK, "_cl_pmodel", "0", "internal storage cvar for current player model number in nehahra (changed by pmodel command)"}; static void Host_PModel_f (void) { int i;