]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Remove FOR_EACH_PLAYER and FOR_EACH_SPEC from the codebase
authorMario <mario@smbclan.net>
Thu, 24 Dec 2015 05:30:22 +0000 (15:30 +1000)
committerMario <mario@smbclan.net>
Thu, 24 Dec 2015 05:30:22 +0000 (15:30 +1000)
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/mutators/mutator/nix/nix.qc
qcsrc/common/mutators/mutator/spawn_near_teammate/spawn_near_teammate.qc
qcsrc/common/mutators/mutator/superspec/superspec.qc
qcsrc/common/triggers/target/music.qc
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/common/weapons/weapon/porto.qc
qcsrc/server/_all.qh
qcsrc/server/bot/havocbot/roles.qc
qcsrc/server/command/vote.qc

index 28aaac5dc17664df2622bcfab6634cc4ed3c66da..90c6c65611d005ffd01c4d90c78cf2bc74dd07dc 100644 (file)
@@ -1129,20 +1129,19 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
        {
                vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
                n = 0;
-               FOR_EACH_PLAYER(other) if(self != other)
-               {
-                       if(other.deadflag == DEAD_NO)
-                       if(other.frozen == 0)
-                       if(SAME_TEAM(other, self))
-                       if(boxesoverlap(self.absmin - revive_extra_size, self.absmax + revive_extra_size, other.absmin, other.absmax))
+               FOREACH_CLIENT(IS_PLAYER(it) && it != self, LAMBDA(
+                       if(it.deadflag == DEAD_NO)
+                       if(it.frozen == 0)
+                       if(SAME_TEAM(it, self))
+                       if(boxesoverlap(self.absmin - revive_extra_size, self.absmax + revive_extra_size, it.absmin, it.absmax))
                        {
                                if(!o)
-                                       o = other;
+                                       o = it;
                                if(self.frozen == 1)
-                                       other.reviving = true;
+                                       it.reviving = true;
                                ++n;
                        }
-               }
+               ));
        }
 
        if(n && self.frozen == 3) // OK, there is at least one teammate reviving us
@@ -1158,11 +1157,10 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
                        Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, self.netname);
                }
 
-               FOR_EACH_PLAYER(other) if(other.reviving)
-               {
+               FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, LAMBDA(
                        other.revive_progress = self.revive_progress;
                        other.reviving = false;
-               }
+               ));
        }
 
        return false;
