From: Rudolf Polzer Date: Tue, 15 Jan 2013 14:20:59 +0000 (+0100) Subject: xonstat rank field: make this an actual player-only rank, ignoring teams X-Git-Tag: xonotic-v0.7.0~108^2~13 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fb68727685088a166e860276f116be6f75cf2d98;p=xonotic%2Fxonotic-data.pk3dir.git xonstat rank field: make this an actual player-only rank, ignoring teams --- diff --git a/qcsrc/server/playerstats.qc b/qcsrc/server/playerstats.qc index 6aecd736b..44f7bb5ed 100644 --- a/qcsrc/server/playerstats.qc +++ b/qcsrc/server/playerstats.qc @@ -370,8 +370,8 @@ void PlayerStats_AddGlobalInfo(entity p) void PlayerStats_EndMatch(float finished) { entity p; - PlayerScore_Sort(score_dummyfield, 0); - PlayerScore_Sort(scoreboard_pos, 1); + PlayerScore_Sort(score_dummyfield, 0, 0); + PlayerScore_Sort(scoreboard_pos, 1, 1); FOR_EACH_CLIENT(p) // spectators intentionally not included { //PlayerStats_Accuracy(p); // stats are already written with PlayerStats_AddGlobalInfo(entity), don't double them up. diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index 6aaa19803..f761b18ba 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -1026,7 +1026,7 @@ void race_ReadyRestart() Score_NicePrint(world); race_ClearRecords(); - PlayerScore_Sort(race_place, 1); + PlayerScore_Sort(race_place, 0, 1); entity e; FOR_EACH_CLIENT(e) diff --git a/qcsrc/server/scores.qc b/qcsrc/server/scores.qc index c2307ad37..c584fc585 100644 --- a/qcsrc/server/scores.qc +++ b/qcsrc/server/scores.qc @@ -665,23 +665,26 @@ string GetTeamScoreString(float tm, float shortString) return out; } -float PlayerTeamScore_Compare(entity p1, entity p2, float strict) +float PlayerTeamScore_Compare(entity p1, entity p2, float teams, float strict) { - if(teamscores_entities_count) + if(teams && teamscores_entities_count) if(p1.team != p2.team) { entity t1, t2; float r; t1 = teamscorekeepers[p1.team - 1]; t2 = teamscorekeepers[p2.team - 1]; - r = TeamScore_Compare(t1, t2, strict); + r = TeamScore_Compare(t1, t2, ((teams >= 0) ? 1 : strict)); return r; } + + if(teams < 0) + return 0; return PlayerScore_Compare(p1.scorekeeper, p2.scorekeeper, strict); } -entity PlayerScore_Sort(.float field, float strict) +entity PlayerScore_Sort(.float field, float teams, float strict) { entity p, plist, pprev, pbest, pbestprev, pfirst, plast; float i, j; @@ -707,7 +710,7 @@ entity PlayerScore_Sort(.float field, float strict) pbest = plist; for(p = plist; (pprev = p), (p = p.chain); ) { - if(PlayerTeamScore_Compare(p, pbest, strict) > 0) + if(PlayerTeamScore_Compare(p, pbest, teams, strict) > 0) { pbest = p; pbestprev = pprev; @@ -722,7 +725,7 @@ entity PlayerScore_Sort(.float field, float strict) pbest.chain = world; ++i; - if(!plast || PlayerTeamScore_Compare(plast, pbest, 0)) + if(!plast || PlayerTeamScore_Compare(plast, pbest, teams, 0)) j = i; pbest.field = j; @@ -867,7 +870,7 @@ void Score_NicePrint(entity to) ++t; w = bound(6, floor(SCORESWIDTH / t - 1), 9); - p = PlayerScore_Sort(score_dummyfield, 1); + p = PlayerScore_Sort(score_dummyfield, 1, 1); t = -1; if(!teamscores_entities_count) diff --git a/qcsrc/server/scores.qh b/qcsrc/server/scores.qh index 96f15bc80..423fd303c 100644 --- a/qcsrc/server/scores.qh +++ b/qcsrc/server/scores.qh @@ -117,5 +117,7 @@ string GetTeamScoreString(float tm, float shortString); * Sorts the players and stores their place in the given field, starting with * 1. Non-players get 0 written into that field. * Returns the beginning of a sorted chain of the non-spectators. + * teams: >0: sort by teams first (always strict ordering); <0: sort by teams only (respects strict flag) + * strict: return a strict ordering */ -entity PlayerScore_Sort(.float field, float strict); +entity PlayerScore_Sort(.float field, float teams, float strict);