]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Kill most uses of FOR_EACH_REALCLIENT
authorMario <mario@smbclan.net>
Thu, 24 Dec 2015 06:20:07 +0000 (16:20 +1000)
committerMario <mario@smbclan.net>
Thu, 24 Dec 2015 06:20:07 +0000 (16:20 +1000)
12 files changed:
qcsrc/common/effects/qc/gibs.qc
qcsrc/common/effects/qc/globalsound.qc
qcsrc/common/mutators/mutator/damagetext/damagetext.qc
qcsrc/common/mutators/mutator/itemstime.qc
qcsrc/common/net_notice.qc
qcsrc/common/notifications.qc
qcsrc/common/playerstats.qc
qcsrc/common/weapons/weapon/tuba.qc
qcsrc/server/cl_client.qc
qcsrc/server/mapvoting.qc
qcsrc/server/mutators/mutator/gamemode_lms.qc
qcsrc/server/t_items.qc

index 2e248096bb7582c5a7e0887a896e9be051ebc2ed..2e54f43960d5d0f4284c35aa6afb0e462078fcda 100644 (file)
@@ -43,7 +43,7 @@ void Violence_GibSplash_At(vector org, vector dir, float type, float amount, ent
 
        e.oldorigin_x = compressShortVector(e.velocity);
 
-       entity cl; FOR_EACH_REALCLIENT(cl) Violence_GibSplash_SendEntity(e, cl, 0);
+       FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(Violence_GibSplash_SendEntity(e, it, 0)));
        remove(e);
 }
 
index 83a2440cf8fe08e9f1db7e3423bdcff89a37c2a5..7f77d84004d739e8b8bfeb10f2d4eebee3d63468 100644 (file)
                                        if (fake) { msg_entity = this; X(); }
                                        else
                                        {
-                                               FOR_EACH_REALCLIENT(msg_entity)
-                                               {
-                                                       if (!teamplay || msg_entity.team == this.team) X();
-                                               }
+                                               FOREACH_CLIENT(IS_REAL_CLIENT(it) && (!teamplay || msg_entity.team == this.team), LAMBDA(
+                                                       msg_entity = it;
+                                                       X();
+                                               ));
                                        }
                #undef X
                                        break;
                                        }
                                        else
                                        {
-                                               FOR_EACH_REALCLIENT(msg_entity)
-                                               {
+                                               FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
+                                                       msg_entity = it;
                                                        X();
-                                               }
+                                               ));
                                        }
                #undef X
                                        break;
index 923ca3bcc705be933144b69603c47b5c0ae10586..e8f3a54bfb5e1cc69fad9f88777d1b2ca706d855 100644 (file)
@@ -88,23 +88,24 @@ MUTATOR_HOOKFUNCTION(damagetext, PlayerDamaged) {
     const int armor = MUTATOR_ARGV(1, int);
     const int deathtype = MUTATOR_ARGV(2, int);
     const vector location = hit.origin;
-    entity e;
-    FOR_EACH_REALCLIENT(e) if (
-        (SV_DAMAGETEXT_ALL()) ||
-        (SV_DAMAGETEXT_PLAYERS() && e == attacker) ||
-        (SV_DAMAGETEXT_SPECTATORS_ONLY() && IS_SPEC(e) && e.enemy == attacker) ||
-        (SV_DAMAGETEXT_SPECTATORS_ONLY() && IS_OBSERVER(e))
-    ) {
-        msg_entity = e;
-        WriteHeader(MSG_ONE, damagetext);
-        WriteShort(MSG_ONE, health);
-        WriteShort(MSG_ONE, armor);
-        WriteEntity(MSG_ONE, hit);
-        WriteCoord(MSG_ONE, location.x);
-        WriteCoord(MSG_ONE, location.y);
-        WriteCoord(MSG_ONE, location.z);
-        WriteInt24_t(MSG_ONE, deathtype);
-    }
+    FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
+        if (
+            (SV_DAMAGETEXT_ALL()) ||
+            (SV_DAMAGETEXT_PLAYERS() && it == attacker) ||
+            (SV_DAMAGETEXT_SPECTATORS_ONLY() && IS_SPEC(it) && it.enemy == attacker) ||
+            (SV_DAMAGETEXT_SPECTATORS_ONLY() && IS_OBSERVER(it))
+        ) {
+            msg_entity = it;
+            WriteHeader(MSG_ONE, damagetext);
+            WriteShort(MSG_ONE, health);
+            WriteShort(MSG_ONE, armor);
+            WriteEntity(MSG_ONE, hit);
+            WriteCoord(MSG_ONE, location.x);
+            WriteCoord(MSG_ONE, location.y);
+            WriteCoord(MSG_ONE, location.z);
+            WriteInt24_t(MSG_ONE, deathtype);
+        }
+    ));
 }
 #endif
 