index 2f4a7cd6390c0637387eab286c39347b531f3710..c3aadca41962ea849dd822789680b494e02044f2 100644 (file)
@@ -54,19 +54,17 @@ REGISTER_MUTATOR(nix, cvar("g_nix") && !cvar("g_instagib") && !cvar("g_overkill"
        MUTATOR_ONREMOVE
        {
                // as the PlayerSpawn hook will no longer run, NIX is turned off by this!
-               entity e;
-               FOR_EACH_PLAYER(e) if(e.deadflag == DEAD_NO)
-               {
-                       e.ammo_cells = start_ammo_cells;
-                       e.ammo_plasma = start_ammo_plasma;
-                       e.ammo_shells = start_ammo_shells;
-                       e.ammo_nails = start_ammo_nails;
-                       e.ammo_rockets = start_ammo_rockets;
-                       e.ammo_fuel = start_ammo_fuel;
-                       e.weapons = start_weapons;
-                       if(!client_hasweapon(e, PS(e).m_weapon, true, false))
-                               PS(e).m_switchweapon = w_getbestweapon(self);
-               }
+               FOREACH_CLIENT(IS_PLAYER(it) && it.deadflag == DEAD_NO, LAMBDA(
+                       it.ammo_cells = start_ammo_cells;
+                       it.ammo_plasma = start_ammo_plasma;
+                       it.ammo_shells = start_ammo_shells;
+                       it.ammo_nails = start_ammo_nails;
+                       it.ammo_rockets = start_ammo_rockets;
+                       it.ammo_fuel = start_ammo_fuel;
+                       it.weapons = start_weapons;
+                       if(!client_hasweapon(it, PS(it).m_weapon, true, false))
+                               PS(it).m_switchweapon = w_getbestweapon(self);
+               ));
        }
 
        return 0;
index 42d8d6b7f54a13b42b5cec33b5f519a9fc052502..dbbadd8e5d712de60db62e7759b1752ff3f06a5e 100644 (file)
@@ -21,25 +21,22 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, Spawn_Score)
        if(autocvar_g_spawn_near_teammate_ignore_spawnpoint == 1 || (autocvar_g_spawn_near_teammate_ignore_spawnpoint == 2 && self.cvar_cl_spawn_near_teammate))
                return 0;
 
-       entity p;
-
        spawn_spot.msnt_lookat = world;
 
        if(!teamplay)
                return 0;
 
        RandomSelection_Init();
-       FOR_EACH_PLAYER(p) if(p != self) if(p.team == self.team) if(!p.deadflag)
-       {
-               float l = vlen(spawn_spot.origin - p.origin);
+       FOREACH_CLIENT(IS_PLAYER(it) && it != self && SAME_TEAM(it, self) && it.deadflag == DEAD_NO, LAMBDA(
+               float l = vlen(spawn_spot.origin - it.origin);
                if(l > autocvar_g_spawn_near_teammate_distance)
                        continue;
                if(l < 48)
                        continue;
-               if(!checkpvs(spawn_spot.origin, p))
+               if(!checkpvs(spawn_spot.origin, it))
                        continue;
-               RandomSelection_Add(p, 0, string_null, 1, 1);
-       }
+               RandomSelection_Add(it, 0, string_null, 1, 1);
+       ));
 
        if(RandomSelection_chosen_ent)
        {
@@ -61,55 +58,54 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn)
                if(autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay_death)
                        self.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay_death;
 
-               entity team_mate, best_mate = world;
+               entity best_mate = world;
                vector best_spot = '0 0 0';
                float pc = 0, best_dist = 0, dist = 0;
-               FOR_EACH_PLAYER(team_mate)
-               {
-                       if((autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health >= 0 && team_mate.health >= autocvar_g_balance_health_regenstable) || autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health == 0)
-                       if(team_mate.deadflag == DEAD_NO)
-                       if(team_mate.msnt_timer < time)
-                       if(SAME_TEAM(self, team_mate))
-                       if(time > team_mate.spawnshieldtime) // spawn shielding
-                       if(team_mate.frozen == 0)
-                       if(team_mate != self)
+               FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+                       if((autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health >= 0 && it.health >= autocvar_g_balance_health_regenstable) || autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health == 0)
+                       if(it.deadflag == DEAD_NO)
+                       if(it.msnt_timer < time)
+                       if(SAME_TEAM(self, it))
+                       if(time > it.spawnshieldtime) // spawn shielding
+                       if(it.frozen == 0)
+                       if(it != self)
                        {
-                               tracebox(team_mate.origin, PL_MIN, PL_MAX, team_mate.origin - '0 0 100', MOVE_WORLDONLY, team_mate);
+                               tracebox(it.origin, PL_MIN, PL_MAX, it.origin - '0 0 100', MOVE_WORLDONLY, it);
                                if(trace_fraction != 1.0)
                                if(!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY))
                                {
                                        pc = pointcontents(trace_endpos + '0 0 1');
                                        if(pc == CONTENT_EMPTY)
                                        {
-                                               if(vlen(team_mate.velocity) > 5)
-                                                       fixedmakevectors(vectoangles(team_mate.velocity));
+                                               if(vlen(it.velocity) > 5)
+                                                       fixedmakevectors(vectoangles(it.velocity));
                                                else
-                                                       fixedmakevectors(team_mate.angles);
+                                                       fixedmakevectors(it.angles);
 
                                                for(pc = 0; pc < 5; ++pc) // test 5 diffrent spots close to mate
                                                {
                                                        switch(pc)
                                                        {
                                                                case 0:
-                                                                       tracebox(team_mate.origin , PL_MIN, PL_MAX, team_mate.origin + v_right * 128, MOVE_NORMAL, team_mate);
+                                                                       tracebox(it.origin , PL_MIN, PL_MAX, it.origin + v_right * 128, MOVE_NORMAL, it);
                                                                        break;
                                                                case 1:
-                                                                       tracebox(team_mate.origin , PL_MIN, PL_MAX, team_mate.origin - v_right * 128 , MOVE_NORMAL, team_mate);
+                                                                       tracebox(it.origin , PL_MIN, PL_MAX, it.origin - v_right * 128 , MOVE_NORMAL, it);
                                                                        break;
                                                                case 2:
-                                                                       tracebox(team_mate.origin , PL_MIN, PL_MAX, team_mate.origin + v_right * 64 - v_forward * 64, MOVE_NORMAL, team_mate);
+                                                                       tracebox(it.origin , PL_MIN, PL_MAX, it.origin + v_right * 64 - v_forward * 64, MOVE_NORMAL, it);
                                                                        break;
                                                                case 3:
-                                                                       tracebox(team_mate.origin , PL_MIN, PL_MAX, team_mate.origin - v_right * 64 - v_forward * 64, MOVE_NORMAL, team_mate);
+                                                                       tracebox(it.origin , PL_MIN, PL_MAX, it.origin - v_right * 64 - v_forward * 64, MOVE_NORMAL, it);
                                                                        break;
                                                                case 4:
-                                                                       tracebox(team_mate.origin , PL_MIN, PL_MAX, team_mate.origin - v_forward * 128, MOVE_NORMAL, team_mate);
+                                                                       tracebox(it.origin , PL_MIN, PL_MAX, it.origin - v_forward * 128, MOVE_NORMAL, it);
                                                                        break;
                                                        }
 
                                                        if(trace_fraction == 1.0)
                                                        {
-                                                               traceline(trace_endpos + '0 0 4', trace_endpos - '0 0 100', MOVE_NORMAL, team_mate);
+                                                               traceline(trace_endpos + '0 0 4', trace_endpos - '0 0 100', MOVE_NORMAL, it);
                                                                if(trace_fraction != 1.0)
                                                                {
                                                                        if(autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath)
@@ -119,15 +115,15 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn)
                                                                                {
                                                                                        best_dist = dist;
                                                                                        best_spot = trace_endpos;
-                                                                                       best_mate = team_mate;
+                                                                                       best_mate = it;
                                                                                }
                                                                        }
                                                                        else
                                                                        {
                                                                                setorigin(self, trace_endpos);
-                                                                               self.angles = team_mate.angles;
+                                                                               self.angles = it.angles;
                                                                                self.angles_z = 0; // never spawn tilted even if the spot says to
-                                                                               team_mate.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay;
+                                                                               it.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay;
                                                                                return 0;
                                                                        }
                                                                }
@@ -136,7 +132,7 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn)
                                        }
                                }
                        }
