From: terencehill Date: Tue, 30 Mar 2021 23:23:53 +0000 (+0200) Subject: Create the g_race_targets, g_racecheckpoints and g_kaballs intrusive lists only when... X-Git-Tag: xonotic-v0.8.5~476 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c0add59c57c00b31e0db86871ad776ffacc9165e;p=xonotic%2Fxonotic-data.pk3dir.git Create the g_race_targets, g_racecheckpoints and g_kaballs intrusive lists only when needed --- diff --git a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc index 8ec8613cc..904d26e8f 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 5c55350cb..519cbd064 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 4c2084656..ca782cedb 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 e937a958e..bb75feced 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 7239f9e7a..6952f3138 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 32387a336..a06960078 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 c9f2ea740..db39a8a39 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 d472dd999..1f98522ba 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 472a8ec4f..c940afb94 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); }