From 6965437c2085de3ed771480d4bb95416c347653d Mon Sep 17 00:00:00 2001
From: Mario <mario@smbclan.net>
Date: Mon, 22 Aug 2016 17:56:53 +1000
Subject: [PATCH] Some more intrusiveness

---
 qcsrc/common/turrets/targettrigger.qc |  3 ++-
 qcsrc/common/vehicles/sv_vehicles.qc  | 20 ++++++++++----------
 qcsrc/common/vehicles/sv_vehicles.qh  |  3 +++
 3 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/qcsrc/common/turrets/targettrigger.qc b/qcsrc/common/turrets/targettrigger.qc
index f2a97d4a12..152a7d6a27 100644
--- a/qcsrc/common/turrets/targettrigger.qc
+++ b/qcsrc/common/turrets/targettrigger.qc
@@ -5,7 +5,8 @@ void turret_targettrigger_touch(entity this, entity toucher);
 void turret_targettrigger_touch(entity this, entity toucher)
 {
     if (this.cnt > time) return;
-    FOREACH_ENTITY_STRING_ORDERED(targetname, this.target, {
+    IL_EACH(g_turrets, it.targetname == this.target,
+    {
         if (!(it.turret_flags & TUR_FLAG_RECIEVETARGETS)) continue;
         if (!it.turret_addtarget) continue;
         it.turret_addtarget(it, toucher, this);
diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc
index a010ba2c44..cf1f642d4f 100644
--- a/qcsrc/common/vehicles/sv_vehicles.qc
+++ b/qcsrc/common/vehicles/sv_vehicles.qc
@@ -433,17 +433,15 @@ void vehicles_reset_colors(entity this)
 void vehicles_clearreturn(entity veh)
 {
 	// Remove "return helper" entities, if any.
-	FOREACH_ENTITY_ENT(wp00, veh,
+	IL_EACH(g_vehicle_returners, it.wp00 == veh,
 	{
-		if(it.classname == "vehicle_return")
-		{
-			it.classname = "";
-			setthink(it, SUB_Remove);
-			it.nextthink = time + 0.1;
+		it.classname = "";
+		setthink(it, SUB_Remove);
+		it.nextthink = time + 0.1;
+		IL_REMOVE(g_vehicle_returners, it);
 
-			if(it.waypointsprite_attached)
-				WaypointSprite_Kill(it.waypointsprite_attached);
-		}
+		if(it.waypointsprite_attached)
+			WaypointSprite_Kill(it.waypointsprite_attached);
 	});
 }
 
@@ -513,6 +511,7 @@ void vehicles_setreturn(entity veh)
 	vehicles_clearreturn(veh);
 
 	entity ret = new(vehicle_return);
+	IL_PUSH(g_vehicle_returners, ret);
 	ret.wp00	   = veh;
 	ret.team		= veh.team;
 	setthink(ret, vehicles_showwp);
@@ -1076,8 +1075,9 @@ void vehicles_spawn(entity this)
 	this.solid				= SOLID_SLIDEBOX;
 	this.takedamage			= DAMAGE_AIM;
 	this.deadflag			= DEAD_NO;
+	if(!this.bot_attack)
+		IL_PUSH(g_bot_targets, this);
 	this.bot_attack			= true;
-	IL_PUSH(g_bot_targets, this);
 	this.flags				= FL_NOTARGET;
 	this.avelocity			= '0 0 0';
 	this.velocity			= '0 0 0';
diff --git a/qcsrc/common/vehicles/sv_vehicles.qh b/qcsrc/common/vehicles/sv_vehicles.qh
index 158191f654..948427db33 100644
--- a/qcsrc/common/vehicles/sv_vehicles.qh
+++ b/qcsrc/common/vehicles/sv_vehicles.qh
@@ -108,4 +108,7 @@ bool vehicle_impulse(entity this, int imp);
 bool vehicles_crushable(entity e);
 float vehicle_altitude(entity this, float amax);
 
+IntrusiveList g_vehicle_returners;
+STATIC_INIT(g_vehicle_returners) { g_vehicle_returners = IL_NEW(); }
+
 #endif
-- 
2.39.5