-               }
+               ));
 
                if(autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath)
                if(best_dist)
index 3c183c726f0823722f0d78950aea46ad55862c05..ed1f37b59bdbbc45fcc16c26321b896f75376853 100644 (file)
@@ -344,12 +344,7 @@ MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
 
        if(cmd_name == "followpowerup")
        {
-               entity _player;
-               FOR_EACH_PLAYER(_player)
-               {
-                       if(_player.strength_finished > time || _player.invincible_finished > time)
-                               return superspec_Spectate(_player);
-               }
+               FOREACH_CLIENT(IS_PLAYER(it) && (it.strength_finished > time || it.invincible_finished > time), LAMBDA(return superspec_Spectate(it)));
 
                superspec_msg("", "", self, "No active powerup\n", 1);
                return true;
@@ -357,12 +352,7 @@ MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
 
        if(cmd_name == "followstrength")
        {
-               entity _player;
-               FOR_EACH_PLAYER(_player)
-               {
-                       if(_player.strength_finished > time)
-                               return superspec_Spectate(_player);
-               }
+               FOREACH_CLIENT(IS_PLAYER(it) && it.strength_finished > time, LAMBDA(return superspec_Spectate(it)));
 
                superspec_msg("", "", self, "No active Strength\n", 1);
                return true;
@@ -370,12 +360,7 @@ MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
 
        if(cmd_name == "followshield")
        {
-               entity _player;
-               FOR_EACH_PLAYER(_player)
-               {
-                       if(_player.invincible_finished > time)
-                               return superspec_Spectate(_player);
-               }
+               FOREACH_CLIENT(IS_PLAYER(it) && it.invincible_finished > time, LAMBDA(return superspec_Spectate(it)));
 
                superspec_msg("", "", self, "No active Shield\n", 1);
                return true;
@@ -455,10 +440,8 @@ MUTATOR_HOOKFUNCTION(superspec, ClientConnect)
 
 MUTATOR_HOOKFUNCTION(superspec, PlayerDies)
 {SELFPARAM();
-       entity e;
-       FOR_EACH_SPEC(e)
-       {
-               setself(e);
+       FOREACH_CLIENT(IS_SPEC(it), LAMBDA(
+               setself(it);
                if(self.autospec_flags & ASF_FOLLOWKILLER && IS_PLAYER(frag_attacker) && self.enemy == this)
                {
                        if(self.autospec_flags & ASF_SHOWWHAT)
@@ -466,7 +449,7 @@ MUTATOR_HOOKFUNCTION(superspec, PlayerDies)
 
                        superspec_Spectate(frag_attacker);
                }
-       }
+       ));
 
        setself(this);
        return false;
index 1d8864f2c74291c66c687252c5cd8608f4704bd9..e6f68e68b1f30c585f215ad3fe95aecfc461edf2 100644 (file)
@@ -54,8 +54,10 @@ void target_music_use()
                msg_entity = activator;
                target_music_sendto(MSG_ONE, 1);
        }
-       entity head;
-       FOR_EACH_SPEC(head) if(head.enemy == activator) { msg_entity = head; target_music_sendto(MSG_ONE, 1); }
+       FOREACH_CLIENT(IS_SPEC(it) && it.enemy == activator, LAMBDA(
+               msg_entity = it;
+               target_music_sendto(MSG_ONE, 1);
+       ));
 }
 spawnfunc(target_music)
 {
index 97a6b467ca5e6f3b6e0c82749c3ecf5710dd3b64..acc213d39edb6fc8da16916510eab2d90921cd1a 100644 (file)
@@ -1016,9 +1016,7 @@ void vehicles_enter(entity pl, entity veh)
        if(DIFF_TEAM(pl, veh))
        if(autocvar_g_vehicles_steal)
        {
-               entity head;
-               FOR_EACH_PLAYER(head) if(SAME_TEAM(head, veh))
-                       Send_Notification(NOTIF_ONE, head, MSG_CENTER, CENTER_VEHICLE_STEAL);
+               FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, veh), LAMBDA(Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_VEHICLE_STEAL)));
 
                Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_VEHICLE_STEAL_SELF);
 
