From 3502cd4664691d8381a6b28d9fb1e80f7f1e1382 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 21 Aug 2016 23:15:25 +1000 Subject: [PATCH] Add intrusive lists for some client side stuff --- qcsrc/client/main.qh | 3 +++ qcsrc/client/view.qc | 5 +++-- qcsrc/common/effects/qc/rubble.qh | 8 ++++++-- qcsrc/common/gamemodes/gamemode/onslaught/cl_generator.qc | 7 +++++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index 9da754729..719026478 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -76,6 +76,9 @@ 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/client/view.qc b/qcsrc/client/view.qc index 222620052..c60dbb8e4 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1500,9 +1500,10 @@ void CSQC_UpdateView(entity this, float w, float h) } } - if(ons_roundlost) + if(ons_roundlost) // TODO: move this junk to a client mutator for onslaught (possible using the WantEventchase hook) { - FOREACH_ENTITY_CLASS("onslaught_generator", it.health <= 0, { + IL_EACH(g_onsgenerators, it.health <= 0, + { gen = it; break; }); diff --git a/qcsrc/common/effects/qc/rubble.qh b/qcsrc/common/effects/qc/rubble.qh index 83a694121..dd3785b68 100644 --- a/qcsrc/common/effects/qc/rubble.qh +++ b/qcsrc/common/effects/qc/rubble.qh @@ -5,7 +5,10 @@ entityclass(Rubble); class(Rubble).float creationtime; -void RubbleLimit(string cname, float limit, void(entity) deleteproc) +IntrusiveList g_rubble; +STATIC_INIT(g_rubble) { g_rubble = IL_NEW(); } + +void RubbleLimit(string cname, int limit, void(entity) deleteproc) { // remove rubble of the same type if it's at the limit // remove multiple rubble if the limit has been decreased @@ -17,7 +20,7 @@ void RubbleLimit(string cname, float limit, void(entity) deleteproc) entity oldest = NULL; float oldesttime = 0; // compare to all other matching entities - FOREACH_ENTITY_CLASS(cname, true, + IL_EACH(g_rubble, it.classname == cname, { ++c; if(!oldest || oldesttime > it.creationtime) @@ -41,6 +44,7 @@ entity RubbleNew(string cname) entity e = spawn(); e.classname = cname; e.creationtime = time; + IL_PUSH(g_rubble, e); return e; } diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/cl_generator.qc b/qcsrc/common/gamemodes/gamemode/onslaught/cl_generator.qc index 2b9470f77..cbba9a9aa 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/cl_generator.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/cl_generator.qc @@ -143,11 +143,14 @@ void generator_damage(entity this, float hp) setsize(this, GENERATOR_MIN, GENERATOR_MAX); } -void generator_construct(entity this) +void generator_construct(entity this, bool isnew) { this.netname = "Generator"; this.classname = "onslaught_generator"; + if(isnew) + IL_PUSH(g_onsgenerators, this); + setorigin(this, this.origin); setmodel(this, MDL_ONS_GEN); setsize(this, GENERATOR_MIN, GENERATOR_MAX); @@ -199,7 +202,7 @@ NET_HANDLE(ENT_CLIENT_GENERATOR, bool isnew) this.count = 40; generator_changeteam(this); - generator_construct(this); + generator_construct(this, isnew); } if(sf & GSF_STATUS) -- 2.39.2