]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Give mines an intrusive list
authorMario <mario@smbclan.net>
Thu, 28 Jul 2016 12:52:49 +0000 (22:52 +1000)
committerMario <mario@smbclan.net>
Thu, 28 Jul 2016 12:52:49 +0000 (22:52 +1000)
qcsrc/common/weapons/weapon/minelayer.qc
qcsrc/server/defs.qh
qcsrc/server/weapons/selection.qc
qcsrc/server/weapons/weaponsystem.qc

index 8b1e0cd2e12bbc268551ee8a62e117483b621639..ff03633392de1711efaba1be038f303d54afec8c 100644 (file)
@@ -70,6 +70,7 @@ void W_MineLayer_Stick(entity this, entity to)
        // in order for mines to face properly when sticking to the ground, they must be a server side entity rather than a csqc projectile
 
        entity newmine = spawn();
+       IL_PUSH(g_mines, newmine);
        newmine.classname = this.classname;
 
        newmine.bot_dodge = this.bot_dodge;
@@ -203,9 +204,10 @@ void W_MineLayer_ProximityExplode(entity this)
 int W_MineLayer_Count(entity e)
 {
        int minecount = 0;
-       entity mine;
-       for(mine = NULL; (mine = find(mine, classname, "mine")); ) if(mine.realowner == e)
+       IL_EACH(g_mines, it.realowner == e,
+       {
                minecount += 1;
+       });
 
        return minecount;
 }
@@ -335,6 +337,7 @@ void W_MineLayer_Attack(Weapon thiswep, entity actor)
        Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
 
        mine = WarpZone_RefSys_SpawnSameRefSys(actor);
+       IL_PUSH(g_mines, mine);
        mine.owner = mine.realowner = actor;
        if(WEP_CVAR(minelayer, detonatedelay) >= 0)
                mine.spawnshieldtime = time + WEP_CVAR(minelayer, detonatedelay);
@@ -384,24 +387,23 @@ void W_MineLayer_Attack(Weapon thiswep, entity actor)
        actor.minelayer_mines = W_MineLayer_Count(actor);
 }
 
-float W_MineLayer_PlacedMines(entity this, float detonate)
+bool W_MineLayer_PlacedMines(entity this, bool detonate)
 {
-       entity mine;
-       float minfound = 0;
+       bool minfound = false;
 
-       for(mine = NULL; (mine = find(mine, classname, "mine")); ) if(mine.realowner == this)
+       IL_EACH(g_mines, it.realowner == this,
        {
                if(detonate)
                {
-                       if(!mine.minelayer_detonate)
+                       if(!it.minelayer_detonate)
                        {
-                               mine.minelayer_detonate = true;
-                               minfound = 1;
+                               it.minelayer_detonate = true;
+                               minfound = true;
                        }
                }
                else
-                       minfound = 1;
-       }
+                       minfound = true;
+       });
        return minfound;
 }
 
@@ -425,10 +427,8 @@ METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor))
         teamdamage = 0;
         enemydamage = 0;
 
-        FOREACH_ENTITY_ENT(realowner, actor,
+        IL_EACH(g_mines, it.realowner == actor,
         {
-               if(it.classname != "mine") continue;
-
                entity mine = it;
                FOREACH_ENTITY_FLOAT(bot_attack, true,
                {
@@ -452,10 +452,8 @@ METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor))
             desirabledamage = desirabledamage - teamdamage;
 
         makevectors(actor.v_angle);
-        FOREACH_ENTITY_ENT(realowner, actor,
+        IL_EACH(g_mines, it.realowner == actor,
         {
-            if(it.classname != "mine") continue;
-
             if(skill > 9) // normal players only do this for the target they are tracking
             {
                    entity mine = it;
index ae1e7068090be6c129fc3221d196ca1e30c5aeba..a626a35824d585d2e4e370e347e8c9213cc8fffc 100644 (file)
@@ -455,3 +455,6 @@ STATIC_INIT(g_vehicles) { g_vehicles = IL_NEW(); }
 
 IntrusiveList g_turrets;
 STATIC_INIT(g_turrets) { g_turrets = IL_NEW(); }
+
+IntrusiveList g_mines;
+STATIC_INIT(g_mines) { g_mines = IL_NEW(); }
index 0288347ee1f1e61bdaa47cc70b93479c04f2f02f..8e3e1075899707fdcf6248ce297f5e0394ec061d 100644 (file)
@@ -75,7 +75,7 @@ bool client_hasweapon(entity this, Weapon wpn, float andammo, bool complain)
 
                                // always allow selecting the Mine Layer if we placed mines, so that we can detonate them
                                if(wpn == WEP_MINE_LAYER)
-                                       FOREACH_ENTITY_CLASS("mine", it.owner == this,
+                                       IL_EACH(g_mines, it.owner == this,
                                        {
                                                f = 1;
                                                break; // no need to continue
index 7c8061e94e02d24cfd2e08510983296e89ea0ee1..71622545c6b99bcd7f137b880cdab86f18da0efc 100644 (file)
@@ -215,10 +215,9 @@ bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, bool secondary
        // always keep the Mine Layer if we placed mines, so that we can detonate them
        if (thiswep == WEP_MINE_LAYER)
        {
-               FOREACH_ENTITY_ENT(owner, actor,
+               IL_EACH(g_mines, it.owner == actor,
                {
-                       if(it.classname != "mine") continue;
-                       if(it.owner == actor) return false;
+                       return false;
                });
        }