Reduce code of 2 macros
authorterencehill <piuntn@gmail.com>
Sat, 1 Dec 2018 19:25:47 +0000 (20:25 +0100)
committerterencehill <piuntn@gmail.com>
Sat, 1 Dec 2018 19:25:47 +0000 (20:25 +0100)
qcsrc/common/mapobjects/teleporters.qh
qcsrc/server/cheats.qc

index 68c5114..f72f943 100644 (file)
@@ -34,12 +34,8 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle
 void trigger_teleport_use(entity this, entity actor, entity trigger);
 
 #define TDEATHLOOP(o) \
-       entity head; \
-       vector deathmin; \
-       vector deathmax; \
-       float deathradius; \
-       deathmin = (o) + player.mins; \
-       deathmax = (o) + player.maxs; \
+       vector deathmin = (o) + player.mins; \
+       vector deathmax = (o) + player.maxs; \
        if(telefragmin != telefragmax) \
        { \
                if(deathmin.x > telefragmin.x) deathmin.x = telefragmin.x; \
@@ -49,11 +45,9 @@ void trigger_teleport_use(entity this, entity actor, entity trigger);
                if(deathmax.y < telefragmax.y) deathmax.y = telefragmax.y; \
                if(deathmax.z < telefragmax.z) deathmax.z = telefragmax.z; \
        } \
-       deathradius = max(vlen(deathmin), vlen(deathmax)); \
-       for(head = findradius(o, deathradius); head; head = head.chain) \
-               if(head != player) \
-                       if(head.takedamage) \
-                               if(boxesoverlap(deathmin, deathmax, head.absmin, head.absmax))
+       float deathradius = max(vlen(deathmin), vlen(deathmax)); \
+       for (entity head = findradius(o, deathradius); head; head = head.chain) \
+               if (head != player && head.takedamage && boxesoverlap(deathmin, deathmax, head.absmin, head.absmax))
 
 float check_tdeath(entity player, vector org, vector telefragmin, vector telefragmax);
 float tdeath_hit;
index 5ca5270..c22737e 100644 (file)
@@ -95,8 +95,7 @@ float CheatsAllowed(entity this, float i, int argc, float fr) // the cheat gets
 }
 
 #define BEGIN_CHEAT_FUNCTION() \
-       float cheating, attempting; \
-       cheating = 0; attempting = 0
+       float cheating = 0, attempting = 0
 #define DID_CHEAT() \
        ++cheating
 #define ADD_CHEATS(e,n) \