From 61bd69dc7a8e218b6beff349fd332eb7ac8a81ae Mon Sep 17 00:00:00 2001 From: TimePath Date: Sun, 3 Apr 2016 21:30:43 +1000 Subject: [PATCH] Register score fields --- qcsrc/client/hud/hud.qh | 2 +- qcsrc/client/hud/panel/infomessages.qc | 4 +- qcsrc/client/hud/panel/modicons.qc | 4 +- qcsrc/client/hud/panel/score.qc | 22 +- qcsrc/client/main.qc | 51 ++-- qcsrc/client/main.qh | 27 +- qcsrc/client/scoreboard.qc | 158 +++++----- qcsrc/common/constants.qh | 108 ++++++- .../gamemodes/gamemode/nexball/nexball.qc | 4 +- .../gamemodes/gamemode/onslaught/onslaught.qc | 4 +- qcsrc/server/defs.qh | 2 +- qcsrc/server/g_damage.qc | 2 +- qcsrc/server/g_damage.qh | 2 +- qcsrc/server/mutators/events.qh | 4 +- .../mutators/mutator/gamemode_assault.qc | 1 - qcsrc/server/mutators/mutator/gamemode_ctf.qc | 16 +- qcsrc/server/mutators/mutator/gamemode_ctf.qh | 6 - qcsrc/server/mutators/mutator/gamemode_cts.qc | 3 - .../mutators/mutator/gamemode_domination.qc | 3 - .../mutators/mutator/gamemode_freezetag.qc | 1 - .../mutators/mutator/gamemode_keepaway.qc | 10 +- .../mutators/mutator/gamemode_keyhunt.qc | 18 +- qcsrc/server/mutators/mutator/gamemode_lms.qc | 4 - .../server/mutators/mutator/gamemode_race.qc | 2 +- qcsrc/server/race.qh | 3 - qcsrc/server/scores.qc | 270 +++++++++--------- qcsrc/server/scores.qh | 10 +- qcsrc/server/scores_rules.qc | 10 +- 28 files changed, 382 insertions(+), 369 deletions(-) diff --git a/qcsrc/client/hud/hud.qh b/qcsrc/client/hud/hud.qh index d46b11db5..008ef543d 100644 --- a/qcsrc/client/hud/hud.qh +++ b/qcsrc/client/hud/hud.qh @@ -81,7 +81,7 @@ int complain_weapon; float complain_weapon_type; float complain_weapon_time; -int ps_primary, ps_secondary; +PlayerScoreField ps_primary, ps_secondary; int ts_primary, ts_secondary; Weapon last_switchweapon; diff --git a/qcsrc/client/hud/panel/infomessages.qc b/qcsrc/client/hud/panel/infomessages.qc index 8199bd8dd..07c0b5271 100644 --- a/qcsrc/client/hud/panel/infomessages.qc +++ b/qcsrc/client/hud/panel/infomessages.qc @@ -89,9 +89,9 @@ void HUD_InfoMessages() { entity sk; sk = playerslots[player_localnum]; - if(sk.(scores[ps_primary]) >= 666) + if(sk.(scores(ps_primary)) >= 666) s = _("^1Match has already begun"); - else if(sk.(scores[ps_primary]) > 0) + else if(sk.(scores(ps_primary)) > 0) s = _("^1You have no more lives left"); else s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump")); diff --git a/qcsrc/client/hud/panel/modicons.qc b/qcsrc/client/hud/panel/modicons.qc index 5b4665f56..cb7930786 100644 --- a/qcsrc/client/hud/panel/modicons.qc +++ b/qcsrc/client/hud/panel/modicons.qc @@ -518,9 +518,9 @@ void HUD_Mod_Race(vector pos, vector mySize) entity me; me = playerslots[player_localnum]; float score; - score = me.(scores[ps_primary]); + score = me.(scores(ps_primary)); - if(!(scores_flags[ps_primary] & SFL_TIME) || teamplay) // race/cts record display on HUD + if(!(scores_flags(ps_primary) & SFL_TIME) || teamplay) // race/cts record display on HUD return; // no records in the actual race // clientside personal record diff --git a/qcsrc/client/hud/panel/score.qc b/qcsrc/client/hud/panel/score.qc index 12114b4e3..094182fa1 100644 --- a/qcsrc/client/hud/panel/score.qc +++ b/qcsrc/client/hud/panel/score.qc @@ -84,7 +84,7 @@ void HUD_Score_Rankings(vector pos, vector mySize, entity me) continue; if (tm.team == myteam) drawfill(pos + eX * score_size * i, eX * score_size + eY * fontsize.y, '1 1 1', highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(pos + eX * score_size * i, ftos(tm.(teamscores[ts_primary])), eX * score_size + eY * fontsize.y, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(pos + eX * score_size * i, ftos(tm.(teamscores(ts_primary))), eX * score_size + eY * fontsize.y, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL); ++i; } first_pl = 1; @@ -124,7 +124,7 @@ void HUD_Score_Rankings(vector pos, vector mySize, entity me) score_color = Team_ColorRGB(pl.team) * 0.8; s = textShortenToWidth(entcs_GetName(pl.sv_entnum), name_size, fontsize, stringwidth_colors); drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, true, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring(pos + eX * (name_size + spacing_size), ftos(pl.(scores[ps_primary])), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring(pos + eX * (name_size + spacing_size), ftos(pl.(scores(ps_primary))), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL); pos.y += fontsize.y; ++i; } @@ -158,23 +158,23 @@ void HUD_Score() me = playerslots[current_player]; - if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD + if((scores_flags(ps_primary) & SFL_TIME) && !teamplay) { // race/cts record display on HUD string timer, distrtimer; pl = players.sort_next; if(pl == me) pl = pl.sort_next; - if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST) - if(pl.scores[ps_primary] == 0) + if(scores_flags(ps_primary) & SFL_ZERO_IS_WORST) + if(pl.scores(ps_primary) == 0) pl = world; - score = me.(scores[ps_primary]); + score = me.(scores(ps_primary)); timer = TIME_ENCODED_TOSTRING(score); draw_beginBoldFont(); - if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) { + if (pl && ((!(scores_flags(ps_primary) & SFL_ZERO_IS_WORST)) || score)) { // distribution display - distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]); + distribution = me.(scores(ps_primary)) - pl.(scores(ps_primary)); distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS); @@ -207,11 +207,11 @@ void HUD_Score() if(autocvar__hud_configure) distribution = 42; else if(pl) - distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]); + distribution = me.(scores(ps_primary)) - pl.(scores(ps_primary)); else distribution = 0; - score = me.(scores[ps_primary]); + score = me.(scores(ps_primary)); if(autocvar__hud_configure) score = 123; @@ -279,7 +279,7 @@ void HUD_Score() continue; if(!tm.team && teamplay) continue; - score = tm.(teamscores[ts_primary]); + score = tm.(teamscores(ts_primary)); if(autocvar__hud_configure) score = 123; diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 98b266c6d..c845a7d34 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -399,23 +399,21 @@ void Ent_RemovePlayerScore(entity this) if(this.owner) { SetTeam(this.owner, -1); this.owner.gotscores = 0; - for(int i = 0; i < MAX_SCORE; ++i) { - this.owner.(scores[i]) = 0; // clear all scores - } + FOREACH(Scores, true, { + this.owner.(scores(it)) = 0; // clear all scores + }); } } NET_HANDLE(ENT_CLIENT_SCORES, bool isnew) { make_pure(this); - int i, n; - bool isNew; entity o; // damnit -.- don't want to go change every single .sv_entnum in hud.qc AGAIN // (no I've never heard of M-x replace-string, sed, or anything like that) - isNew = !this.owner; // workaround for DP bug - n = ReadByte()-1; + bool isNew = !this.owner; // workaround for DP bug + int n = ReadByte()-1; #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED if(!isNew && n != this.sv_entnum) @@ -443,22 +441,18 @@ NET_HANDLE(ENT_CLIENT_SCORES, bool isnew) //playerchecker will do this for us later, if it has not already done so int sf, lf; -#if MAX_SCORE <= 8 - sf = ReadByte(); - lf = ReadByte(); -#else sf = ReadShort(); lf = ReadShort(); -#endif - int p; - for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2) - if(sf & p) + FOREACH(Scores, true, { + int p = 1 << (i % 16); + if (sf & p) { - if(lf & p) - o.(scores[i]) = ReadInt24_t(); + if (lf & p) + o.(scores(it)) = ReadInt24_t(); else - o.(scores[i]) = ReadChar(); + o.(scores(it)) = ReadChar(); } + }); return = true; @@ -490,9 +484,9 @@ NET_HANDLE(ENT_CLIENT_TEAMSCORES, bool isnew) if(sf & p) { if(lf & p) - o.(teamscores[i]) = ReadInt24_t(); + o.(teamscores(i)) = ReadInt24_t(); else - o.(teamscores[i]) = ReadChar(); + o.(teamscores(i)) = ReadChar(); } return = true; @@ -952,17 +946,16 @@ NET_HANDLE(ENT_CLIENT_SCORES_INFO, bool isnew) make_pure(this); gametype = ReadInt24_t(); HUD_ModIcons_SetFunc(); - for (int i = 0; i < MAX_SCORE; ++i) - { - if (scores_label[i]) strunzone(scores_label[i]); - scores_label[i] = strzone(ReadString()); - scores_flags[i] = ReadByte(); - } + FOREACH(Scores, true, { + if (scores_label(it)) strunzone(scores_label(it)); + scores_label(it) = strzone(ReadString()); + scores_flags(it) = ReadByte(); + }); for (int i = 0; i < MAX_TEAMSCORE; ++i) { - if (teamscores_label[i]) strunzone(teamscores_label[i]); - teamscores_label[i] = strzone(ReadString()); - teamscores_flags[i] = ReadByte(); + if (teamscores_label(i)) strunzone(teamscores_label(i)); + teamscores_label(i) = strzone(ReadString()); + teamscores_flags(i) = ReadByte(); } return = true; HUD_InitScores(); diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index 9d7c40689..033bfdcf0 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -42,36 +42,13 @@ void LoadMenuSkinValues(); // -------------------------------------------------------------------------- // Scoreboard stuff -const int MAX_HUD_FIELDS = 16; +const int MAX_HUD_FIELDS = 64; -const int SP_END = -1; - -const int SP_PING = -2; -const int SP_NAME = -3; -const int SP_KDRATIO = -4; -const int SP_CLRATIO = -5; -const int SP_PL = -6; -const int SP_FRAGS = -7; -const int SP_SUM = -8; - -const int SP_SEPARATOR = -100; - -float hud_field[MAX_HUD_FIELDS + 1]; +PlayerScoreField hud_field[MAX_HUD_FIELDS + 1]; float hud_size[MAX_HUD_FIELDS + 1]; string hud_title[MAX_HUD_FIELDS + 1]; int hud_num_fields; -string scores_label[MAX_SCORE]; -int scores_flags[MAX_SCORE]; -string teamscores_label[MAX_SCORE]; -int teamscores_flags[MAX_SCORE]; -.int scores[MAX_SCORE]; -.float teamscores[MAX_TEAMSCORE]; - -#define IS_INCREASING(x) ( (x)&SFL_LOWER_IS_BETTER ) -#define IS_DECREASING(x) ( !((x)&SFL_LOWER_IS_BETTER) ) - - vector hud_fontsize; float RANKINGS_RECEIVED_CNT; diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc index cf43e7c1d..78846d69c 100644 --- a/qcsrc/client/scoreboard.qc +++ b/qcsrc/client/scoreboard.qc @@ -72,21 +72,21 @@ void HUD_InitScores() { int i, f; - ps_primary = ps_secondary = ts_primary = ts_secondary = -1; - for(i = 0; i < MAX_SCORE; ++i) - { - f = (scores_flags[i] & SFL_SORT_PRIO_MASK); + ps_primary = ps_secondary = NULL; + ts_primary = ts_secondary = -1; + FOREACH(Scores, true, { + f = (scores_flags(it) & SFL_SORT_PRIO_MASK); if(f == SFL_SORT_PRIO_PRIMARY) - ps_primary = i; + ps_primary = it; if(f == SFL_SORT_PRIO_SECONDARY) - ps_secondary = i; - } - if(ps_secondary == -1) + ps_secondary = it; + }); + if(ps_secondary == NULL) ps_secondary = ps_primary; for(i = 0; i < MAX_TEAMSCORE; ++i) { - f = (teamscores_flags[i] & SFL_SORT_PRIO_MASK); + f = (teamscores_flags(i) & SFL_SORT_PRIO_MASK); if(f == SFL_SORT_PRIO_PRIMARY) ts_primary = i; if(f == SFL_SORT_PRIO_SECONDARY) @@ -170,21 +170,18 @@ float HUD_ComparePlayerScores(entity left, entity right) return false; } - r = HUD_CompareScore(left.scores[ps_primary], right.scores[ps_primary], scores_flags[ps_primary]); + r = HUD_CompareScore(left.scores(ps_primary), right.scores(ps_primary), scores_flags(ps_primary)); if (r >= 0) return r; - r = HUD_CompareScore(left.scores[ps_secondary], right.scores[ps_secondary], scores_flags[ps_secondary]); + r = HUD_CompareScore(left.scores(ps_secondary), right.scores(ps_secondary), scores_flags(ps_secondary)); if (r >= 0) return r; - int i; - for(i = 0; i < MAX_SCORE; ++i) - { - r = HUD_CompareScore(left.scores[i], right.scores[i], scores_flags[i]); - if (r >= 0) - return r; - } + FOREACH(Scores, true, { + r = HUD_CompareScore(left.scores(it), right.scores(it), scores_flags(it)); + if (r >= 0) return r; + }); if (left.sv_entnum < right.sv_entnum) return true; @@ -213,17 +210,17 @@ float HUD_CompareTeamScores(entity left, entity right) if(right.team == NUM_SPECTATOR) return 0; - r = HUD_CompareScore(left.teamscores[ts_primary], right.teamscores[ts_primary], teamscores_flags[ts_primary]); + r = HUD_CompareScore(left.teamscores(ts_primary), right.teamscores(ts_primary), teamscores_flags(ts_primary)); if (r >= 0) return r; - r = HUD_CompareScore(left.teamscores[ts_secondary], right.teamscores[ts_secondary], teamscores_flags[ts_secondary]); + r = HUD_CompareScore(left.teamscores(ts_secondary), right.teamscores(ts_secondary), teamscores_flags(ts_secondary)); if (r >= 0) return r; - for(i = 0; i < MAX_SCORE; ++i) + for(i = 0; i < MAX_TEAMSCORE; ++i) { - r = HUD_CompareScore(left.teamscores[i], right.teamscores[i], teamscores_flags[i]); + r = HUD_CompareScore(left.teamscores(i), right.teamscores(i), teamscores_flags(i)); if (r >= 0) return r; } @@ -325,7 +322,7 @@ void Cmd_HUD_Help() void Cmd_HUD_SetFields(int argc) { TC(int, argc); - int i, j, slash; + int i, slash; string str, pattern; float have_name = 0, have_primary = 0, have_secondary = 0, have_separator = 0; float missing; @@ -335,9 +332,9 @@ void Cmd_HUD_SetFields(int argc) // set up a temporary scoreboard layout // no layout can be properly set up until score_info data haven't been received argc = tokenizebyseparator("0 1 ping pl name | score", " "); - ps_primary = 0; - scores_label[ps_primary] = strzone("score"); - scores_flags[ps_primary] = SFL_ALLOW_HIDE; + ps_primary = SP_SCORE; + scores_label(ps_primary) = strzone("score"); + scores_flags(ps_primary) = SFL_ALLOW_HIDE; } // TODO: re enable with gametype dependant cvars? @@ -355,16 +352,15 @@ void Cmd_HUD_SetFields(int argc) { string s; s = "ping pl name |"; - for(i = 0; i < MAX_SCORE; ++i) - { - if(i != ps_primary) - if(i != ps_secondary) - if(scores_label[i] != "") - s = strcat(s, " ", scores_label[i]); - } + FOREACH(Scores, true, { + if(it != ps_primary) + if(it != ps_secondary) + if(scores_label(it) != "") + s = strcat(s, " ", scores_label(it)); + }); if(ps_secondary != ps_primary) - s = strcat(s, " ", scores_label[ps_secondary]); - s = strcat(s, " ", scores_label[ps_primary]); + s = strcat(s, " ", scores_label(ps_secondary)); + s = strcat(s, " ", scores_label(ps_primary)); argc = tokenizebyseparator(strcat("0 1 ", s), " "); } } @@ -401,6 +397,7 @@ void Cmd_HUD_SetFields(int argc) hud_size[hud_num_fields] = stringwidth(hud_title[hud_num_fields], false, hud_fontsize); str = strtolower(str); + PlayerScoreField j; switch(str) { case "ping": hud_field[hud_num_fields] = SP_PING; break; @@ -413,9 +410,12 @@ void Cmd_HUD_SetFields(int argc) case "dmgtaken": hud_field[hud_num_fields] = SP_DMGTAKEN; break; default: { - for(j = 0; j < MAX_SCORE; ++j) - if(str == strtolower(scores_label[j])) + FOREACH(Scores, true, { + if (str == strtolower(scores_label(it))) { + j = it; goto found; // sorry, but otherwise fteqcc -O3 miscompiles this and warns about "unreachable code" + } + }); LABEL(notfound) if(str == "frags") @@ -440,9 +440,9 @@ LABEL(found) break; } - if(scores_flags[ps_primary] & SFL_ALLOW_HIDE) + if(scores_flags(ps_primary) & SFL_ALLOW_HIDE) have_primary = 1; - if(scores_flags[ps_secondary] & SFL_ALLOW_HIDE) + if(scores_flags(ps_secondary) & SFL_ALLOW_HIDE) have_secondary = 1; if(ps_primary == ps_secondary) have_secondary = 1; @@ -492,20 +492,20 @@ LABEL(found) if(!have_secondary) { strunzone(hud_title[hud_num_fields]); - hud_title[hud_num_fields] = strzone(TranslateScoresLabel(scores_label[ps_secondary])); + hud_title[hud_num_fields] = strzone(TranslateScoresLabel(scores_label(ps_secondary))); hud_size[hud_num_fields] = stringwidth(hud_title[hud_num_fields], false, hud_fontsize); hud_field[hud_num_fields] = ps_secondary; ++hud_num_fields; - LOG_INFOF("fixed missing field '%s'\n", scores_label[ps_secondary]); + LOG_INFOF("fixed missing field '%s'\n", scores_label(ps_secondary)); } if(!have_primary) { strunzone(hud_title[hud_num_fields]); - hud_title[hud_num_fields] = strzone(TranslateScoresLabel(scores_label[ps_primary])); + hud_title[hud_num_fields] = strzone(TranslateScoresLabel(scores_label(ps_primary))); hud_size[hud_num_fields] = stringwidth(hud_title[hud_num_fields], false, hud_fontsize); hud_field[hud_num_fields] = ps_primary; ++hud_num_fields; - LOG_INFOF("fixed missing field '%s'\n", scores_label[ps_primary]); + LOG_INFOF("fixed missing field '%s'\n", scores_label(ps_primary)); } } @@ -523,9 +523,8 @@ vector hud_field_icon2_rgb; float hud_field_icon0_alpha; float hud_field_icon1_alpha; float hud_field_icon2_alpha; -string HUD_GetField(entity pl, int field) +string HUD_GetField(entity pl, PlayerScoreField field) { - TC(int, field); float tmp, num, denom; int f; string str; @@ -585,13 +584,13 @@ string HUD_GetField(entity pl, int field) return entcs_GetName(pl.sv_entnum); case SP_FRAGS: - f = pl.(scores[SP_KILLS]); - f -= pl.(scores[SP_SUICIDES]); + f = pl.(scores(SP_KILLS)); + f -= pl.(scores(SP_SUICIDES)); return ftos(f); case SP_KDRATIO: - num = pl.(scores[SP_KILLS]); - denom = pl.(scores[SP_DEATHS]); + num = pl.(scores(SP_KILLS)); + denom = pl.(scores(SP_DEATHS)); if(denom == 0) { hud_field_rgb = '0 1 0'; @@ -604,8 +603,8 @@ string HUD_GetField(entity pl, int field) return str; case SP_SUM: - f = pl.(scores[SP_KILLS]); - f -= pl.(scores[SP_DEATHS]); + f = pl.(scores(SP_KILLS)); + f -= pl.(scores(SP_DEATHS)); if(f > 0) { hud_field_rgb = '0 1 0'; @@ -617,22 +616,22 @@ string HUD_GetField(entity pl, int field) return ftos(f); case SP_DMG: - num = pl.(scores[SP_DMG]); + num = pl.(scores(SP_DMG)); denom = 1000; str = sprintf("%.1f k", num/denom); return str; case SP_DMGTAKEN: - num = pl.(scores[SP_DMGTAKEN]); + num = pl.(scores(SP_DMGTAKEN)); denom = 1000; str = sprintf("%.1f k", num/denom); return str; default: - tmp = pl.(scores[field]); - f = scores_flags[field]; + tmp = pl.(scores(field)); + f = scores_flags(field); if(field == ps_primary) hud_field_rgb = '1 1 0'; else if(field == ps_secondary) @@ -651,9 +650,9 @@ float hud_fixscoreboardcolumnwidth_marginlen; string HUD_FixScoreboardColumnWidth(int i, string str) { TC(int, i); - float field, f; + float f; vector sz; - field = hud_field[i]; + PlayerScoreField field = hud_field[i]; hud_fixscoreboardcolumnwidth_iconlen = 0; @@ -718,12 +717,10 @@ string HUD_FixScoreboardColumnWidth(int i, string str) void HUD_PrintScoreboardItem(vector pos, vector item_size, entity pl, bool is_self, int pl_number) { TC(bool, is_self); TC(int, pl_number); - vector tmp, rgb; - rgb = Team_ColorRGB(pl.team); + vector tmp; + vector rgb = Team_ColorRGB(pl.team); string str; - int field; - float is_spec; - is_spec = (entcs_GetTeam(pl.sv_entnum) == NUM_SPECTATOR); + bool is_spec = (entcs_GetTeam(pl.sv_entnum) == NUM_SPECTATOR); if((rgb == '1 1 1') && (!is_spec)) { rgb.x = autocvar_scoreboard_color_bg_r + 0.5; @@ -742,6 +739,7 @@ void HUD_PrintScoreboardItem(vector pos, vector item_size, entity pl, bool is_se tmp.y = 0; tmp.z = 0; int i; + PlayerScoreField field; for(i = 0; i < hud_num_fields; ++i) { field = hud_field[i]; @@ -1330,12 +1328,12 @@ void HUD_DrawScoreboard() draw_beginBoldFont(); rgb = Team_ColorRGB(tm.team); - str = ftos(tm.(teamscores[ts_primary])); + str = ftos(tm.(teamscores(ts_primary))); drawstring(pos + team_score_baseoffset - eX * stringwidth(str, false, hud_fontsize * 1.5), str, hud_fontsize * 1.5, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL); if(ts_primary != ts_secondary) { - str = ftos(tm.(teamscores[ts_secondary])); + str = ftos(tm.(teamscores(ts_secondary))); drawstring(pos + team_score_baseoffset - eX * stringwidth(str, false, hud_fontsize) + eY * hud_fontsize.y * 1.5, str, hud_fontsize, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL); } draw_endBoldFont(); @@ -1433,17 +1431,17 @@ void HUD_DrawScoreboard() str = strcat(str, _(" or")); if(teamplay) { - str = strcat(str, sprintf(_(" until ^3%s %s^7"), ScoreString(teamscores_flags[ts_primary], fl), - (teamscores_label[ts_primary] == "score") ? CTX(_("SCO^points")) : - (teamscores_label[ts_primary] == "fastest") ? CTX(_("SCO^is beaten")) : - TranslateScoresLabel(teamscores_label[ts_primary]))); + str = strcat(str, sprintf(_(" until ^3%s %s^7"), ScoreString(teamscores_flags(ts_primary), fl), + (teamscores_label(ts_primary) == "score") ? CTX(_("SCO^points")) : + (teamscores_label(ts_primary) == "fastest") ? CTX(_("SCO^is beaten")) : + TranslateScoresLabel(teamscores_label(ts_primary)))); } else { - str = strcat(str, sprintf(_(" until ^3%s %s^7"), ScoreString(scores_flags[ps_primary], fl), - (scores_label[ps_primary] == "score") ? CTX(_("SCO^points")) : - (scores_label[ps_primary] == "fastest") ? CTX(_("SCO^is beaten")) : - TranslateScoresLabel(scores_label[ps_primary]))); + str = strcat(str, sprintf(_(" until ^3%s %s^7"), ScoreString(scores_flags(ps_primary), fl), + (scores_label(ps_primary) == "score") ? CTX(_("SCO^points")) : + (scores_label(ps_primary) == "fastest") ? CTX(_("SCO^is beaten")) : + TranslateScoresLabel(scores_label(ps_primary)))); } } if(ll > 0) @@ -1452,17 +1450,17 @@ void HUD_DrawScoreboard() str = strcat(str, _(" or")); if(teamplay) { - str = strcat(str, sprintf(_(" until a lead of ^3%s %s^7"), ScoreString(teamscores_flags[ts_primary], ll), - (teamscores_label[ts_primary] == "score") ? CTX(_("SCO^points")) : - (teamscores_label[ts_primary] == "fastest") ? CTX(_("SCO^is beaten")) : - TranslateScoresLabel(teamscores_label[ts_primary]))); + str = strcat(str, sprintf(_(" until a lead of ^3%s %s^7"), ScoreString(teamscores_flags(ts_primary), ll), + (teamscores_label(ts_primary) == "score") ? CTX(_("SCO^points")) : + (teamscores_label(ts_primary) == "fastest") ? CTX(_("SCO^is beaten")) : + TranslateScoresLabel(teamscores_label(ts_primary)))); } else { - str = strcat(str, sprintf(_(" until a lead of ^3%s %s^7"), ScoreString(scores_flags[ps_primary], ll), - (scores_label[ps_primary] == "score") ? CTX(_("SCO^points")) : - (scores_label[ps_primary] == "fastest") ? CTX(_("SCO^is beaten")) : - TranslateScoresLabel(scores_label[ps_primary]))); + str = strcat(str, sprintf(_(" until a lead of ^3%s %s^7"), ScoreString(scores_flags(ps_primary), ll), + (scores_label(ps_primary) == "score") ? CTX(_("SCO^points")) : + (scores_label(ps_primary) == "fastest") ? CTX(_("SCO^is beaten")) : + TranslateScoresLabel(scores_label(ps_primary)))); } } } diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 28db23dc1..3011cd256 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -123,19 +123,111 @@ const int SFL_SORT_PRIO_SECONDARY = 4; const int SFL_SORT_PRIO_PRIMARY = 8; const int SFL_SORT_PRIO_MASK = 12; -/** +/* * Score indices */ -#define MAX_SCORE 12 + +#ifndef MENUQC + +#define IS_INCREASING(x) ( (x) & SFL_LOWER_IS_BETTER ) +#define IS_DECREASING(x) ( !((x) & SFL_LOWER_IS_BETTER) ) + + +#define MAX_SCORE 64 + +#define REGISTER_SP(id) REGISTER(Scores, SP, id, m_id, new_pure(PlayerScoreField)) +REGISTRY(Scores, MAX_SCORE); +#define Scores_from(i) _Scores_from(i, NULL) +REGISTER_REGISTRY(Scores) +REGISTRY_SORT(Scores); +REGISTRY_CHECK(Scores); +STATIC_INIT(Scores_renumber) { FOREACH(Scores, true, it.m_id = i); } + +USING(PlayerScoreField, entity); +.int _scores[MAX_SCORE]; +.string m_name; +.int m_flags; + +#define scores(this) _scores[(this).m_id] +#define scores_label(this) ((this).m_name) +#define scores_flags(this) ((this).m_flags) + +REGISTER_SP(END); + +REGISTER_SP(PING); +REGISTER_SP(NAME); +REGISTER_SP(KDRATIO); +REGISTER_SP(CLRATIO); +REGISTER_SP(PL); +REGISTER_SP(SUM); + +REGISTER_SP(SEPARATOR); + +REGISTER_SP(SCORE); + +REGISTER_SP(DMG); +REGISTER_SP(DMGTAKEN); + +REGISTER_SP(KILLS); +REGISTER_SP(DEATHS); +REGISTER_SP(SUICIDES); +REGISTER_SP(FRAGS); + +REGISTER_SP(RACE_TIME); +REGISTER_SP(RACE_LAPS); +REGISTER_SP(RACE_FASTEST); + +REGISTER_SP(CTS_TIME); +REGISTER_SP(CTS_LAPS); +REGISTER_SP(CTS_FASTEST); + +REGISTER_SP(ASSAULT_OBJECTIVES); + +REGISTER_SP(CTF_PICKUPS); +REGISTER_SP(CTF_FCKILLS); +REGISTER_SP(CTF_RETURNS); +REGISTER_SP(CTF_CAPS); +REGISTER_SP(CTF_CAPTIME); +REGISTER_SP(CTF_DROPS); + +REGISTER_SP(DOM_TAKES); +REGISTER_SP(DOM_TICKS); + +REGISTER_SP(FREEZETAG_REVIVALS); + +REGISTER_SP(KEEPAWAY_PICKUPS); +REGISTER_SP(KEEPAWAY_BCTIME); +REGISTER_SP(KEEPAWAY_CARRIERKILLS); + +REGISTER_SP(KH_PICKUPS); +REGISTER_SP(KH_CAPS); +REGISTER_SP(KH_KCKILLS); +REGISTER_SP(KH_PUSHES); +REGISTER_SP(KH_DESTROYS); +REGISTER_SP(KH_LOSSES); + +REGISTER_SP(LMS_RANK); +REGISTER_SP(LMS_LIVES); + +REGISTER_SP(NEXBALL_GOALS); +REGISTER_SP(NEXBALL_FAULTS); + +REGISTER_SP(ONS_TAKES); +REGISTER_SP(ONS_CAPS); + #define MAX_TEAMSCORE 2 +USING(ScoreTeam, string); +.int _teamscores[MAX_TEAMSCORE]; +#define teamscores(i) _teamscores[i] +string _teamscores_label[MAX_TEAMSCORE]; +#define teamscores_label(i) _teamscores_label[i] +int _teamscores_flags[MAX_TEAMSCORE]; +#define teamscores_flags(i) _teamscores_flags[i] + +#endif const int ST_SCORE = 0; -const int SP_KILLS = 0; -const int SP_DEATHS = 1; -const int SP_SUICIDES = 2; -const int SP_SCORE = 3; -const int SP_DMG = 10; -const int SP_DMGTAKEN = 11; + // game mode specific indices are not in common/, but in server/scores_rules.qc! // WEAPONTODO: move this into separate/new projectile handling code // this sets sounds and other properties of the projectiles in csqc diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index 1d500c1a6..ddc016825 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -56,13 +56,11 @@ float OtherTeam(float t) //works only if there are two teams on the map! } const float ST_NEXBALL_GOALS = 1; -const float SP_NEXBALL_GOALS = 4; -const float SP_NEXBALL_FAULTS = 5; void nb_ScoreRules(float teams) { ScoreRules_basics(teams, 0, 0, true); ScoreInfo_SetLabel_TeamScore( ST_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY); - ScoreInfo_SetLabel_PlayerScore( SP_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY); + ScoreInfo_SetLabel_PlayerScore(SP_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY); ScoreInfo_SetLabel_PlayerScore(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER); ScoreRules_basics_end(); } diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc index 5271beba1..18241145a 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc @@ -120,8 +120,6 @@ void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org // score rule declarations const int ST_ONS_CAPS = 1; -const int SP_ONS_CAPS = 4; -const int SP_ONS_TAKES = 6; #endif #endif @@ -2248,7 +2246,7 @@ void ons_ScoreRules() CheckAllowedTeams(world); ScoreRules_basics(((c4>=0) ? 4 : (c3>=0) ? 3 : 2), SFL_SORT_PRIO_PRIMARY, 0, true); ScoreInfo_SetLabel_TeamScore (ST_ONS_CAPS, "destroyed", SFL_SORT_PRIO_PRIMARY); - ScoreInfo_SetLabel_PlayerScore(SP_ONS_CAPS, "caps", SFL_SORT_PRIO_SECONDARY); + ScoreInfo_SetLabel_PlayerScore(SP_ONS_CAPS, "caps", SFL_SORT_PRIO_SECONDARY); ScoreInfo_SetLabel_PlayerScore(SP_ONS_TAKES, "takes", 0); ScoreRules_basics_end(); } diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 7124e4468..191038710 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -35,7 +35,7 @@ float player_count; float currentbots; float bots_would_leave; -void UpdateFrags(entity player, float f); +void UpdateFrags(entity player, int f); .float totalfrags; float team1_score, team2_score, team3_score, team4_score; diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index 208ae62e5..dad52d685 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -25,7 +25,7 @@ #include "../lib/csqcmodel/sv_model.qh" #include "../lib/warpzone/common.qh" -void UpdateFrags(entity player, float f) +void UpdateFrags(entity player, int f) { PlayerTeamScore_AddScore(player, f); } diff --git a/qcsrc/server/g_damage.qh b/qcsrc/server/g_damage.qh index ca5c45b9e..584a24ce4 100644 --- a/qcsrc/server/g_damage.qh +++ b/qcsrc/server/g_damage.qh @@ -52,7 +52,7 @@ float damage_gooddamage; float IsFlying(entity a); -void UpdateFrags(entity player, float f); +void UpdateFrags(entity player, int f); // NOTE: f=0 means still count as a (positive) kill, but count no frags for it void W_SwitchWeapon_Force(Player this, Weapon w); diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 8039d8348..2bb634dda 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -759,11 +759,11 @@ bool want_mutatorblocked; MUTATOR_HOOKABLE(WantWeapon, EV_WantWeapon); #define EV_AddPlayerScore(i, o) \ - /**/ i(int, score_field) \ + /**/ i(entity, score_field) \ /**/ i(float, ret_float) \ /**/ o(float, ret_float) \ /**/ -int score_field; +PlayerScoreField score_field; MUTATOR_HOOKABLE(AddPlayerScore, EV_AddPlayerScore); #define EV_GetPlayerStatus(i, o) \ diff --git a/qcsrc/server/mutators/mutator/gamemode_assault.qc b/qcsrc/server/mutators/mutator/gamemode_assault.qc index 34c19d425..c697e46b2 100644 --- a/qcsrc/server/mutators/mutator/gamemode_assault.qc +++ b/qcsrc/server/mutators/mutator/gamemode_assault.qc @@ -59,7 +59,6 @@ void(entity this, float ratingscale, vector org, float sradius) havocbot_goalrat // scoreboard stuff const float ST_ASSAULT_OBJECTIVES = 1; -const float SP_ASSAULT_OBJECTIVES = 4; // predefined spawnfuncs void target_objective_decrease_activate(); diff --git a/qcsrc/server/mutators/mutator/gamemode_ctf.qc b/qcsrc/server/mutators/mutator/gamemode_ctf.qc index a7d6fb2a1..199f5bc58 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ctf.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ctf.qc @@ -233,7 +233,7 @@ bool ctf_CaptureShield_CheckStatus(entity p) if(ctf_captureshield_max_ratio <= 0) return false; - s = PlayerScore_Add(p, SP_CTF_CAPS, 0); + s = PlayerScore_Add(p, SP_CTF_CAPS, 0); s2 = PlayerScore_Add(p, SP_CTF_PICKUPS, 0); s3 = PlayerScore_Add(p, SP_CTF_RETURNS, 0); s4 = PlayerScore_Add(p, SP_CTF_FCKILLS, 0); @@ -247,7 +247,7 @@ bool ctf_CaptureShield_CheckStatus(entity p) FOREACH_CLIENT(IS_PLAYER(it), LAMBDA( if(DIFF_TEAM(it, p)) continue; - se = PlayerScore_Add(it, SP_CTF_CAPS, 0); + se = PlayerScore_Add(it, SP_CTF_CAPS, 0); se2 = PlayerScore_Add(it, SP_CTF_PICKUPS, 0); se3 = PlayerScore_Add(it, SP_CTF_RETURNS, 0); se4 = PlayerScore_Add(it, SP_CTF_FCKILLS, 0); @@ -2535,12 +2535,12 @@ void ctf_ScoreRules(int teams) CheckAllowedTeams(world); ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, 0, true); ScoreInfo_SetLabel_TeamScore (ST_CTF_CAPS, "caps", SFL_SORT_PRIO_PRIMARY); - ScoreInfo_SetLabel_PlayerScore(SP_CTF_CAPS, "caps", SFL_SORT_PRIO_SECONDARY); - ScoreInfo_SetLabel_PlayerScore(SP_CTF_CAPTIME, "captime", SFL_LOWER_IS_BETTER | SFL_TIME); - ScoreInfo_SetLabel_PlayerScore(SP_CTF_PICKUPS, "pickups", 0); - ScoreInfo_SetLabel_PlayerScore(SP_CTF_FCKILLS, "fckills", 0); - ScoreInfo_SetLabel_PlayerScore(SP_CTF_RETURNS, "returns", 0); - ScoreInfo_SetLabel_PlayerScore(SP_CTF_DROPS, "drops", SFL_LOWER_IS_BETTER); + ScoreInfo_SetLabel_PlayerScore(SP_CTF_CAPS, "caps", SFL_SORT_PRIO_SECONDARY); + ScoreInfo_SetLabel_PlayerScore(SP_CTF_CAPTIME, "captime", SFL_LOWER_IS_BETTER | SFL_TIME); + ScoreInfo_SetLabel_PlayerScore(SP_CTF_PICKUPS, "pickups", 0); + ScoreInfo_SetLabel_PlayerScore(SP_CTF_FCKILLS, "fckills", 0); + ScoreInfo_SetLabel_PlayerScore(SP_CTF_RETURNS, "returns", 0); + ScoreInfo_SetLabel_PlayerScore(SP_CTF_DROPS, "drops", SFL_LOWER_IS_BETTER); ScoreRules_basics_end(); } diff --git a/qcsrc/server/mutators/mutator/gamemode_ctf.qh b/qcsrc/server/mutators/mutator/gamemode_ctf.qh index c44dfc374..1429b4063 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ctf.qh +++ b/qcsrc/server/mutators/mutator/gamemode_ctf.qh @@ -8,12 +8,6 @@ void ctf_RespawnFlag(entity flag); // score rule declarations const int ST_CTF_CAPS = 1; -const int SP_CTF_CAPS = 4; -const int SP_CTF_CAPTIME = 5; -const int SP_CTF_PICKUPS = 6; -const int SP_CTF_DROPS = 7; -const int SP_CTF_FCKILLS = 8; -const int SP_CTF_RETURNS = 9; CLASS(Flag, Pickup) ATTRIB(Flag, m_mins, vector, PL_MIN_CONST + '0 0 -13') diff --git a/qcsrc/server/mutators/mutator/gamemode_cts.qc b/qcsrc/server/mutators/mutator/gamemode_cts.qc index 1f99c938d..49f181787 100644 --- a/qcsrc/server/mutators/mutator/gamemode_cts.qc +++ b/qcsrc/server/mutators/mutator/gamemode_cts.qc @@ -38,9 +38,6 @@ REGISTER_MUTATOR(cts, false) // scores const float ST_CTS_LAPS = 1; -const float SP_CTS_LAPS = 4; -const float SP_CTS_TIME = 5; -const float SP_CTS_FASTEST = 6; #endif #ifdef IMPLEMENTATION diff --git a/qcsrc/server/mutators/mutator/gamemode_domination.qc b/qcsrc/server/mutators/mutator/gamemode_domination.qc index 01f17ec9f..55996db47 100644 --- a/qcsrc/server/mutators/mutator/gamemode_domination.qc +++ b/qcsrc/server/mutators/mutator/gamemode_domination.qc @@ -37,10 +37,7 @@ REGISTER_MUTATOR(dom, false) // score rule declarations const float ST_DOM_TICKS = 1; -const float SP_DOM_TICKS = 4; -const float SP_DOM_TAKES = 5; const float ST_DOM_CAPS = 1; -const float SP_DOM_CAPS = 4; // pps: points per second .float dom_total_pps = _STAT(DOM_TOTAL_PPS); diff --git a/qcsrc/server/mutators/mutator/gamemode_freezetag.qc b/qcsrc/server/mutators/mutator/gamemode_freezetag.qc index 8482e258e..1dda2cee5 100644 --- a/qcsrc/server/mutators/mutator/gamemode_freezetag.qc +++ b/qcsrc/server/mutators/mutator/gamemode_freezetag.qc @@ -61,7 +61,6 @@ int autocvar_g_freezetag_teams; int autocvar_g_freezetag_teams_override; float autocvar_g_freezetag_warmup; -const float SP_FREEZETAG_REVIVALS = 4; void freezetag_ScoreRules(float teams) { ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, true); // SFL_SORT_PRIO_PRIMARY diff --git a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc index 66ac8a80e..5f5f278b6 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc +++ b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc @@ -32,10 +32,6 @@ REGISTER_MUTATOR(ka, false) entity ka_ball; -const float SP_KEEPAWAY_PICKUPS = 4; -const float SP_KEEPAWAY_CARRIERKILLS = 5; -const float SP_KEEPAWAY_BCTIME = 6; - void(entity this) havocbot_role_ka_carrier; void(entity this) havocbot_role_ka_collector; @@ -487,9 +483,9 @@ void ka_SpawnBall() // loads various values for the ball, runs only once at star void ka_ScoreRules() { ScoreRules_basics(0, SFL_SORT_PRIO_PRIMARY, 0, true); // SFL_SORT_PRIO_PRIMARY - ScoreInfo_SetLabel_PlayerScore(SP_KEEPAWAY_PICKUPS, "pickups", 0); - ScoreInfo_SetLabel_PlayerScore(SP_KEEPAWAY_CARRIERKILLS, "bckills", 0); - ScoreInfo_SetLabel_PlayerScore(SP_KEEPAWAY_BCTIME, "bctime", SFL_SORT_PRIO_SECONDARY); + ScoreInfo_SetLabel_PlayerScore(SP_KEEPAWAY_PICKUPS, "pickups", 0); + ScoreInfo_SetLabel_PlayerScore(SP_KEEPAWAY_CARRIERKILLS, "bckills", 0); + ScoreInfo_SetLabel_PlayerScore(SP_KEEPAWAY_BCTIME, "bctime", SFL_SORT_PRIO_SECONDARY); ScoreRules_basics_end(); } diff --git a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc index dbcaa5f89..e72a312f7 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc +++ b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc @@ -138,22 +138,16 @@ float kh_interferemsg_time, kh_interferemsg_team; float kh_key_dropped, kh_key_carried; const float ST_KH_CAPS = 1; -const float SP_KH_CAPS = 4; -const float SP_KH_PUSHES = 5; -const float SP_KH_DESTROYS = 6; -const float SP_KH_PICKUPS = 7; -const float SP_KH_KCKILLS = 8; -const float SP_KH_LOSSES = 9; void kh_ScoreRules(float teams) { ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, true); ScoreInfo_SetLabel_TeamScore( ST_KH_CAPS, "caps", SFL_SORT_PRIO_SECONDARY); - ScoreInfo_SetLabel_PlayerScore(SP_KH_CAPS, "caps", SFL_SORT_PRIO_SECONDARY); - ScoreInfo_SetLabel_PlayerScore(SP_KH_PUSHES, "pushes", 0); - ScoreInfo_SetLabel_PlayerScore(SP_KH_DESTROYS, "destroyed", SFL_LOWER_IS_BETTER); - ScoreInfo_SetLabel_PlayerScore(SP_KH_PICKUPS, "pickups", 0); - ScoreInfo_SetLabel_PlayerScore(SP_KH_KCKILLS, "kckills", 0); - ScoreInfo_SetLabel_PlayerScore(SP_KH_LOSSES, "losses", SFL_LOWER_IS_BETTER); + ScoreInfo_SetLabel_PlayerScore(SP_KH_CAPS, "caps", SFL_SORT_PRIO_SECONDARY); + ScoreInfo_SetLabel_PlayerScore(SP_KH_PUSHES, "pushes", 0); + ScoreInfo_SetLabel_PlayerScore(SP_KH_DESTROYS, "destroyed", SFL_LOWER_IS_BETTER); + ScoreInfo_SetLabel_PlayerScore(SP_KH_PICKUPS, "pickups", 0); + ScoreInfo_SetLabel_PlayerScore(SP_KH_KCKILLS, "kckills", 0); + ScoreInfo_SetLabel_PlayerScore(SP_KH_LOSSES, "losses", SFL_LOWER_IS_BETTER); ScoreRules_basics_end(); } diff --git a/qcsrc/server/mutators/mutator/gamemode_lms.qc b/qcsrc/server/mutators/mutator/gamemode_lms.qc index a2f1f2507..aa4ab5f96 100644 --- a/qcsrc/server/mutators/mutator/gamemode_lms.qc +++ b/qcsrc/server/mutators/mutator/gamemode_lms.qc @@ -32,10 +32,6 @@ REGISTER_MUTATOR(lms, false) return 0; } -// scoreboard stuff -const float SP_LMS_LIVES = 4; -const float SP_LMS_RANK = 5; - // lives related defs float lms_lowest_lives; float lms_next_place; diff --git a/qcsrc/server/mutators/mutator/gamemode_race.qc b/qcsrc/server/mutators/mutator/gamemode_race.qc index 7b769e29f..739f2d31e 100644 --- a/qcsrc/server/mutators/mutator/gamemode_race.qc +++ b/qcsrc/server/mutators/mutator/gamemode_race.qc @@ -78,7 +78,7 @@ void race_ScoreRules() ScoreRules_basics(race_teams, 0, 0, false); if(race_teams) { - ScoreInfo_SetLabel_TeamScore( ST_RACE_LAPS, "laps", SFL_SORT_PRIO_PRIMARY); + ScoreInfo_SetLabel_TeamScore( ST_RACE_LAPS, "laps", SFL_SORT_PRIO_PRIMARY); ScoreInfo_SetLabel_PlayerScore(SP_RACE_LAPS, "laps", SFL_SORT_PRIO_PRIMARY); ScoreInfo_SetLabel_PlayerScore(SP_RACE_TIME, "time", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER | SFL_TIME); ScoreInfo_SetLabel_PlayerScore(SP_RACE_FASTEST, "fastest", SFL_LOWER_IS_BETTER | SFL_TIME); diff --git a/qcsrc/server/race.qh b/qcsrc/server/race.qh index 51ec45900..b60125858 100644 --- a/qcsrc/server/race.qh +++ b/qcsrc/server/race.qh @@ -4,9 +4,6 @@ float race_teams; // scores const float ST_RACE_LAPS = 1; -const float SP_RACE_LAPS = 4; -const float SP_RACE_TIME = 5; -const float SP_RACE_FASTEST = 6; bool g_race_qualifying; diff --git a/qcsrc/server/scores.qc b/qcsrc/server/scores.qc index b09657e6a..59c76513d 100644 --- a/qcsrc/server/scores.qc +++ b/qcsrc/server/scores.qc @@ -7,10 +7,6 @@ .entity scorekeeper; entity teamscorekeepers[16]; -string scores_label[MAX_SCORE]; -float scores_flags[MAX_SCORE]; -string teamscores_label[MAX_TEAMSCORE]; -float teamscores_flags[MAX_TEAMSCORE]; float teamscores_entities_count; var .float scores_primary; var .float teamscores_primary; @@ -65,7 +61,7 @@ bool TeamScore_SendEntity(entity this, entity to, float sendflags) longflags = 0; for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2) - if(self.(teamscores[i]) > 127 || self.(teamscores[i]) <= -128) + if(self.(teamscores(i)) > 127 || self.(teamscores(i)) <= -128) longflags |= p; #if MAX_TEAMSCORE <= 8 @@ -79,9 +75,9 @@ bool TeamScore_SendEntity(entity this, entity to, float sendflags) if(sendflags & p) { if(longflags & p) - WriteInt24_t(MSG_ENTITY, self.(teamscores[i])); + WriteInt24_t(MSG_ENTITY, self.(teamscores(i))); else - WriteChar(MSG_ENTITY, self.(teamscores[i])); + WriteChar(MSG_ENTITY, self.(teamscores(i))); } return true; @@ -120,9 +116,9 @@ float TeamScore_AddToTeam(float t, float scorefield, float score) error("Adding score to unknown team!"); } if(score) - if(teamscores_label[scorefield] != "") + if(teamscores_label(scorefield) != "") s.SendFlags |= pow(2, scorefield); - return (s.(teamscores[scorefield]) += score); + return (s.(teamscores(scorefield)) += score); } float TeamScore_Add(entity player, float scorefield, float score) @@ -139,8 +135,8 @@ float TeamScore_Compare(entity t1, entity t2, float strict) for(i = 0; i < MAX_TEAMSCORE; ++i) { var .float f; - f = teamscores[i]; - result = ScoreField_Compare(t1, t2, f, teamscores_flags[i], result, strict); + f = teamscores(i); + result = ScoreField_Compare(t1, t2, f, teamscores_flags(i), result, strict); } if (result.x == 0 && strict) @@ -153,13 +149,13 @@ float TeamScore_Compare(entity t1, entity t2, float strict) * the scoreinfo entity */ -void ScoreInfo_SetLabel_PlayerScore(float i, string label, float scoreflags) +void ScoreInfo_SetLabel_PlayerScore(PlayerScoreField i, string label, float scoreflags) { - scores_label[i] = label; - scores_flags[i] = scoreflags; + scores_label(i) = label; + scores_flags(i) = scoreflags; if((scoreflags & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY) { - scores_primary = scores[i]; + scores_primary = scores(i); scores_flags_primary = scoreflags; } if(label != "") @@ -171,11 +167,11 @@ void ScoreInfo_SetLabel_PlayerScore(float i, string label, float scoreflags) void ScoreInfo_SetLabel_TeamScore(float i, string label, float scoreflags) { - teamscores_label[i] = label; - teamscores_flags[i] = scoreflags; + teamscores_label(i) = label; + teamscores_flags(i) = scoreflags; if((scoreflags & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY) { - teamscores_primary = teamscores[i]; + teamscores_primary = teamscores(i); teamscores_flags_primary = scoreflags; } if(label != "") @@ -190,15 +186,14 @@ bool ScoreInfo_SendEntity(entity this, entity to, int sf) float i; WriteHeader(MSG_ENTITY, ENT_CLIENT_SCORES_INFO); WriteInt24_t(MSG_ENTITY, MapInfo_LoadedGametype); - for(i = 0; i < MAX_SCORE; ++i) - { - WriteString(MSG_ENTITY, scores_label[i]); - WriteByte(MSG_ENTITY, scores_flags[i]); - } + FOREACH(Scores, true, { + WriteString(MSG_ENTITY, scores_label(it)); + WriteByte(MSG_ENTITY, scores_flags(it)); + }); for(i = 0; i < MAX_TEAMSCORE; ++i) { - WriteString(MSG_ENTITY, teamscores_label[i]); - WriteByte(MSG_ENTITY, teamscores_flags[i]); + WriteString(MSG_ENTITY, teamscores_label(i)); + WriteByte(MSG_ENTITY, teamscores_flags(i)); } return true; } @@ -230,31 +225,28 @@ void ScoreInfo_Init(float teams) bool PlayerScore_SendEntity(entity this, entity to, float sendflags) { - float i, p, longflags; - WriteHeader(MSG_ENTITY, ENT_CLIENT_SCORES); WriteByte(MSG_ENTITY, etof(self.owner)); - longflags = 0; - for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2) - if(self.(scores[i]) > 127 || self.(scores[i]) <= -128) + int longflags = 0; + FOREACH(Scores, true, { + int p = 1 << (i % 16); + if (self.(scores(it)) > 127 || self.(scores(it)) <= -128) longflags |= p; + }); -#if MAX_SCORE <= 8 - WriteByte(MSG_ENTITY, sendflags); - WriteByte(MSG_ENTITY, longflags); -#else WriteShort(MSG_ENTITY, sendflags); WriteShort(MSG_ENTITY, longflags); -#endif - for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2) - if(sendflags & p) + FOREACH(Scores, true, { + int p = 1 << (i % 16); + if (sendflags & p) { if(longflags & p) - WriteInt24_t(MSG_ENTITY, self.(scores[i])); + WriteInt24_t(MSG_ENTITY, self.(scores(it))); else - WriteChar(MSG_ENTITY, self.(scores[i])); + WriteChar(MSG_ENTITY, self.(scores(it))); } + }); return true; } @@ -262,7 +254,6 @@ bool PlayerScore_SendEntity(entity this, entity to, float sendflags) float PlayerScore_Clear(entity player) { entity sk; - float i; if(teamscores_entities_count) return 0; @@ -270,13 +261,12 @@ float PlayerScore_Clear(entity player) if(MUTATOR_CALLHOOK(ForbidPlayerScore_Clear)) return 0; sk = player.scorekeeper; - for(i = 0; i < MAX_SCORE; ++i) - { - if(sk.(scores[i]) != 0) - if(scores_label[i] != "") - sk.SendFlags |= pow(2, i); - sk.(scores[i]) = 0; - } + FOREACH(Scores, true, { + if(sk.(scores(it)) != 0) + if(scores_label(it) != "") + sk.SendFlags |= pow(2, i % 16); + sk.(scores(it)) = 0; + }); return 1; } @@ -285,18 +275,15 @@ void Score_ClearAll() { entity sk; float t; - FOREACH_CLIENTSLOT(true, - { + FOREACH_CLIENTSLOT(true, { sk = it.scorekeeper; - if(!sk) - continue; - for(int j = 0; j < MAX_SCORE; ++j) - { - if(sk.(scores[j]) != 0) - if(scores_label[j] != "") - sk.SendFlags |= pow(2, j); - sk.(scores[j]) = 0; - } + if (!sk) continue; + FOREACH(Scores, true, { + if(sk.(scores(it)) != 0) + if(scores_label(it) != "") + sk.SendFlags |= pow(2, i % 16); + sk.(scores(it)) = 0; + }); }); for(t = 0; t < 16; ++t) { @@ -305,10 +292,10 @@ void Score_ClearAll() continue; for(int j = 0; j < MAX_TEAMSCORE; ++j) { - if(sk.(teamscores[j]) != 0) - if(teamscores_label[j] != "") + if(sk.(teamscores(j)) != 0) + if(teamscores_label(j) != "") sk.SendFlags |= pow(2, j); - sk.(teamscores[j]) = 0; + sk.(teamscores(j)) = 0; } } } @@ -331,7 +318,7 @@ void PlayerScore_Detach(entity player) player.scorekeeper = world; } -float PlayerScore_Add(entity player, float scorefield, float score) +float PlayerScore_Add(entity player, PlayerScoreField scorefield, float score) { bool mutator_returnvalue = MUTATOR_CALLHOOK(AddPlayerScore, scorefield, score); score = ret_float; @@ -350,14 +337,14 @@ float PlayerScore_Add(entity player, float scorefield, float score) return 0; } if(score) - if(scores_label[scorefield] != "") - s.SendFlags |= pow(2, scorefield); + if(scores_label(scorefield) != "") + s.SendFlags |= pow(2, scorefield.m_id % 16); if(!warmup_stage) - PS_GR_P_ADDVAL(s.owner, strcat(PLAYERSTATS_TOTAL, scores_label[scorefield]), score); - return (s.(scores[scorefield]) += score); + PS_GR_P_ADDVAL(s.owner, strcat(PLAYERSTATS_TOTAL, scores_label(scorefield)), score); + return (s.(scores(scorefield)) += score); } -float PlayerTeamScore_Add(entity player, float pscorefield, float tscorefield, float score) +float PlayerTeamScore_Add(entity player, PlayerScoreField pscorefield, float tscorefield, float score) { float r; r = PlayerScore_Add(player, pscorefield, score); @@ -371,13 +358,10 @@ float PlayerScore_Compare(entity t1, entity t2, float strict) if(!t1 || !t2) return (!t2) - !t1; vector result = '0 0 0'; - float i; - for(i = 0; i < MAX_SCORE; ++i) - { - var .float f; - f = scores[i]; - result = ScoreField_Compare(t1, t2, f, scores_flags[i], result, strict); - } + FOREACH(Scores, true, { + var .float f = scores(it); + result = ScoreField_Compare(t1, t2, f, scores_flags(it), result, strict); + }); if (result.x == 0 && strict) result.x = etof(t1.owner) - etof(t2.owner); @@ -567,53 +551,59 @@ string GetPlayerScoreString(entity pl, float shortString) { string out; entity sk; - float i, f; + float f; string l; out = ""; if(!pl) { // label - for(i = 0; i < MAX_SCORE; ++i) - if((scores_flags[i] & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY) + FOREACH(Scores, true, { + if ((scores_flags(it) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY) { - f = scores_flags[i]; - l = scores_label[i]; + f = scores_flags(it); + l = scores_label(it); out = strcat(out, GetScoreLogLabel(l, f), ","); } + }); if(shortString < 2) - for(i = 0; i < MAX_SCORE; ++i) - if((scores_flags[i] & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY) + FOREACH(Scores, true, { + if((scores_flags(it) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY) { - f = scores_flags[i]; - l = scores_label[i]; + f = scores_flags(it); + l = scores_label(it); out = strcat(out, GetScoreLogLabel(l, f), ","); } + }); if(shortString < 1) - for(i = 0; i < MAX_SCORE; ++i) - if((scores_flags[i] & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_PRIMARY) - if((scores_flags[i] & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_SECONDARY) + FOREACH(Scores, true, { + if((scores_flags(it) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_PRIMARY) + if((scores_flags(it) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_SECONDARY) { - f = scores_flags[i]; - l = scores_label[i]; + f = scores_flags(it); + l = scores_label(it); out = strcat(out, GetScoreLogLabel(l, f), ","); } + }); out = substring(out, 0, strlen(out) - 1); } else if((sk = pl.scorekeeper)) { - for(i = 0; i < MAX_SCORE; ++i) - if((scores_flags[i] & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY) - out = strcat(out, ftos(sk.(scores[i])), ","); + FOREACH(Scores, true, { + if ((scores_flags(it) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY) + out = strcat(out, ftos(sk.(scores(it))), ","); + }); if(shortString < 2) - for(i = 0; i < MAX_SCORE; ++i) - if((scores_flags[i] & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY) - out = strcat(out, ftos(sk.(scores[i])), ","); + FOREACH(Scores, true, { + if ((scores_flags(it) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY) + out = strcat(out, ftos(sk.(scores(it))), ","); + }); if(shortString < 1) - for(i = 0; i < MAX_SCORE; ++i) - if((scores_flags[i] & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_PRIMARY) - if((scores_flags[i] & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_SECONDARY) - out = strcat(out, ftos(sk.(scores[i])), ","); + FOREACH(Scores, true, { + if((scores_flags(it) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_PRIMARY) + if((scores_flags(it) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_SECONDARY) + out = strcat(out, ftos(sk.(scores(it))), ","); + }); out = substring(out, 0, strlen(out) - 1); } return out; @@ -631,27 +621,27 @@ string GetTeamScoreString(float tm, float shortString) { // label for(i = 0; i < MAX_TEAMSCORE; ++i) - if((teamscores_flags[i] & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY) + if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY) { - f = teamscores_flags[i]; - l = teamscores_label[i]; + f = teamscores_flags(i); + l = teamscores_label(i); out = strcat(out, GetScoreLogLabel(l, f), ","); } if(shortString < 2) for(i = 0; i < MAX_TEAMSCORE; ++i) - if((teamscores_flags[i] & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY) + if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY) { - f = teamscores_flags[i]; - l = teamscores_label[i]; + f = teamscores_flags(i); + l = teamscores_label(i); out = strcat(out, GetScoreLogLabel(l, f), ","); } if(shortString < 1) for(i = 0; i < MAX_TEAMSCORE; ++i) - if((teamscores_flags[i] & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_PRIMARY) - if((teamscores_flags[i] & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_SECONDARY) + if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_PRIMARY) + if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_SECONDARY) { - f = teamscores_flags[i]; - l = teamscores_label[i]; + f = teamscores_flags(i); + l = teamscores_label(i); out = strcat(out, GetScoreLogLabel(l, f), ","); } out = substring(out, 0, strlen(out) - 1); @@ -659,17 +649,17 @@ string GetTeamScoreString(float tm, float shortString) else if((sk = teamscorekeepers[tm - 1])) { for(i = 0; i < MAX_TEAMSCORE; ++i) - if((teamscores_flags[i] & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY) - out = strcat(out, ftos(sk.(teamscores[i])), ","); + if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY) + out = strcat(out, ftos(sk.(teamscores(i))), ","); if(shortString < 2) for(i = 0; i < MAX_TEAMSCORE; ++i) - if((teamscores_flags[i] & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY) - out = strcat(out, ftos(sk.(teamscores[i])), ","); + if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY) + out = strcat(out, ftos(sk.(teamscores(i))), ","); if(shortString < 1) for(i = 0; i < MAX_TEAMSCORE; ++i) - if((teamscores_flags[i] & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_PRIMARY) - if((teamscores_flags[i] & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_SECONDARY) - out = strcat(out, ftos(sk.(teamscores[i])), ","); + if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_PRIMARY) + if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_SECONDARY) + out = strcat(out, ftos(sk.(teamscores(i))), ","); out = substring(out, 0, strlen(out) - 1); } return out; @@ -804,10 +794,10 @@ void Score_NicePrint_Team(entity to, float t, float w) { s = strcat(s, Team_ColoredFullName(t)); for(i = 0; i < MAX_TEAMSCORE; ++i) - if(teamscores_label[i] != "") + if(teamscores_label(i) != "") { - fl = teamscores_flags[i]; - sc = sk.(teamscores[i]); + fl = teamscores_flags(i); + sc = sk.(teamscores(i)); s = strcat(s, " ", Score_NicePrint_ItemColor(fl), ScoreString(fl, sc)); } } @@ -816,13 +806,14 @@ void Score_NicePrint_Team(entity to, float t, float w) s = strcat(s, strpad(max(0, NAMEWIDTH - strlennocol(s)), "")); - for(i = 0; i < MAX_SCORE; ++i) - if(scores_label[i] != "") + FOREACH(Scores, true, { + if(scores_label(it) != "") { - fl = scores_flags[i]; - s2 = scores_label[i]; + fl = scores_flags(it); + s2 = scores_label(it); s = strcat(s, " ", Score_NicePrint_ItemColor(fl), strpad(-w, substring(s2, 0, w))); } + }); print_to(to, s); } @@ -850,13 +841,14 @@ void Score_NicePrint_Player(entity to, entity p, float w) } } - for(i = 0; i < MAX_SCORE; ++i) - if(scores_label[i] != "") + FOREACH(Scores, true, { + if(scores_label(it) != "") { - fl = scores_flags[i]; - sc = sk.(scores[i]); + fl = scores_flags(it); + sc = sk.(scores(it)); s = strcat(s, " ", Score_NicePrint_ItemColor(fl), strpad(-w, ScoreString(fl, sc))); } + }); print_to(to, s); } @@ -875,13 +867,13 @@ void Score_NicePrint_Spectator(entity to, entity p) void Score_NicePrint(entity to) { entity p; - float i; float w; int t = 0; - for(i = 0; i < MAX_SCORE; ++i) - if(scores_label[i] != "") + FOREACH(Scores, true, { + if(scores_label(it) != "") ++t; + }); w = bound(6, floor(SCORESWIDTH / t - 1), 9); p = PlayerScore_Sort(score_dummyfield, 1, 1, 0); @@ -910,14 +902,12 @@ void Score_NicePrint(entity to) void PlayerScore_PlayerStats(entity p) { - entity s; - float i; - s = p.scorekeeper; - - for(i = 0; i < MAX_SCORE; ++i) - if(s.(scores[i]) != 0) - if(scores_label[i] != "") - PS_GR_P_ADDVAL(s.owner, strcat(PLAYERSTATS_SCOREBOARD, scores_label[i]), s.(scores[i])); + entity s = p.scorekeeper; + FOREACH(Scores, true, { + if(s.(scores(it)) != 0) + if(scores_label(it) != "") + PS_GR_P_ADDVAL(s.owner, strcat(PLAYERSTATS_SCOREBOARD, scores_label(it)), s.(scores(it))); + }); } void PlayerScore_TeamStats() @@ -930,9 +920,9 @@ void PlayerScore_TeamStats() if(!sk) continue; for(i = 0; i < MAX_TEAMSCORE; ++i) - if(sk.(teamscores[i]) != 0) - if(teamscores_label[i] != "") + if(sk.(teamscores(i)) != 0) + if(teamscores_label(i) != "") // the +1 is important here! - PS_GR_T_ADDVAL(t+1, strcat(PLAYERSTATS_SCOREBOARD, teamscores_label[i]), sk.(teamscores[i])); + PS_GR_T_ADDVAL(t+1, strcat(PLAYERSTATS_SCOREBOARD, teamscores_label(i)), sk.(teamscores(i))); } } diff --git a/qcsrc/server/scores.qh b/qcsrc/server/scores.qh index b547730ef..3e553f4d8 100644 --- a/qcsrc/server/scores.qh +++ b/qcsrc/server/scores.qh @@ -3,8 +3,6 @@ #include entity scores_initialized; // non-world when scores labels/rules have been set -.float scores[MAX_SCORE]; -.float teamscores[MAX_TEAMSCORE]; .float scoreboard_pos; /** @@ -24,7 +22,7 @@ void PlayerScore_Detach(entity player); * Means: FIXME make players unable to join the game when not called ClientConnect yet. * Returns the new score. */ -float PlayerScore_Add(entity player, float scorefield, float score); +float PlayerScore_Add(entity player, PlayerScoreField scorefield, float score); /** * Initialize the score of this player if needed. @@ -57,12 +55,12 @@ float TeamScore_GetCompareValue(float t); * Adds a score to both the player and the team. Returns the team score if * possible, otherwise the player score. */ -float PlayerTeamScore_Add(entity player, float pscorefield, float tscorefield, float score); +float PlayerTeamScore_Add(entity player, PlayerScoreField pscorefield, float tscorefield, float score); /** * Adds to the generic score fields for both the player and the team. */ -#define PlayerTeamScore_AddScore(p,s) PlayerTeamScore_Add(p, SP_SCORE, ST_SCORE, s) +#define PlayerTeamScore_AddScore(p, s) PlayerTeamScore_Add(p, SP_SCORE, ST_SCORE, s) /** * Set the label of a team score item, as well as the scoring flags. @@ -72,7 +70,7 @@ void ScoreInfo_SetLabel_TeamScore(float i, string label, float scoreflags); /** * Set the label of a player score item, as well as the scoring flags. */ -void ScoreInfo_SetLabel_PlayerScore(float i, string label, float scoreflags); +void ScoreInfo_SetLabel_PlayerScore(PlayerScoreField i, string label, float scoreflags); /** * Initialize the scores info for the given number of teams. diff --git a/qcsrc/server/scores_rules.qc b/qcsrc/server/scores_rules.qc index 80836bcb3..48958b158 100644 --- a/qcsrc/server/scores_rules.qc +++ b/qcsrc/server/scores_rules.qc @@ -5,15 +5,15 @@ void CheckAllowedTeams (entity for_whom); -// NOTE: SP_ constants may not be >= MAX_SCORE; ST_constants may not be >= MAX_TEAMSCORE +// NOTE: ST_constants may not be >= MAX_TEAMSCORE // scores that should be in all modes: float ScoreRules_teams; void ScoreRules_basics(float teams, float sprio, float stprio, float score_enabled) { - float i; - for(i = 0; i < MAX_SCORE; ++i) - ScoreInfo_SetLabel_PlayerScore(i, "", 0); - for(i = 0; i < MAX_TEAMSCORE; ++i) + FOREACH(Scores, true, { + ScoreInfo_SetLabel_PlayerScore(it, "", 0); + }); + for(int i = 0; i < MAX_TEAMSCORE; ++i) ScoreInfo_SetLabel_TeamScore(i, "", 0); ScoreRules_teams = teams; -- 2.39.2