From c0add59c57c00b31e0db86871ad776ffacc9165e Mon Sep 17 00:00:00 2001 From: terencehill Date: Wed, 31 Mar 2021 01:23:53 +0200 Subject: [PATCH] Create the g_race_targets, g_racecheckpoints and g_kaballs intrusive lists only when needed --- qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc | 1 + qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qh | 1 - .../gamemode/domination/sv_domination.qc | 2 ++ .../gamemode/domination/sv_domination.qh | 2 -- .../gamemodes/gamemode/keepaway/sv_keepaway.qc | 1 + .../gamemodes/gamemode/keepaway/sv_keepaway.qh | 4 +--- .../gamemode/onslaught/sv_onslaught.qc | 1 + .../gamemode/onslaught/sv_onslaught.qh | 1 - qcsrc/server/race.qc | 17 ++++++++++++----- 9 files changed, 18 insertions(+), 12 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc index 8ec8613cc2..904d26e8f8 100644 --- a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc +++ b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc @@ -2826,6 +2826,7 @@ void ctf_DelayedInit(entity this) // Do this check with a delay so we can wait f void ctf_Initialize() { + CTF_FLAG = NEW(Flag); record_type = CTF_RECORD; ctf_captimerecord = stof(db_get(ServerProgsDB, strcat(GetMapname(), "/captimerecord/time"))); diff --git a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qh b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qh index 5c55350cb3..519cbd0648 100644 --- a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qh +++ b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qh @@ -20,7 +20,6 @@ REGISTER_MUTATOR(ctf, false) MUTATOR_STATIC(); MUTATOR_ONADD { - CTF_FLAG = NEW(Flag); GameRules_teams(true); GameRules_limit_score(autocvar_capturelimit_override); GameRules_limit_lead(autocvar_captureleadlimit_override); diff --git a/qcsrc/common/gamemodes/gamemode/domination/sv_domination.qc b/qcsrc/common/gamemodes/gamemode/domination/sv_domination.qc index 4c20846565..ca782cedbb 100644 --- a/qcsrc/common/gamemodes/gamemode/domination/sv_domination.qc +++ b/qcsrc/common/gamemodes/gamemode/domination/sv_domination.qc @@ -671,5 +671,7 @@ void dom_DelayedInit(entity this) // Do this check with a delay so we can wait f void dom_Initialize() { g_domination = true; + g_dompoints = IL_NEW(); + InitializeEntity(NULL, dom_DelayedInit, INITPRIO_GAMETYPE); } diff --git a/qcsrc/common/gamemodes/gamemode/domination/sv_domination.qh b/qcsrc/common/gamemodes/gamemode/domination/sv_domination.qh index e937a958ed..bb75feced5 100644 --- a/qcsrc/common/gamemodes/gamemode/domination/sv_domination.qh +++ b/qcsrc/common/gamemodes/gamemode/domination/sv_domination.qh @@ -14,8 +14,6 @@ REGISTER_MUTATOR(dom, false) MUTATOR_STATIC(); MUTATOR_ONADD { - g_dompoints = IL_NEW(); - int fraglimit_override = autocvar_g_domination_point_limit; if (autocvar_g_domination_roundbased && autocvar_g_domination_roundbased_point_limit) fraglimit_override = autocvar_g_domination_roundbased_point_limit; diff --git a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc index 7239f9e7a4..6952f31389 100644 --- a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc +++ b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc @@ -267,6 +267,7 @@ void ka_Handler_CheckBall(entity this) void ka_Initialize() // run at the start of a match, initiates game mode { + g_kaballs = IL_NEW(); ka_Handler = new_pure(ka_Handler); setthink(ka_Handler, ka_Handler_CheckBall); ka_Handler.nextthink = time; diff --git a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qh b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qh index 32387a336a..a06960078e 100644 --- a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qh +++ b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qh @@ -4,6 +4,7 @@ #include void ka_Initialize(); +IntrusiveList g_kaballs; REGISTER_MUTATOR(ka, false) { MUTATOR_STATIC(); @@ -24,9 +25,6 @@ const int KA_BALL_COUNT = 1; entity ka_Handler; -IntrusiveList g_kaballs; -STATIC_INIT(g_kaballs) { g_kaballs = IL_NEW(); } - void(entity this) havocbot_role_ka_carrier; void(entity this) havocbot_role_ka_collector; diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc index c9f2ea740a..db39a8a395 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc @@ -2180,6 +2180,7 @@ void ons_DelayedInit(entity this) // Do this check with a delay so we can wait f void ons_Initialize() { g_onslaught = true; + g_onsshields = IL_NEW(); ons_captureshield_force = autocvar_g_onslaught_shield_force; cam = new(objective_camera); diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qh b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qh index d472dd9995..1f98522ba7 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qh +++ b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qh @@ -11,7 +11,6 @@ REGISTER_MUTATOR(ons, false) MUTATOR_STATIC(); MUTATOR_ONADD { - g_onsshields = IL_NEW(); GameRules_teams(true); GameRules_limit_score(autocvar_g_onslaught_point_limit); diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index 472a8ec4f6..c940afb94d 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -66,11 +66,6 @@ void write_recordmarker(entity pl, float tstart, float dt) IntrusiveList g_race_targets; IntrusiveList g_racecheckpoints; -STATIC_INIT(g_race) -{ - g_race_targets = IL_NEW(); - g_racecheckpoints = IL_NEW(); -} void race_InitSpectator() { @@ -1091,8 +1086,14 @@ spawnfunc(trigger_race_checkpoint) this.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player; this.spawn_evalfunc = trigger_race_checkpoint_spawn_evalfunc; + if (!g_racecheckpoints) + g_racecheckpoints = IL_NEW(); IL_PUSH(g_racecheckpoints, this); + // trigger_race_checkpoint_verify checks this list too + if (!g_race_targets) + g_race_targets = IL_NEW(); + InitializeEntity(this, trigger_race_checkpoint_verify, INITPRIO_FINDTARGET); } @@ -1136,8 +1137,14 @@ void target_checkpoint_setup(entity this) race_timed_checkpoint = 1; + if (!g_race_targets) + g_race_targets = IL_NEW(); IL_PUSH(g_race_targets, this); + // trigger_race_checkpoint_verify checks this list too + if (!g_racecheckpoints) + g_racecheckpoints = IL_NEW(); + InitializeEntity(this, trigger_race_checkpoint_verify, INITPRIO_FINDTARGET); } -- 2.39.2