diff --git a/qw/include/client.h b/qw/include/client.h index f35674241..a0ed031d2 100644 --- a/qw/include/client.h +++ b/qw/include/client.h @@ -87,6 +87,8 @@ typedef struct player_info_s // skin information int topcolor; int bottomcolor; + struct info_key_s *skinname; + struct info_key_s *team; int _topcolor; int _bottomcolor; @@ -258,8 +260,10 @@ typedef struct float stdver; // serverinfo mirrors - int watervis; int chase; + int no_pogo_stick; + int teamplay; + int watervis; // refresh related state struct model_s *worldmodel; // cl_entitites[0].model diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index ca23e9157..b9f12859a 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -597,6 +597,12 @@ CL_FullServerinfo_f (void) if ((p = Info_ValueForKey (cl.serverinfo, "chase")) && *p) { cl.chase = atof (p); } + if ((p = Info_ValueForKey (cl.serverinfo, "no_pogo_stick")) && *p) { + cl.no_pogo_stick = atof (p); + } + if ((p = Info_ValueForKey (cl.serverinfo, "teamplay")) && *p) { + cl.teamplay = atof (p); + } if ((p = Info_ValueForKey (cl.serverinfo, "watervis")) && *p) { cl.watervis = atof (p); } @@ -1469,7 +1475,7 @@ Host_Frame (float time) // fetch results from server CL_ReadPackets (); - if (atoi (Info_ValueForKey (cl.serverinfo, "no_pogo_stick"))) + if (cl.no_pogo_stick) Cvar_Set (no_pogo_stick, "1"); // send intentions now diff --git a/qw/source/cl_parse.c b/qw/source/cl_parse.c index ddc53714c..d98b67b46 100644 --- a/qw/source/cl_parse.c +++ b/qw/source/cl_parse.c @@ -47,6 +47,7 @@ static const char rcsid[] = #include "QF/cmd.h" #include "QF/console.h" #include "QF/cvar.h" +#include "QF/hash.h" #include "QF/msg.h" #include "QF/screen.h" #include "QF/sound.h" @@ -1002,12 +1003,25 @@ CL_ParseClientdata (void) void CL_ProcessUserInfo (int slot, player_info_t *player) { + char skin[512]; + const char *s; + + s = Info_ValueForKey (player->userinfo, "skin"); + COM_StripExtension (s, skin); // FIXME buffer overflow + if (!strequal (s, skin)) + Info_SetValueForKey (player->userinfo, "skin", skin, 1); strncpy (player->name, Info_ValueForKey (player->userinfo, "name"), sizeof (player->name) - 1); player->_topcolor = player->_bottomcolor = -1; player->topcolor = atoi (Info_ValueForKey (player->userinfo, "topcolor")); player->bottomcolor = atoi (Info_ValueForKey (player->userinfo, "bottomcolor")); + + while (!(player->team = Hash_Find (player->userinfo->tab, "team"))) + Info_SetValueForKey (player->userinfo, "team", "", 1); + while (!(player->skinname = Hash_Find (player->userinfo->tab, "skin"))) + Info_SetValueForKey (player->userinfo, "skin", "", 1); + if (Info_ValueForKey (player->userinfo, "*spectator")[0]) player->spectator = true; else diff --git a/qw/source/cl_skin.c b/qw/source/cl_skin.c index df25dd66c..bb3fb1202 100644 --- a/qw/source/cl_skin.c +++ b/qw/source/cl_skin.c @@ -177,13 +177,22 @@ CL_Skin_Init (void) "pants will match"); } +static void +skin_f (cvar_t *var) +{ + char *s = Hunk_TempAlloc (strlen (var->string) + 1); + COM_StripExtension (var->string, s); + Cvar_Set (var, s); + Cvar_Info (var); +} + void CL_Skin_Init_Cvars (void) { Skin_Init_Cvars (); noskins = Cvar_Get ("noskins", "0", CVAR_NONE, NULL, //XXX FIXME "set to 1 to not download new skins"); - skin = Cvar_Get ("skin", "", CVAR_ARCHIVE | CVAR_USERINFO, Cvar_Info, + skin = Cvar_Get ("skin", "", CVAR_ARCHIVE | CVAR_USERINFO, skin_f, "Players skin"); topcolor = Cvar_Get ("topcolor", "0", CVAR_ARCHIVE | CVAR_USERINFO, Cvar_Info, "Players color on top"); @@ -194,7 +203,6 @@ CL_Skin_Init_Cvars (void) void CL_NewTranslation (int slot, skin_t *skin) { - char s[512]; player_info_t *player; if (slot > MAX_CLIENTS) @@ -204,16 +212,13 @@ CL_NewTranslation (int slot, skin_t *skin) if (!player->name[0]) return; - strcpy (s, Info_ValueForKey (player->userinfo, "skin")); - COM_StripExtension (s, s); - if (player->skin && !strequal (s, player->skin->name)) + if (player->skin && !strequal (player->skinname->value, player->skin->name)) player->skin = NULL; if (player->_topcolor != player->topcolor || player->_bottomcolor != player->bottomcolor || !player->skin) { player->_topcolor = player->topcolor; player->_bottomcolor = player->bottomcolor; - Skin_Set_Translate (player->topcolor, player->bottomcolor, player->translations); if (!player->skin) diff --git a/qw/source/sbar.c b/qw/source/sbar.c index d4ea532e8..5ada26369 100644 --- a/qw/source/sbar.c +++ b/qw/source/sbar.c @@ -388,14 +388,13 @@ void Sbar_SortTeams (void) { char t[16 + 1]; - int teamplay, i, j, k; + int i, j, k; player_info_t *s; // request new ping times every two second scoreboardteams = 0; - teamplay = atoi (Info_ValueForKey (cl.serverinfo, "teamplay")); - if (!teamplay) + if (!cl.teamplay) return; // sort the teams @@ -412,7 +411,7 @@ Sbar_SortTeams (void) // find his team in the list t[16] = 0; - strncpy (t, Info_ValueForKey (s->userinfo, "team"), 16); + strncpy (t, s->team->value, 16); if (!t || !t[0]) continue; // not on team for (j = 0; j < scoreboardteams; j++) @@ -751,8 +750,8 @@ Sbar_Draw (int swap) // main screen deathmatch rankings // if we're dead show team scores in team games if (cl.stats[STAT_HEALTH] <= 0 && !cl.spectator) - if (atoi (Info_ValueForKey (cl.serverinfo, "teamplay")) > 0 && - !sb_showscores) Sbar_TeamOverlay (); + if (cl.teamplay > 0 && !sb_showscores) + Sbar_TeamOverlay (); else Sbar_DeathmatchOverlay (0); else if (sb_showscores) @@ -805,14 +804,12 @@ void Sbar_TeamOverlay (void) { char num[12], team[5]; - int pavg, plow, phigh, teamplay, i, k, l, x, y; + int pavg, plow, phigh, i, k, l, x, y; qpic_t *pic; team_t *tm; // request new ping times every two second - teamplay = atoi (Info_ValueForKey (cl.serverinfo, "teamplay")); - - if (!teamplay) { + if (!cl.teamplay) { Sbar_DeathmatchOverlay (0); return; } @@ -873,8 +870,7 @@ Sbar_TeamOverlay (void) snprintf (num, sizeof (num), "%5i", tm->players); Draw_String (x + 104 + 88, y, num); - if (!strncmp (Info_ValueForKey (cl.players[cl.playernum].userinfo, - "team"), tm->team, 16)) { + if (strnequal (cl.players[cl.playernum].team->value, tm->team, 16)) { Draw_Character (x + 104 - 8, y, 16); Draw_Character (x + 104 + 32, y, 17); } @@ -894,7 +890,7 @@ void Sbar_DeathmatchOverlay (int start) { char num[12], team[5]; - int minutes, teamplay, total, top, bottom, f, i, k, l, p, x, y; + int minutes, total, top, bottom, f, i, k, l, p, x, y; int skip = 10; player_info_t *s; qpic_t *pic; @@ -913,8 +909,6 @@ Sbar_DeathmatchOverlay (int start) SZ_Print (&cls.netchan.message, "pings"); } - teamplay = atoi (Info_ValueForKey (cl.serverinfo, "teamplay")); - scr_copyeverything = 1; scr_fullupdate = 0; @@ -932,7 +926,7 @@ Sbar_DeathmatchOverlay (int start) y = start; else y = 24; - if (teamplay) { + if (cl.teamplay) { x = 4; // 0 40 64 104 152 192 if (cl_showscoresuid->int_val == 0) @@ -988,7 +982,7 @@ Sbar_DeathmatchOverlay (int start) if (s->spectator) { Draw_String (x + 40, y, "(spectator)"); // draw name - if (teamplay) + if (cl.teamplay) Draw_String (x + 152 + 40, y, s->name); else Draw_String (x + 152, y, s->name); @@ -1030,13 +1024,13 @@ Sbar_DeathmatchOverlay (int start) Draw_Character (x + 136, y, 17); } // team - if (teamplay) { + if (cl.teamplay) { team[4] = 0; - strncpy (team, Info_ValueForKey (s->userinfo, "team"), 4); + strncpy (team, s->team->value, 4); Draw_String (x + 152, y, team); } // draw name - if (teamplay) + if (cl.teamplay) Draw_String (x + 152 + 40, y, s->name); else Draw_String (x + 152, y, s->name); @@ -1058,7 +1052,7 @@ Sbar_DeathmatchOverlay (int start) void Sbar_MiniDeathmatchOverlay (void) { - int numlines, teamplay, top, bottom, f, i, k, x, y; + int numlines, top, bottom, f, i, k, x, y; char name[16 + 1], num[12], team[5]; player_info_t *s; team_t *tm; @@ -1066,8 +1060,6 @@ Sbar_MiniDeathmatchOverlay (void) if (vid.width < 512 || !sb_lines) return; // not enuff room - teamplay = atoi (Info_ValueForKey (cl.serverinfo, "teamplay")); - scr_copyeverything = 1; scr_fullupdate = 0; @@ -1131,15 +1123,15 @@ Sbar_MiniDeathmatchOverlay (void) Draw_Character (x + 32, y, 17); } // team - if (teamplay) { + if (cl.teamplay) { team[4] = 0; - strncpy (team, Info_ValueForKey (s->userinfo, "team"), 4); - Draw_String (x + 48, y, team); + strncpy (team, s->team->value, 4); + Draw_String (x + 48, y, s->team->value); } // draw name name[16] = 0; strncpy (name, s->name, 16); - if (teamplay) + if (cl.teamplay) Draw_String (x + 48 + 40, y, name); else Draw_String (x + 48, y, name); @@ -1147,7 +1139,7 @@ Sbar_MiniDeathmatchOverlay (void) } // draw teams if room - if (vid.width < 640 || !teamplay) + if (vid.width < 640 || !cl.teamplay) return; // draw separator @@ -1172,8 +1164,7 @@ Sbar_MiniDeathmatchOverlay (void) snprintf (num, sizeof (num), "%5i", tm->frags); Draw_String (x + 40, y, num); - if (!strncmp (Info_ValueForKey (cl.players[cl.playernum].userinfo, - "team"), tm->team, 16)) { + if (strnequal (cl.players[cl.playernum].team->value, tm->team, 16)) { Draw_Character (x - 8, y, 16); Draw_Character (x + 32, y, 17); } @@ -1189,8 +1180,8 @@ Sbar_IntermissionOverlay (void) scr_copyeverything = 1; scr_fullupdate = 0; - if (atoi (Info_ValueForKey (cl.serverinfo, "teamplay")) > 0 - && !sb_showscores) Sbar_TeamOverlay (); + if (cl.teamplay > 0 && !sb_showscores) + Sbar_TeamOverlay (); else Sbar_DeathmatchOverlay (0); } diff --git a/qw/source/skin.c b/qw/source/skin.c index 46912ace3..14c729045 100644 --- a/qw/source/skin.c +++ b/qw/source/skin.c @@ -91,7 +91,7 @@ Skin_Find (player_info_t *sc) if (allskins[0]) { strncpy (name, allskins, sizeof (name)); } else { - if ((s = Info_ValueForKey (sc->userinfo, "skin")) && s[0]) + if ((s = sc->skinname->value) && s[0]) strncpy (name, s, sizeof (name)); else strncpy (name, baseskin->string, sizeof (name));