index 975eb29f3ea12b755c156c6510f67c81dad0ffca..20b43032348f0fe94d0122d256c575f76db109cf 100644 (file)
@@ -110,9 +110,7 @@ void Item_ItemsTime_SetTime(entity e, float t)
 
 void Item_ItemsTime_SetTimesForAllPlayers()
 {
-    entity e;
-    FOR_EACH_REALCLIENT(e) if (warmup_stage || !IS_PLAYER(e))
-        Item_ItemsTime_SetTimesForPlayer(e);
+    FOREACH_CLIENT(IS_REAL_CLIENT(it) && (warmup_stage || !IS_PLAYER(it)), LAMBDA(Item_ItemsTime_SetTimesForPlayer(it)));
 }
 
 float Item_ItemsTime_UpdateTime(entity e, float t)
index 06f310799423f05c635f263e76e74b35225e8f75..59061e5a97c99b257e879ccdd5084bcc7c1521ca 100644 (file)
@@ -30,10 +30,7 @@ void sv_notice_to(entity _to, string _notice, float _howlong, float _modal)
 
 void sv_notice_toall(string _notice, float _howlong, float _modal)
 {
-    entity _head;
-    FOR_EACH_REALCLIENT(_head)
-        sv_notice_to(_head, _notice, _howlong, _modal);
-
+    FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(sv_notice_to(it, _notice, _howlong, _modal)));
 }
 
 #endif // SVQC
index c8664e7af04743d2fce4886ed2ce463a4c185cb4..2343206caa18d20596ec8617715aa252a9dcb872 100644 (file)
@@ -2083,14 +2083,12 @@ void Send_Notification(
                        }
                        default:
                        {
-                               entity to;
-                               FOR_EACH_REALCLIENT(to)
-                               {
-                                       if(Notification_ShouldSend(broadcast, to, client))
+                               FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
+                                       if(Notification_ShouldSend(broadcast, it, client))
                                        {
-                                               RECURSE_FROM_CHOICE(to, continue);
+                                               RECURSE_FROM_CHOICE(it, continue);
                                        }
-                               }
+                               ));
                                break;
                        }
                }
index 2d9398ad7ede56de2b00681aa9fa5fd65c62ad2a..f4657d968ef1fdc30eb92c7073845c4d85256d38 100644 (file)
@@ -456,12 +456,10 @@ void PlayerStats_PlayerBasic(entity joiningplayer, float newrequest)
                // server has this disabled, kill the DB and set status to idle
                if(PS_B_IN_DB >= 0)
                {
-                       entity player;
-
                        db_close(PS_B_IN_DB);
                        PS_B_IN_DB = -1;
 
-                       FOR_EACH_REALCLIENT(player) { player.playerstats_basicstatus = PS_B_STATUS_IDLE; }
+                       FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(it.playerstats_basicstatus = PS_B_STATUS_IDLE));
                }
        }
 }
index ef2e5e2612dafd69847c56bf8b1574035b37eed3..084c5cff466e8fd029e55521f35deff74a8a80c1 100644 (file)
@@ -287,7 +287,6 @@ void W_Tuba_NoteThink()
        float vol0, vol1;
        vector dir0, dir1;
        vector v;
