From edadc9e8a60ccfbbed9c53fe075fd69c3c6b24a0 Mon Sep 17 00:00:00 2001 From: div0 Date: Sat, 26 Jul 2008 16:30:49 +0000 Subject: [PATCH] add team scores display; csqc .team is NOT svqc .team, that sucks! (csqc .team is always svqc .team minus one) git-svn-id: svn://svn.icculus.org/nexuiz/trunk@3925 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/client/sbar.qc | 25 ++++++++++++++++++------- data/qcsrc/server/scores.qc | 8 +++++--- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/data/qcsrc/client/sbar.qc b/data/qcsrc/client/sbar.qc index 9a2453133..a3a95a114 100644 --- a/data/qcsrc/client/sbar.qc +++ b/data/qcsrc/client/sbar.qc @@ -237,6 +237,11 @@ void Sbar_UpdatePlayerPos(entity player) float Sbar_CompareTeamScores(entity left, entity right) { float vl, vr; + + if(left.team == COLOR_SPECTATOR) + return 1; + if(right.team == COLOR_SPECTATOR) + return 0; vl = left.teamscores[ts_primary]; vr = right.teamscores[ts_primary]; @@ -257,13 +262,11 @@ float Sbar_CompareTeamScores(entity left, entity right) void Sbar_UpdateTeamPos(entity Team) { - for(other = Team.sort_next; other && Sbar_ComparePlayerScores(Team, other); other = Team.sort_next) + for(other = Team.sort_next; other && Sbar_CompareTeamScores(Team, other); other = Team.sort_next) { - if(other.team == COLOR_SPECTATOR) - break; SORT_SWAP(Team, other); } - for(other = Team.sort_prev; other != teams && Sbar_ComparePlayerScores(other, Team); other = Team.sort_prev) + for(other = Team.sort_prev; other != teams && Sbar_CompareTeamScores(other, Team); other = Team.sort_prev) { SORT_SWAP(other, Team); } @@ -700,11 +703,19 @@ void Sbar_DrawScoreboard() rgb = GetTeamRGB(tm.team); - pos_x = xmin - 4*24; - // TODO: Print primary and secondary scores! - pos_x = xmin; + Sbar_DrawXNum( + pos - '6.5 0 0' * sbar_fontsize_y, + tm.(teamscores[ts_primary]), + 4, sbar_fontsize_y * 1.5, rgb, 1, DRAWFLAG_NORMAL); + + if(ts_primary != ts_secondary) + Sbar_DrawXNum( + pos - '4.5 0 0' * sbar_fontsize_y + '0 1.5 0' * sbar_fontsize_y, + tm.(teamscores[ts_secondary]), + 4, sbar_fontsize_y * 1, rgb, 1, DRAWFLAG_NORMAL); + specs = tm.team_size; if(specs < 2) diff --git a/data/qcsrc/server/scores.qc b/data/qcsrc/server/scores.qc index 7ddb57aaf..a7d235a70 100644 --- a/data/qcsrc/server/scores.qc +++ b/data/qcsrc/server/scores.qc @@ -46,7 +46,7 @@ float TeamScore_SendEntity(entity to) float i; WriteByte(MSG_ENTITY, ENT_CLIENT_TEAMSCORES); - WriteByte(MSG_ENTITY, self.team); + WriteByte(MSG_ENTITY, self.team - 1); for(i = 0; i < MAX_TEAMSCORE; ++i) WriteShort(MSG_ENTITY, self.teamscores[i]); @@ -63,7 +63,7 @@ void TeamScore_Spawn(float t, string name) ts.Version = 1; // immediately send, so csqc knows about the team ts.team = t; Net_LinkEntity(ts); - teamscorekeepers[t] = ts; + teamscorekeepers[t - 1] = ts; ++teamscores_entities_count; } @@ -71,7 +71,9 @@ float TeamScore_AddToTeam(float t, float scorefield, float score) { entity s; if(!scores_initialized) return 0; // FIXME remove this when everything uses this system - s = teamscorekeepers[t]; + if(t <= 0 || t >= 16) + error("Adding score to invalid team!"); + s = teamscorekeepers[t - 1]; if(!s) error("Adding score to unknown team!"); if(score) -- 2.39.2