]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Minor cleanup to player score sorting functions
authorMario <mario.mario@y7mail.com>
Mon, 19 Oct 2020 08:56:17 +0000 (18:56 +1000)
committerMario <mario.mario@y7mail.com>
Mon, 19 Oct 2020 08:56:17 +0000 (18:56 +1000)
qcsrc/common/gamemodes/gamemode/cts/sv_cts.qc
qcsrc/common/gamemodes/gamemode/race/sv_race.qc
qcsrc/common/playerstats.qc
qcsrc/server/scores.qc
qcsrc/server/scores.qh

index 08c4f84be2dfe53b0ab5f0f33f31edfeed0e1cda..70bd105ef03466518464c7d8cb0963c3c82441bb 100644 (file)
@@ -149,7 +149,7 @@ MUTATOR_HOOKFUNCTION(cts, reset_map_global)
        Score_NicePrint(NULL);
 
        race_ClearRecords();
-       PlayerScore_Sort(race_place, 0, 1, 0);
+       PlayerScore_Sort(race_place, 0, true, false);
 
        FOREACH_CLIENT(true, {
                if(it.race_place)
index 39c72a4593a9878fbe755f1211c977ff8ffd83cb..bd5f8b4385dbe8d9aba13074be0d41425487efd5 100644 (file)
@@ -208,7 +208,7 @@ MUTATOR_HOOKFUNCTION(rc, reset_map_global)
        Score_NicePrint(NULL);
 
        race_ClearRecords();
-       PlayerScore_Sort(race_place, 0, 1, 0);
+       PlayerScore_Sort(race_place, 0, true, false);
 
        FOREACH_CLIENT(true, {
                if(it.race_place)
index 4a7f352035881552acd6e15102f7fc690b7d49f9..2400d4750144916c09109ad4fa1eb55e2a4bdbba 100644 (file)
@@ -167,8 +167,8 @@ void PlayerStats_GameReport(bool finished)
 {
        if(PS_GR_OUT_DB < 0) { return; }
 
-       PlayerScore_Sort(score_dummyfield, 0, 0, 0);
-       PlayerScore_Sort(scoreboard_pos, 1, 1, 1);
+       PlayerScore_Sort(score_dummyfield, 0, false, false);
+       PlayerScore_Sort(scoreboard_pos, 1, true, true);
        if(teamplay) { PlayerScore_TeamStats(); }
 
        FOREACH_CLIENT(true, {
index eefd06fe3fe229240ce7a8ce2fb641ff09c72510..3113e8a965f9b56ac52974ae3543f3e81e1a0190 100644 (file)
@@ -24,7 +24,7 @@ var .float teamscores_primary;
 float scores_flags_primary;
 float teamscores_flags_primary;
 
-vector ScoreField_Compare(entity t1, entity t2, .float field, float fieldflags, vector previous, float strict) // returns: cmp value, best prio
+vector ScoreField_Compare(entity t1, entity t2, .float field, float fieldflags, vector previous, bool strict) // returns: cmp value, best prio
 {
        if(!strict && !(fieldflags & SFL_SORT_PRIO_MASK)) // column does not sort
                return previous;
@@ -139,7 +139,7 @@ float TeamScore_Add(entity player, float scorefield, float score)
        return TeamScore_AddToTeam(player.team, scorefield, score);
 }
 
-float TeamScore_Compare(entity t1, entity t2, float strict)
+float TeamScore_Compare(entity t1, entity t2, bool strict)
 {
        if(!t1 || !t2) return (!t2) - !t1;
 
@@ -396,7 +396,7 @@ float PlayerTeamScore_Add(entity player, PlayerScoreField pscorefield, float tsc
        return r;
 }
 
-float PlayerScore_Compare(entity t1, entity t2, float strict)
+float PlayerScore_Compare(entity t1, entity t2, bool strict)
 {
        if(!t1 || !t2) return (!t2) - !t1;
 
@@ -492,7 +492,7 @@ void WinningConditionHelper(entity this)
                secondscorekeeper = NULL;
                FOREACH_CLIENT(IS_PLAYER(it), {
                        sk = CS(it).scorekeeper;
-                       c = PlayerScore_Compare(winnerscorekeeper, sk, 1);
+                       c = PlayerScore_Compare(winnerscorekeeper, sk, true);
                        if(c < 0)
                        {
                                WinningConditionHelper_second = WinningConditionHelper_winner;
@@ -502,7 +502,7 @@ void WinningConditionHelper(entity this)
                        }
                        else
                        {
-                               c = PlayerScore_Compare(secondscorekeeper, sk, 1);
+                               c = PlayerScore_Compare(secondscorekeeper, sk, true);
                                if(c < 0)
                                {
                                        WinningConditionHelper_second = it;
@@ -511,7 +511,7 @@ void WinningConditionHelper(entity this)
                        }
                });
 
-               WinningConditionHelper_equality = (PlayerScore_Compare(winnerscorekeeper, secondscorekeeper, 0) == 0);
+               WinningConditionHelper_equality = (PlayerScore_Compare(winnerscorekeeper, secondscorekeeper, false) == 0);
                if(WinningConditionHelper_equality)
                        WinningConditionHelper_winner = WinningConditionHelper_second = NULL;
 
@@ -699,7 +699,7 @@ string GetTeamScoreString(float tm, float shortString)
        return out;
 }
 
-float PlayerTeamScore_Compare(entity p1, entity p2, float teams, float strict)
+float PlayerTeamScore_Compare(entity p1, entity p2, float teams, bool strict)
 {
        if(teams && teamscores_entities_count)
        {
@@ -719,7 +719,7 @@ float PlayerTeamScore_Compare(entity p1, entity p2, float teams, float strict)
        return PlayerScore_Compare(CS(p1).scorekeeper, CS(p2).scorekeeper, strict);
 }
 
-entity PlayerScore_Sort(.float field, float teams, float strict, float nospectators)
+entity PlayerScore_Sort(.float field, int teams, bool strict, bool nospectators)
 {
        entity p, plist, pprev, pbest, pbestprev, pfirst, plast;
        float i, j;
@@ -763,7 +763,7 @@ entity PlayerScore_Sort(.float field, float teams, float strict, float nospectat
                pbest.chain = NULL;
 
                ++i;
-               if(!plast || PlayerTeamScore_Compare(plast, pbest, teams, 0))
+               if(!plast || PlayerTeamScore_Compare(plast, pbest, teams, false))
                        j = i;
 
                pbest.(field) = j;
@@ -910,7 +910,7 @@ void Score_NicePrint(entity to)
     });
        w = bound(6, floor(SCORESWIDTH / t - 1), 9);
 
-       p = PlayerScore_Sort(score_dummyfield, 1, 1, 0);
+       p = PlayerScore_Sort(score_dummyfield, 1, true, false);
        t = -1;
 
        if(!teamscores_entities_count)
index ad406196635a55b1ecf60667d653eba8a21c27bc..cae0169aa6d32162af609ba088b0d044c3746fbe 100644 (file)
@@ -136,4 +136,4 @@ string GetTeamScoreString(float tm, float shortString);
  * strict: return a strict ordering
  * nospectators: exclude spectators
  */
-entity PlayerScore_Sort(.float field, float teams, float strict, float nospectators);
+entity PlayerScore_Sort(.float field, int teams, bool strict, bool nospectators);