-       entity e;
        if(time > self.teleport_time)
        {
                W_Tuba_NoteOff();
@@ -295,13 +294,11 @@ void W_Tuba_NoteThink()
        }
        self.nextthink = time;
        dist_mult = WEP_CVAR(tuba, attenuation) / autocvar_snd_soundradius;
-       FOR_EACH_REALCLIENT(e)
-       if(e != self.realowner)
-       {
-               v = self.origin - (e.origin + e.view_ofs);
+       FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != self.realowner, LAMBDA(
+               v = self.origin - (it.origin + it.view_ofs);
                vol0 = max(0, 1 - vlen(v) * dist_mult);
                dir0 = normalize(v);
-               v = self.realowner.origin - (e.origin + e.view_ofs);
+               v = self.realowner.origin - (it.origin + it.view_ofs);
                vol1 = max(0, 1 - vlen(v) * dist_mult);
                dir1 = normalize(v);
                if(fabs(vol0 - vol1) > 0.005) // 0.5 percent change in volume
@@ -316,7 +313,7 @@ void W_Tuba_NoteThink()
                        self.SendFlags |= 2;
                        break;
                }
-       }
+       ));
 }
 
 void W_Tuba_NoteOn(float hittype)
index 32ec6eb03c9ec32963287fa2075975639c9f307a..0c72e878e3606d652daad79cbd6598ada3b8a29a 100644 (file)
@@ -103,14 +103,7 @@ void ClientData_Touch(entity e)
        e.clientdata.SendFlags = 1;
 
        // make it spectatable
-       entity e2;
-       FOR_EACH_REALCLIENT(e2)
-       {
-               if(e2 != e)
-                       if(IS_SPEC(e2))
-                               if(e2.enemy == e)
-                                       e2.clientdata.SendFlags = 1;
-       }
+       FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != e && IS_SPEC(it) && it.enemy == e, LAMBDA(it.clientdata.SendFlags = 1));
 }
 
 .string netname_previous;
index ed17d86e8e2a26ddc97cf47bde011cbc65649766..a08272010eee694c4bc0fe3983145af5b5c76fdf 100644 (file)
@@ -99,8 +99,7 @@ string GameTypeVote_MapInfo_FixName(string m)
 
 void MapVote_ClearAllVotes()
 {
-       FOR_EACH_CLIENT(other)
-               other.mapvote = 0;
+       FOREACH_CLIENT(true, LAMBDA(it.mapvote = 0));
 }
 
 void MapVote_UnzoneStrings()
@@ -454,8 +453,7 @@ float MapVote_Finished(float mappos)
                        GameLogEcho(strcat(":vote:suggestion_accepted:", mapvote_maps[mappos]));
        }
 
-       FOR_EACH_REALCLIENT(other)
-               FixClientCvars(other);
+       FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(FixClientCvars(it)));
 
        if(gametypevote)
        {
@@ -494,16 +492,15 @@ void MapVote_CheckRules_1()
                }
 
        mapvote_voters = 0;
-       FOR_EACH_REALCLIENT(other)
-       {
+       FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
                ++mapvote_voters;
-               if(other.mapvote)
+               if(it.mapvote)
                {
-                       i = other.mapvote - 1;
-                       //dprint("Player ", other.netname, " vote = ", ftos(other.mapvote - 1), "\n");
+                       i = it.mapvote - 1;
+                       //dprint("Player ", it.netname, " vote = ", ftos(it.mapvote - 1), "\n");
                        mapvote_selections[i] = mapvote_selections[i] + 1;
                }
-       }
+       ));
 }
 
 float MapVote_CheckRules_2()
@@ -604,36 +601,33 @@ void MapVote_Tick()
                return;
 
        totalvotes = 0;
