From: Mario Date: Thu, 28 Jul 2016 12:52:49 +0000 (+1000) Subject: Give mines an intrusive list X-Git-Tag: xonotic-v0.8.2~752^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=41034429a7bc5fe6b310e2337205c666b950dd19;p=xonotic%2Fxonotic-data.pk3dir.git Give mines an intrusive list --- diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index 8b1e0cd2e..ff0363339 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -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; diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index ae1e70680..a626a3582 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -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(); } diff --git a/qcsrc/server/weapons/selection.qc b/qcsrc/server/weapons/selection.qc index 0288347ee..8e3e10758 100644 --- a/qcsrc/server/weapons/selection.qc +++ b/qcsrc/server/weapons/selection.qc @@ -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 diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 7c8061e94..71622545c 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -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; }); }