From 25eb98d085bf9b1d6f2738712799f05397593380 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 21 Aug 2016 23:46:58 +1000 Subject: [PATCH] Kill a few FOREACH_ENTITY_CLASS cases --- qcsrc/client/main.qh | 3 - .../gamemode/onslaught/cl_controlpoint.qc | 7 ++- .../gamemodes/gamemode/onslaught/onslaught.qh | 5 ++ .../gamemode/onslaught/sv_onslaught.qc | 62 +++++++++---------- .../gamemode/onslaught/sv_onslaught.qh | 1 - 5 files changed, 41 insertions(+), 37 deletions(-) diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index 719026478..9da754729 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -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; diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/cl_controlpoint.qc b/qcsrc/common/gamemodes/gamemode/onslaught/cl_controlpoint.qc index fb8cb7171..ee348fdbc 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/cl_controlpoint.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/cl_controlpoint.qc @@ -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) diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qh b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qh index be9b8203c..01ba8e708 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qh +++ b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qh @@ -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 diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc index 2af0dd010..01aa023c4 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc @@ -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; } diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qh b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qh index 70a5c8b6b..750ade34b 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qh +++ b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qh @@ -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; -- 2.39.2