Fix up some more FOR_EACH_PLAYER loops
authorMario <mario@smbclan.net>
Thu, 24 Dec 2015 00:50:18 +0000 (10:50 +1000)
committerMario <mario@smbclan.net>
Thu, 24 Dec 2015 00:50:18 +0000 (10:50 +1000)
qcsrc/server/g_damage.qc
qcsrc/server/g_subs.qc

index 2e949ec..cdafc53 100644 (file)
@@ -538,10 +538,7 @@ void Freeze (entity targ, float freeze_time, float frozen_type, float show_waypo
 
        RemoveGrapplingHook(targ);
 
-       entity head;
-       FOR_EACH_PLAYER(head)
-       if(head.hook.aiment == targ)
-               RemoveGrapplingHook(head);
+       FOREACH_CLIENT(IS_PLAYER(it) && it.hook.aiment == targ, LAMBDA(RemoveGrapplingHook(it)));
 
        // add waypoint
        if(show_waypoint)
@@ -556,7 +553,6 @@ void Unfreeze (entity targ)
        if(targ.frozen && targ.frozen != 3) // only reset health if target was frozen
                targ.health = ((IS_PLAYER(targ)) ? start_health : targ.max_health);
 
-       entity head;
        targ.frozen = 0;
        targ.revive_progress = 0;
        targ.revival_time = time;
@@ -564,9 +560,7 @@ void Unfreeze (entity targ)
 
        WaypointSprite_Kill(targ.waypointsprite_attached);
 
-       FOR_EACH_PLAYER(head)
-       if(head.hook.aiment == targ)
-               RemoveGrapplingHook(head);
+       FOREACH_CLIENT(IS_PLAYER(it) && it.hook.aiment == targ, LAMBDA(RemoveGrapplingHook(it)));
 
        // remove the ice block
        if(targ.iceblock)
@@ -1233,20 +1227,18 @@ void Fire_ApplyDamage(entity e)
        }
        e.fire_hitsound = true;
 
-       if (!IS_INDEPENDENT_PLAYER(e))
+       if(!IS_INDEPENDENT_PLAYER(e))
        if(!e.frozen)
-       FOR_EACH_PLAYER(other) if(e != other)
-       {
-               if(IS_PLAYER(other))
-               if(other.deadflag == DEAD_NO)
-               if (!IS_INDEPENDENT_PLAYER(other))
-               if(boxesoverlap(e.absmin, e.absmax, other.absmin, other.absmax))
-               {
-                       t = autocvar_g_balance_firetransfer_time * (e.fire_endtime - time);
-                       d = autocvar_g_balance_firetransfer_damage * e.fire_damagepersec * t;
-                       Fire_AddDamage(other, o, d, t, DEATH_FIRE.m_id);
-               }
-       }
+               FOREACH_CLIENT(IS_PLAYER(it) && it != e, LAMBDA(
+                       if(it.deadflag == DEAD_NO)
+                       if(!IS_INDEPENDENT_PLAYER(it))
+                       if(boxesoverlap(e.absmin, e.absmax, it.absmin, it.absmax))
+                       {
+                               t = autocvar_g_balance_firetransfer_time * (e.fire_endtime - time);
+                               d = autocvar_g_balance_firetransfer_damage * e.fire_damagepersec * t;
+                               Fire_AddDamage(it, o, d, t, DEATH_FIRE.m_id);
+                       }
+               ));
 }
 
 void Fire_ApplyEffect(entity e)
index f7dcf30..ecba366 100644 (file)
@@ -35,9 +35,6 @@ Additionally it moves players back into the past before the trace and restores t
 */
 void tracebox_antilag_force_wz (entity source, vector v1, vector mi, vector ma, vector v2, float nomonst, entity forent, float lag, float wz)
 {
-       entity player;
-       float oldsolid;
-
        // check whether antilagged traces are enabled
        if (lag < 0.001)
                lag = 0;
@@ -45,18 +42,18 @@ void tracebox_antilag_force_wz (entity source, vector v1, vector mi, vector ma,
                lag = 0; // only antilag for clients
 
        // change shooter to SOLID_BBOX so the shot can hit corpses
-       oldsolid = source.dphitcontentsmask;
+       int oldsolid = source.dphitcontentsmask;
        if(source)
                source.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
 
        if (lag)
        {
                // take players back into the past
-               FOR_EACH_PLAYER(player)
-                       if(player != forent)
-                               antilag_takeback(player, time - lag);
-               FOR_EACH_MONSTER(player)
-                       antilag_takeback(player, time - lag);
+               FOREACH_CLIENT(IS_PLAYER(it) && it != forent, LAMBDA(antilag_takeback(it, time - lag)));
+               FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, LAMBDA(
+                       if(it != forent)
+                               antilag_takeback(it, time - lag);
+               ));
        }
 
        // do the trace
@@ -68,11 +65,11 @@ void tracebox_antilag_force_wz (entity source, vector v1, vector mi, vector ma,
        // restore players to current positions
        if (lag)
        {
-               FOR_EACH_PLAYER(player)
-                       if(player != forent)
-                               antilag_restore(player);
-               FOR_EACH_MONSTER(player)
-                       antilag_restore(player);
+               FOREACH_CLIENT(IS_PLAYER(it) && it != forent, LAMBDA(antilag_restore(it)));
+               FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, LAMBDA(
+                       if(it != forent)
+                               antilag_restore(it);
+               ));
        }
 
        // restore shooter solid type