]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Kill a few FOREACH_ENTITY_CLASS cases
authorMario <mario@smbclan.net>
Sun, 21 Aug 2016 13:46:58 +0000 (23:46 +1000)
committerMario <mario@smbclan.net>
Sun, 21 Aug 2016 13:46:58 +0000 (23:46 +1000)
qcsrc/client/main.qh
qcsrc/common/gamemodes/gamemode/onslaught/cl_controlpoint.qc
qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qh
qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc
qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qh

index 71902647893ea6d3b14ec0dbc9b36cf615a6e299..9da7547299dd013e27e8e93731fc7599b70948f3 100644 (file)
@@ -76,9 +76,6 @@ STATIC_INIT(g_radarlinks) { g_radarlinks = IL_NEW(); }
 IntrusiveList g_radaricons;
 STATIC_INIT(g_radaricons) { g_radaricons = IL_NEW(); }
 
-IntrusiveList g_onsgenerators;
-STATIC_INIT(g_onsgenerators) { g_onsgenerators = IL_NEW(); }
-
 bool button_zoom;
 bool spectatorbutton_zoom;
 bool button_attack2;
index fb8cb71719a2e4acea5a10718a737eb4f54d50bb..ee348fdbc6244707f53e7b6202aae30cd6392ea7 100644 (file)
@@ -104,7 +104,7 @@ void cpicon_damage(entity this, float hp)
        setsize(this, CPICON_MIN, CPICON_MAX);
 }
 
-void cpicon_construct(entity this)
+void cpicon_construct(entity this, bool isnew)
 {
        this.netname = "Control Point Icon";
 
@@ -133,6 +133,9 @@ void cpicon_construct(entity this)
        this.cp_origin          = this.origin;
        this.cp_bob_origin      = '0 0 0.1';
        this.cp_bob_spd         = 0;
+
+       if(isnew)
+               IL_PUSH(g_drawables, this);
 }
 
 .vector glowmod;
@@ -174,7 +177,7 @@ NET_HANDLE(ENT_CLIENT_CONTROLPOINT_ICON, bool isnew)
                        this.count = (this.health - this.max_health) * frametime;
 
                cpicon_changeteam(this);
-               cpicon_construct(this);
+               cpicon_construct(this, isnew);
        }
 
        if(sf & CPSF_STATUS)
index be9b8203c61e60db594ea0579506e2c4ad9ca5f5..01ba8e708c357f4f68d76e9a6621b137379255c1 100644 (file)
@@ -2,3 +2,8 @@
 
 REGISTER_NET_LINKED(ENT_CLIENT_GENERATOR)
 REGISTER_NET_LINKED(ENT_CLIENT_CONTROLPOINT_ICON)
+
+#ifdef CSQC
+IntrusiveList g_onsgenerators;
+STATIC_INIT(g_onsgenerators) { g_onsgenerators = IL_NEW(); }
+#endif
index 2af0dd010c3676ba80b7b804c140e0d51ddce9f9..01aa023c416b105ec82791cc30f634949965e58d 100644 (file)
@@ -1463,21 +1463,21 @@ void havocbot_ons_reset_role(entity this)
 entity ons_Nearest_ControlPoint(entity this, vector pos, float max_dist)
 {
        entity closest_target = NULL;
-       FOREACH_ENTITY_CLASS("onslaught_controlpoint", true,
+       for(entity cp = ons_worldcplist; cp; cp = cp.ons_worldcpnext)
        {
-               if(SAME_TEAM(it, this))
-               if(it.iscaptured)
-               if(max_dist <= 0 || vdist(it.origin - pos, <=, max_dist))
-               if(vlen2(it.origin - pos) <= vlen2(closest_target.origin - pos) || closest_target == NULL)
-                       closest_target = it;
-       });
-       FOREACH_ENTITY_CLASS("onslaught_generator", true,
+               if(SAME_TEAM(cp, this))
+               if(cp.iscaptured)
+               if(max_dist <= 0 || vdist(cp.origin - pos, <=, max_dist))
+               if(vlen2(cp.origin - pos) <= vlen2(closest_target.origin - pos) || closest_target == NULL)
+                       closest_target = cp;
+       }
+       for(entity gen = ons_worldgeneratorlist; gen; gen = gen.ons_worldgeneratornext)
        {
-               if(SAME_TEAM(it, this))
-               if(max_dist <= 0 || vdist(it.origin - pos, <, max_dist))
-               if(vlen2(it.origin - pos) <= vlen2(closest_target.origin - pos) || closest_target == NULL)
-                       closest_target = it;
-       });
+               if(SAME_TEAM(gen, this))
+               if(max_dist <= 0 || vdist(gen.origin - pos, <, max_dist))
+               if(vlen2(gen.origin - pos) <= vlen2(closest_target.origin - pos) || closest_target == NULL)
+                       closest_target = gen;
+       }
 
        return closest_target;
 }