@@ -1173,10 +1171,7 @@ void vehicles_spawn()
        if(self.vehicle_controller)
                self.team = self.vehicle_controller.team;
 
-       entity head; // remove hooks (if any)
-       FOR_EACH_PLAYER(head)
-       if(head.hook.aiment == self)
-               RemoveGrapplingHook(head);
+       FOREACH_CLIENT(IS_PLAYER(it) && it.hook.aiment == self, LAMBDA(RemoveGrapplingHook(it)));
 
        vehicles_reset_colors();
 
index f992e31bda17a915172665ee8250635c5acf1647..1782b349135f0392211df51a17d5dc568a99ef06 100644 (file)
@@ -50,9 +50,7 @@ spawnfunc(weapon_porto) { weapon_defaultspawnfunc(this, WEP_PORTO); }
 
 REGISTER_MUTATOR(porto_ticker, true);
 MUTATOR_HOOKFUNCTION(porto_ticker, SV_StartFrame) {
-       entity e;
-       FOR_EACH_PLAYER(e)
-               e.porto_forbidden = max(0, e.porto_forbidden - 1);
+       FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(it.porto_forbidden = max(0, it.porto_forbidden - 1)));
 }
 
 void W_Porto_Success()
index affb8e0b4e12522603798a6e6437c2ce49ba7561..347eaf6cffc2635d120b3b81c18d231309cc76f2 100644 (file)
@@ -24,8 +24,8 @@ const string STR_OBSERVER = "observer";
 #define FOR_EACH_CLIENT(v) FOR_EACH_CLIENTSLOT(v) if (IS_CLIENT(v))
 #define FOR_EACH_REALCLIENT(v) FOR_EACH_CLIENT(v) if (IS_REAL_CLIENT(v))
 