-       FOR_EACH_REALCLIENT(other)
-       {
+       FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
                // hide scoreboard again
-               if(other.health != 2342)
+               if(it.health != 2342)
                {
-                       other.health = 2342;
-                       other.impulse = 0;
-                       if(IS_REAL_CLIENT(other))
-                       {
-                               msg_entity = other;
-                               WriteByte(MSG_ONE, SVC_FINALE);
-                               WriteString(MSG_ONE, "");
-                       }
+                       it.health = 2342;
+                       it.impulse = 0;
+
+                       msg_entity = it;
+                       WriteByte(MSG_ONE, SVC_FINALE);
+                       WriteString(MSG_ONE, "");
                }
 
                // clear possibly invalid votes
-               if ( !(mapvote_maps_flags[other.mapvote-1] & GTV_AVAILABLE) )
-                       other.mapvote = 0;
+               if ( !(mapvote_maps_flags[it.mapvote-1] & GTV_AVAILABLE) )
+                       it.mapvote = 0;
                // use impulses as new vote
-               if(other.impulse >= 1 && other.impulse <= mapvote_count)
-                       if( mapvote_maps_flags[other.impulse - 1] & GTV_AVAILABLE )
+               if(it.impulse >= 1 && it.impulse <= mapvote_count)
+                       if( mapvote_maps_flags[it.impulse - 1] & GTV_AVAILABLE )
                        {
-                               other.mapvote = other.impulse;
-                               MapVote_TouchVotes(other);
+                               it.mapvote = it.impulse;
+                               MapVote_TouchVotes(it);
                        }
-               other.impulse = 0;
+               it.impulse = 0;
 
-               if(other.mapvote)
+               if(it.mapvote)
                        ++totalvotes;
-       }
+       ));
 
        MapVote_CheckRules_1(); // just count
 }
index 575bc69040474805daee2fef54347a3887dd6f3e..6b293a0642de7dbc9219ad5284f4614ea4988d4b 100644 (file)
@@ -161,13 +161,8 @@ MUTATOR_HOOKFUNCTION(lms, reset_map_global)
 
 MUTATOR_HOOKFUNCTION(lms, reset_map_players)
 {SELFPARAM();
-       entity e;
        if(restart_mapalreadyrestarted || (time < game_starttime))
-       FOR_EACH_CLIENT(e)
-       if(IS_PLAYER(e))
-       {
-               WITH(entity, self, e, PlayerScore_Add(e, SP_LMS_LIVES, LMS_NewPlayerLives()));
-       }
+       FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(WITH(entity, self, it, PlayerScore_Add(it, SP_LMS_LIVES, LMS_NewPlayerLives()))));
 
        return false;
 }
@@ -343,12 +338,10 @@ MUTATOR_HOOKFUNCTION(lms, ItemTouch)
 
 MUTATOR_HOOKFUNCTION(lms, Bot_FixCount, CBC_ORDER_EXCLUSIVE)
 {
-       entity head;
-       FOR_EACH_REALCLIENT(head)
-       {
+       FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
                ++bot_activerealplayers;
                ++bot_realplayers;
-       }
+       ));
 
        return true;
 }
index 8bce02ca18ede89a42cd2499168c550ea3fbd342..fbb733405646e4c411c9995bc7b51035cb0dd89d 100644 (file)
@@ -532,13 +532,13 @@ void Item_RespawnCountdown ()
                if(self.waypointsprite_attached)
                {
                        setself(self.waypointsprite_attached);
-                       entity e;
-                       FOR_EACH_REALCLIENT(e)
-                               if(self.waypointsprite_visible_for_player(e))
+                       FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
+                               if(self.waypointsprite_visible_for_player(it))
                                {
-                                       msg_entity = e;
+                                       msg_entity = it;
                                        soundto(MSG_ONE, this, CH_TRIGGER, SND(ITEMRESPAWNCOUNTDOWN), VOL_BASE, ATTEN_NORM);    // play respawn sound
                                }
+                       ));
                        setself(this);
 
                        WaypointSprite_Ping(self.waypointsprite_attached);