@@ -1493,35 +1493,35 @@ entity ons_Nearest_ControlPoint_2D(entity this, vector pos, float max_dist)
        vector delta;
        float smallest_distance = 0, distance;
 
-       FOREACH_ENTITY_CLASS("onslaught_controlpoint", true,
+       for(entity cp = ons_worldcplist; cp; cp = cp.ons_worldcpnext)
        {
-               delta = it.origin - pos;
+               delta = cp.origin - pos;
                delta_z = 0;
                distance = vlen(delta);
 
-               if(SAME_TEAM(it, this))
-               if(it.iscaptured)
+               if(SAME_TEAM(cp, this))
+               if(cp.iscaptured)
                if(max_dist <= 0 || distance <= max_dist)
                if(closest_target == NULL || distance <= smallest_distance )
                {
-                       closest_target = it;
+                       closest_target = cp;
                        smallest_distance = distance;
                }
-       });
-       FOREACH_ENTITY_CLASS("onslaught_generator", true,
+       }
+       for(entity gen = ons_worldgeneratorlist; gen; gen = gen.ons_worldgeneratornext)
        {
-               delta = it.origin - pos;
+               delta = gen.origin - pos;
                delta_z = 0;
                distance = vlen(delta);
 
-               if(SAME_TEAM(it, this))
+               if(SAME_TEAM(gen, this))
                if(max_dist <= 0 || distance <= max_dist)
                if(closest_target == NULL || distance <= smallest_distance )
                {
-                       closest_target = it;
+                       closest_target = gen;
                        smallest_distance = distance;
                }
-       });
+       }
 
        return closest_target;
 }
@@ -1531,17 +1531,17 @@ entity ons_Nearest_ControlPoint_2D(entity this, vector pos, float max_dist)
 int ons_Count_SelfControlPoints(entity this)
 {
        int n = 0;
-       FOREACH_ENTITY_CLASS("onslaught_controlpoint", true,
+       for(entity cp = ons_worldcplist; cp; cp = cp.ons_worldcpnext)
        {
-               if(SAME_TEAM(it, this))
-               if(it.iscaptured)
+               if(SAME_TEAM(cp, this))
+               if(cp.iscaptured)
                        n++;
-       });
-       FOREACH_ENTITY_CLASS("onslaught_generator", true,
+       }
+       for(entity gen = ons_worldgeneratorlist; gen; gen = gen.ons_worldgeneratornext)
        {
-               if(SAME_TEAM(it, this))
+               if(SAME_TEAM(gen, this))
                        n++;
-       });
+       }
        return n;
 }
 
index 70a5c8b6ba999078cb459c8933e2c11f7ab660e8..750ade34b412ece9a6b8a868c4cc747367407ae1 100644 (file)
@@ -44,7 +44,6 @@ const vector CPICON_OFFSET = ('0 0 96');
 // list of generators on the map
 entity ons_worldgeneratorlist;
 .entity ons_worldgeneratornext;
-.entity ons_stalegeneratornext;
 
 // list of control points on the map
 entity ons_worldcplist;