From 791f5e8ceaa56c6b14a8de7ab573292177cfd312 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 20 May 2017 20:28:51 +1000 Subject: [PATCH] Add an intrusive list for entities that save their team, and don't loop through pure entities when resetting the map --- .../gamemodes/gamemode/onslaught/sv_onslaught.qc | 1 + qcsrc/common/triggers/func/breakable.qc | 1 + qcsrc/common/triggers/trigger/multi.qc | 1 + qcsrc/common/triggers/trigger/relay_teamcheck.qc | 1 + qcsrc/server/command/vote.qc | 5 ++++- qcsrc/server/defs.qh | 3 +++ qcsrc/server/mutators/mutator/gamemode_assault.qc | 11 +++++------ qcsrc/server/spawnpoints.qc | 1 + 8 files changed, 17 insertions(+), 7 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc index f09e21fdb..5525c4d6a 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc @@ -1039,6 +1039,7 @@ void ons_GeneratorSetup(entity gen) // called when spawning a generator entity o gen.classname = "onslaught_generator"; gen.solid = SOLID_BBOX; gen.team_saved = teamnumber; + IL_PUSH(g_saved_team, gen); set_movetype(gen, MOVETYPE_NONE); gen.lasthealth = gen.max_health = gen.health = autocvar_g_onslaught_gen_health; gen.takedamage = DAMAGE_AIM; diff --git a/qcsrc/common/triggers/func/breakable.qc b/qcsrc/common/triggers/func/breakable.qc index dc2e6f7dc..81a610190 100644 --- a/qcsrc/common/triggers/func/breakable.qc +++ b/qcsrc/common/triggers/func/breakable.qc @@ -353,6 +353,7 @@ spawnfunc(func_breakable) precache_sound(this.noise1); this.team_saved = this.team; + IL_PUSH(g_saved_team, this); this.dropped_origin = this.origin; this.reset = func_breakable_reset; diff --git a/qcsrc/common/triggers/trigger/multi.qc b/qcsrc/common/triggers/trigger/multi.qc index 7aa13c13e..8f7305d6f 100644 --- a/qcsrc/common/triggers/trigger/multi.qc +++ b/qcsrc/common/triggers/trigger/multi.qc @@ -164,6 +164,7 @@ spawnfunc(trigger_multiple) EXACTTRIGGER_INIT; this.team_saved = this.team; + IL_PUSH(g_saved_team, this); if (this.health) { diff --git a/qcsrc/common/triggers/trigger/relay_teamcheck.qc b/qcsrc/common/triggers/trigger/relay_teamcheck.qc index 4f9dab7fd..fee28df51 100644 --- a/qcsrc/common/triggers/trigger/relay_teamcheck.qc +++ b/qcsrc/common/triggers/trigger/relay_teamcheck.qc @@ -30,6 +30,7 @@ void trigger_relay_teamcheck_reset(entity this) spawnfunc(trigger_relay_teamcheck) { this.team_saved = this.team; + IL_PUSH(g_saved_team, this); this.use = trigger_relay_teamcheck_use; this.reset = trigger_relay_teamcheck_reset; } diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index b6f38ed32..8d1763b73 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -344,7 +344,10 @@ void reset_map(bool dorespawn) MUTATOR_CALLHOOK(reset_map_global); - FOREACH_ENTITY_ORDERED(IS_NOT_A_CLIENT(it), { + FOREACH_ENTITY_FLOAT(pure_data, false, + { + if(IS_CLIENT(it)) + continue; if (it.reset) { it.reset(it); diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index c8e5f6263..11b915027 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -476,3 +476,6 @@ STATIC_INIT(g_ladders) { g_ladders = IL_NEW(); } IntrusiveList g_locations; STATIC_INIT(g_locations) { g_locations = IL_NEW(); } + +IntrusiveList g_saved_team; +STATIC_INIT(g_saved_team) { g_saved_team = IL_NEW(); } diff --git a/qcsrc/server/mutators/mutator/gamemode_assault.qc b/qcsrc/server/mutators/mutator/gamemode_assault.qc index 994a29719..350dc5d68 100644 --- a/qcsrc/server/mutators/mutator/gamemode_assault.qc +++ b/qcsrc/server/mutators/mutator/gamemode_assault.qc @@ -195,13 +195,12 @@ void assault_new_round(entity this) else assault_attacker_team = NUM_TEAM_1; - FOREACH_ENTITY_FLOAT(pure_data, false, + IL_EACH(g_saved_team, !IS_CLIENT(it), { - if(IS_CLIENT(it)) - continue; - - if (it.team_saved == NUM_TEAM_1) it.team_saved = NUM_TEAM_2; - else if (it.team_saved == NUM_TEAM_2) it.team_saved = NUM_TEAM_1; + if(it.team_saved == NUM_TEAM_1) + it.team_saved = NUM_TEAM_2; + else if(it.team_saved == NUM_TEAM_2) + it.team_saved = NUM_TEAM_1; }); // reset the level with a countdown diff --git a/qcsrc/server/spawnpoints.qc b/qcsrc/server/spawnpoints.qc index 84819efbe..3d62c149c 100644 --- a/qcsrc/server/spawnpoints.qc +++ b/qcsrc/server/spawnpoints.qc @@ -106,6 +106,7 @@ void relocate_spawnpoint(entity this) setthink(this, spawnpoint_think); this.nextthink = time + 0.5 + random() * 2; // shouldn't need it for a little second this.team_saved = this.team; + IL_PUSH(g_saved_team, this); if (!this.cnt) this.cnt = 1; -- 2.39.2