]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
xonstat rank field: make this an actual player-only rank, ignoring teams
authorRudolf Polzer <divverent@xonotic.org>
Tue, 15 Jan 2013 14:20:59 +0000 (15:20 +0100)
committerRudolf Polzer <divverent@xonotic.org>
Tue, 15 Jan 2013 14:20:59 +0000 (15:20 +0100)
qcsrc/server/playerstats.qc
qcsrc/server/race.qc
qcsrc/server/scores.qc
qcsrc/server/scores.qh

index 6aecd736b84fef5ed4fbafb4c7ef4eff089fc6f7..44f7bb5ed1f627cb931c32a2595c490f9a8b3c3a 100644 (file)
@@ -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.
index 6aaa19803a5410e1c96316ed7c27e68c8b46c5c3..f761b18ba140cb1257a1e43b05f95a756ea31de8 100644 (file)
@@ -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)
index c2307ad3756208e08b7329ce90e7c2c8712a004a..c584fc58554980b2b437a42c071a897134c99d8f 100644 (file)
@@ -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)
index 96f15bc804266766b2180ab56f22e99a1d11cf61..423fd303cf3a4da0103ae06c18ed1f98113d65ab 100644 (file)
@@ -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);