-#define FOR_EACH_PLAYER(v) FOR_EACH_CLIENT(v) if (IS_PLAYER(v))
-#define FOR_EACH_SPEC(v) FOR_EACH_CLIENT(v) if (IS_SPEC(v))
+// NOTE: FOR_EACH_PLAYER deprecated! Use the following instead: FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(yourcode));
+// NOTE: FOR_EACH_SPEC deprecated! Use the following instead: FOREACH_CLIENT(IS_SPEC(it), LAMBDA(yourcode));
 #define FOR_EACH_OBSERVER(v) FOR_EACH_CLIENT(v) if (IS_OBSERVER(v))
 #define FOR_EACH_REALPLAYER(v) FOR_EACH_REALCLIENT(v) if (IS_PLAYER(v))
 
index f42bed8bcb2b5c94775659038ee2a1e41d6b2e2f..2db5dba02259cc22d3132898cc983a58651af5f0 100644 (file)
@@ -13,7 +13,6 @@
 void havocbot_goalrating_items(float ratingscale, vector org, float sradius)
 {SELFPARAM();
        entity head;
-       entity player;
        float rating, d, discard, distance, friend_distance, enemy_distance;
        vector o;
        ratingscale = ratingscale * 0.0001; // items are rated around 10000 already
@@ -64,17 +63,12 @@ void havocbot_goalrating_items(float ratingscale, vector org, float sradius)
                {
                        discard = false;
 
-                       FOR_EACH_PLAYER(player)
-                       {
-
-                               if ( self == player || player.deadflag )
-                                       continue;
+                       FOREACH_CLIENT(IS_PLAYER(it) && it != self && it.deadflag == DEAD_NO, LAMBDA(
+                               d = vlen(it.origin - o); // distance between player and item
 
-                               d = vlen(player.origin - o); // distance between player and item
-
-                               if ( player.team == self.team )
+                               if ( it.team == self.team )
                                {
-                                       if ( !IS_REAL_CLIENT(player) || discard )
+                                       if ( !IS_REAL_CLIENT(it) || discard )
                                                continue;
 
                                        if( d > friend_distance)
@@ -84,29 +78,29 @@ void havocbot_goalrating_items(float ratingscale, vector org, float sradius)
 
                                        discard = true;
 
-                                       if( head.health && player.health > self.health )
+                                       if( head.health && it.health > self.health )
                                                continue;
 
-                                       if( head.armorvalue && player.armorvalue > self.armorvalue)
+                                       if( head.armorvalue && it.armorvalue > self.armorvalue)
                                                continue;
 
                                        if( head.weapons )
-                                       if( head.weapons & ~player.weapons )
+                                       if( head.weapons & ~it.weapons )
                                                continue;
 
-                                       if (head.ammo_shells && player.ammo_shells > self.ammo_shells)
+                                       if (head.ammo_shells && it.ammo_shells > self.ammo_shells)
                                                continue;
 
-                                       if (head.ammo_nails && player.ammo_nails > self.ammo_nails)
+                                       if (head.ammo_nails && it.ammo_nails > self.ammo_nails)
                                                continue;
 
-                                       if (head.ammo_rockets && player.ammo_rockets > self.ammo_rockets)
+                                       if (head.ammo_rockets && it.ammo_rockets > self.ammo_rockets)
                                                continue;
 
-                                       if (head.ammo_cells && player.ammo_cells > self.ammo_cells)
+                                       if (head.ammo_cells && it.ammo_cells > self.ammo_cells)
                                                continue;
 
-                                       if (head.ammo_plasma && player.ammo_plasma > self.ammo_plasma)
+                                       if (head.ammo_plasma && it.ammo_plasma > self.ammo_plasma)
                                                continue;
 
                                        discard = false;
@@ -118,7 +112,7 @@ void havocbot_goalrating_items(float ratingscale, vector org, float sradius)
                                        if( d < enemy_distance )
                                                enemy_distance = d;
                                }
-                       }
+                       ));
 
                        // Rate the item only if no one needs it, or if an enemy is closer to it
                        if ( (enemy_distance < friend_distance && distance < enemy_distance) ||
index d1598e239cae5a5e85b889f48eca58004d1f3a97..37d3b78e62e855b46aabbc03e78b343325731fc9 100644 (file)
@@ -118,12 +118,7 @@ string OriginalCallerName()
 
 void VoteReset()
 {
-       entity tmp_player;
-
-       FOR_EACH_CLIENT(tmp_player)
-       {
-               tmp_player.vote_selection = 0;
-       }
+       FOREACH_CLIENT(true, LAMBDA(it.vote_selection = 0));
 
        if (vote_called)
        {
@@ -217,32 +212,29 @@ void VoteCount(float first_count)
        float vote_needed_of_voted, final_needed_votes;
        float vote_factor_overall, vote_factor_of_voted;
 
-       entity tmp_player;
-
        Nagger_VoteCountChanged();
 
        // add up all the votes from each connected client
-       FOR_EACH_REALCLIENT(tmp_player)
-       {
+       FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
                ++vote_player_count;
-               if (IS_PLAYER(tmp_player))   ++vote_real_player_count;
-               switch (tmp_player.vote_selection)
+               if (IS_PLAYER(it))   ++vote_real_player_count;
+               switch (it.vote_selection)
                {
                        case VOTE_SELECT_REJECT:
                        { ++vote_reject_count;
-                         { if (IS_PLAYER(tmp_player)) ++vote_real_reject_count; } break;
+                         { if (IS_PLAYER(it)) ++vote_real_reject_count; } break;
                        }
                        case VOTE_SELECT_ACCEPT:
                        { ++vote_accept_count;
-                         { if (IS_PLAYER(tmp_player)) ++vote_real_accept_count; } break;
+                         { if (IS_PLAYER(it)) ++vote_real_accept_count; } break;
                        }
                        case VOTE_SELECT_ABSTAIN:
                        { ++vote_abstain_count;
-                         { if (IS_PLAYER(tmp_player)) ++vote_real_abstain_count; } break;
+                         { if (IS_PLAYER(it)) ++vote_real_abstain_count; } break;
                        }
                        default: break;
                }
-       }
+       ));
 
        // Check to see if there are enough players on the server to allow master voting... otherwise, vote master could be used for evil.
        if ((vote_called == VOTE_MASTER) && autocvar_sv_vote_master_playerlimit > vote_player_count)
@@ -364,9 +356,7 @@ void reset_map(bool dorespawn)
                if (it.reset2) WITH(entity, self, it, it.reset2());
        ));
 
-       entity e;
-       FOR_EACH_PLAYER(e)
-       if (e.frozen) WITH(entity, self, e, Unfreeze(e));
+       FOREACH_CLIENT(IS_PLAYER(it) && it.frozen, LAMBDA(WITH(entity, self, it, Unfreeze(it))));
 
        // Moving the player reset code here since the player-reset depends
        // on spawnpoint entities which have to be reset first --blub
@@ -374,9 +364,8 @@ void reset_map(bool dorespawn)
        {
                if (!MUTATOR_CALLHOOK(reset_map_players))
                {
-                       FOR_EACH_CLIENT(e)  // reset all players
-                       {
-                               setself(e);
+                       FOREACH_CLIENT(true, LAMBDA(
+                               setself(it);
                                /*
                                only reset players if a restart countdown is active
                                this can either be due to cvar sv_ready_restart_after_countdown having set
@@ -397,7 +386,7 @@ void reset_map(bool dorespawn)
                                                PutClientInServer();
                                        }
                                }
-                       }
+                       ));
 
                        setself(this);
                }
@@ -429,15 +418,12 @@ void ReadyRestart_force()
        readyrestart_happened = true;
        game_starttime = time + RESTART_COUNTDOWN;
 
-       entity tmp_player;
-
        // clear player attributes
-       FOR_EACH_CLIENT(tmp_player)
-       {
-               tmp_player.alivetime = 0;
-               tmp_player.killcount = 0;
-               PS_GR_P_ADDVAL(tmp_player, PLAYERSTATS_ALIVETIME, -PS_GR_P_ADDVAL(tmp_player, PLAYERSTATS_ALIVETIME, 0));
-       }
+       FOREACH_CLIENT(true, LAMBDA(
+               it.alivetime = 0;
+               it.killcount = 0;
+               PS_GR_P_ADDVAL(it, PLAYERSTATS_ALIVETIME, -PS_GR_P_ADDVAL(it, PLAYERSTATS_ALIVETIME, 0));
+       ));
 
        restart_mapalreadyrestarted = false; // reset this var, needed when cvar sv_ready_restart_repeatable is in use
 
@@ -445,10 +431,7 @@ void ReadyRestart_force()
        warmup_stage = 0;                // once the game is restarted the game is in match stage
 
        // reset the .ready status of all players (also spectators)
-       FOR_EACH_REALCLIENT(tmp_player)
-       {
-               tmp_player.ready = false;
-       }
+       FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(it.ready = false));
        readycount = 0;
        Nagger_ReadyCounted();  // NOTE: this causes a resend of that entity, and will also turn off warmup state on the client
 
@@ -471,10 +454,7 @@ void ReadyRestart_force()
        // after a restart every players number of allowed timeouts gets reset, too
        if (autocvar_sv_timeout)
        {
-               FOR_EACH_REALPLAYER(tmp_player)
-               {
-                       tmp_player.allowed_timeouts = autocvar_sv_timeout_number;
-               }
+               FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(it.allowed_timeouts = autocvar_sv_timeout_number));
        }
     // reset map immediately if this cvar is not set
     if (!autocvar_sv_ready_restart_after_countdown) reset_map(true);
@@ -496,17 +476,13 @@ void ReadyRestart()
 // Count the players who are ready and determine whether or not to restart the match
 void ReadyCount()
 {
-       entity tmp_player;
        float ready_needed_factor, ready_needed_count;
        float t_ready = 0, t_players = 0;
 
-       FOR_EACH_REALCLIENT(tmp_player)
-       {
-               if (IS_PLAYER(tmp_player) || tmp_player.caplayer == 1)
-               {
-                       ++t_players;
-                       if (tmp_player.ready)   ++t_ready; }
-       }
+       FOREACH_CLIENT(IS_REAL_CLIENT(it) && (IS_PLAYER(it) || it.caplayer == 1), LAMBDA(
+               ++t_players;
+               if (it.ready) ++t_ready;
+       ));
 
        readycount = t_ready;
 
@@ -777,7 +753,6 @@ void VoteCommand_call(float request, entity caller, float argc, string vote_comm
                            || (autocvar_sv_vote_nospectators == 0));
 
                        float tmp_playercount = 0;
-                       entity tmp_player;
 
                        vote_command = VoteCommand_extractcommand(vote_command, 2, argc);
 
@@ -831,10 +806,7 @@ void VoteCommand_call(float request, entity caller, float argc, string vote_comm
                                        msg_entity = caller;
                                }
 
-                               FOR_EACH_REALCLIENT(tmp_player)
-                               {
-                                       ++tmp_playercount;
-                               }
+                               FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(++tmp_playercount));
                                if (tmp_playercount > 1)   Send_Notification(NOTIF_ALL, world, MSG_ANNCE, ANNCE_VOTE_CALL);  // don't announce a "vote now" sound if player is alone
 
                                bprint("\{1}^2* ^3", OriginalCallerName(), "^2 calls a vote for ", vote_called_display, "\n");