]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Kill a few more loops
authorMario <mario@smbclan.net>
Thu, 24 Dec 2015 04:23:28 +0000 (14:23 +1000)
committerMario <mario@smbclan.net>
Thu, 24 Dec 2015 04:23:28 +0000 (14:23 +1000)
qcsrc/server/race.qc
qcsrc/server/scores.qc
qcsrc/server/spawnpoints.qc

index 304022f8e9ef60794b1729df2b2debecef6287d9..08ac0624d3b0f60ad39982dbbabb096069a11cd8 100644 (file)
@@ -1030,11 +1030,8 @@ void race_AbandonRaceCheck(entity p)
 
 void race_StartCompleting()
 {
-       entity p;
        race_completing = 1;
-       FOR_EACH_PLAYER(p)
-               if(p.deadflag != DEAD_NO)
-                       race_AbandonRaceCheck(p);
+       FOREACH_CLIENT(IS_PLAYER(it) && it.deadflag != DEAD_NO, LAMBDA(race_AbandonRaceCheck(it)));
 }
 
 void race_PreparePlayer()
@@ -1079,13 +1076,11 @@ void race_ClearRecords()
                race_checkpoint_recordholders[i] = string_null;
        }
 
-       entity e;
-       FOR_EACH_CLIENT(e)
-       {
-               float p = e.race_place;
-               WITH(entity, self, e, race_PreparePlayer());
-               e.race_place = p;
-       }
+       FOREACH_CLIENT(true, LAMBDA(
+               float p = it.race_place;
+               WITH(entity, self, it, race_PreparePlayer());
+               it.race_place = p;
+       ));
 }
 
 void race_ImposePenaltyTime(entity pl, float penalty, string reason)
index 1b20101d990d5b7a650b7a04d24e7490a5c63c31..0df94e0555720d729d40123ab5f5a2e2f6e05e2a 100644 (file)
@@ -392,7 +392,6 @@ void WinningConditionHelper()
 {
        float c;
        string s;
-       entity p;
        float fullstatus;
        entity winnerscorekeeper;
        entity secondscorekeeper;
@@ -467,14 +466,13 @@ void WinningConditionHelper()
                WinningConditionHelper_second = world;
                winnerscorekeeper = world;
                secondscorekeeper = world;
-               FOR_EACH_PLAYER(p)
-               {
-                       sk = p.scorekeeper;
+               FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+                       sk = it.scorekeeper;
                        c = PlayerScore_Compare(winnerscorekeeper, sk, 1);
                        if(c < 0)
                        {
                                WinningConditionHelper_second = WinningConditionHelper_winner;
-                               WinningConditionHelper_winner = p;
+                               WinningConditionHelper_winner = it;
                                secondscorekeeper = winnerscorekeeper;
                                winnerscorekeeper = sk;
                        }
@@ -483,11 +481,11 @@ void WinningConditionHelper()
                                c = PlayerScore_Compare(secondscorekeeper, sk, 1);
                                if(c < 0)
                                {
-                                       WinningConditionHelper_second = p;
+                                       WinningConditionHelper_second = it;
                                        secondscorekeeper = sk;
                                }
                        }
-               }
+               ));
 
                WinningConditionHelper_equality = (PlayerScore_Compare(winnerscorekeeper, secondscorekeeper, 0) == 0);
                if(WinningConditionHelper_equality)
@@ -529,32 +527,31 @@ void WinningConditionHelper()
                strunzone(worldstatus);
        worldstatus = strzone(s);
 
-       FOR_EACH_CLIENT(p)
-       {
+       FOREACH_CLIENT(true, LAMBDA(
                string s = "";
                if(fullstatus)
                {
-                       s = GetPlayerScoreString(p, 1);
-                       s = strcat(s, IS_REAL_CLIENT(p) ? ":human" : ":bot");
+                       s = GetPlayerScoreString(it, 1);
+                       s = strcat(s, IS_REAL_CLIENT(it) ? ":human" : ":bot");
                        ret_string = string_null;
-                       if(!IS_PLAYER(p) && !MUTATOR_CALLHOOK(GetPlayerStatus, p, s))
+                       if(!IS_PLAYER(it) && !MUTATOR_CALLHOOK(GetPlayerStatus, it, s))
                                s = strcat(s, ":spectator");
                        if (ret_string) s = strcat(s, ret_string);
                }
                else
                {
                        ret_string = string_null;
-                       if (IS_PLAYER(p) || MUTATOR_CALLHOOK(GetPlayerStatus, p, s))
-                               s = GetPlayerScoreString(p, 2);
+                       if (IS_PLAYER(it) || MUTATOR_CALLHOOK(GetPlayerStatus, it, s))
+                               s = GetPlayerScoreString(it, 2);
                        else
                                s = "-666";
                        if (ret_string) s = strcat(s, ret_string);
                }
 
-               if(p.clientstatus)
-                       strunzone(p.clientstatus);
-               p.clientstatus = strzone(s);
-       }
+               if(it.clientstatus)
+                       strunzone(it.clientstatus);
+               it.clientstatus = strzone(s);
+       ));
 }
 
 string GetScoreLogLabel(string label, float fl)
@@ -707,8 +704,7 @@ entity PlayerScore_Sort(.float field, float teams, float strict, float nospectat
 
        plist = world;
 
-       FOR_EACH_CLIENT(p)
-               p.(field) = 0;
+       FOREACH_CLIENT(true, LAMBDA(it.(field) = 0));
 
        FOR_EACH_CLIENT(p) if(p.scorekeeper)
        {
@@ -881,10 +877,10 @@ void Score_NicePrint_Spectator(entity to, entity p)
 void Score_NicePrint(entity to)
 {
        entity p;
-       float t, i;
+       float i;
        float w;
 
-       t = 0;
+       int t = 0;
        for(i = 0; i < MAX_SCORE; ++i)
                if(scores_label[i] != "")
                        ++t;
@@ -906,14 +902,12 @@ void Score_NicePrint(entity to)
        }
 
        t = 0;
-       FOR_EACH_CLIENT(p)
-       if (!IS_PLAYER(p))
-       {
+       FOREACH_CLIENT(!IS_PLAYER(it), LAMBDA(
                if (!t)
                        Score_NicePrint_Spectators(to);
-               Score_NicePrint_Spectator(to, p);
+               Score_NicePrint_Spectator(to, it);
                t = 1;
-       }
+       ));
 }
 
 void PlayerScore_PlayerStats(entity p)
index 55662892acdff8160f7a6fefd5d625754b17bdf9..022e27608f34016794153f3dc1dbee12f0167b90 100644 (file)
@@ -214,7 +214,6 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
 {SELFPARAM();
        float shortest, thisdist;
        float prio;
-       entity player;
 
        prio = 0;
 
@@ -239,12 +238,11 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
        }
 
        shortest = vlen(world.maxs - world.mins);
-       FOR_EACH_PLAYER(player) if (player != self)
-       {
-               thisdist = vlen(player.origin - spot.origin);
+       FOREACH_CLIENT(IS_PLAYER(it) && it != self, LAMBDA(
+               thisdist = vlen(it.origin - spot.origin);
                if (thisdist < shortest)
                        shortest = thisdist;
-       }
+       ));
        if(shortest > mindist)
                prio += SPAWN_PRIO_GOOD_DISTANCE;