From bd75f38fd6a2cdfef075e5bb2b690c4f54d6da3e Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Tue, 27 Oct 2020 03:22:25 +0100 Subject: [PATCH] [MIRROR] Initialize and LateInitialize runs correctly at round start (#1478) * Initialize and LateInitialize runs correctly at round start (#54594) I've been pulling my hair out on this one. Ever since I started my ntnet project, I could never get LateInitalize to work right. Apparently it has never worked right. How it was set up before on server start Station map loads, Does NOT run Initialize(mapload = TRUE) Generates space, lavaland/icebox ruins Loads a ruin, DOES run Initialize(mapload = TRUE) EXCEPT on areas End of mapping system Atom system Initialized and it checks and runs Initialize(mapload = TRUE) on world You see the issue? Initialize and by extension LateInitialize is run in blocks. Worst, LateInitialize is run on turfs FIRST in ruins BEFORE Initialize is ever run on the other atoms. While there isn't much in Area, there is map_generator so I am sure it caused some grief for map creators. The NEW order now is Station map loads, Does NOT run Initialize(mapload = TRUE) Generates space, lavaland/icebox ruins Loads a ruin, Does NOT run Initialize(mapload = TRUE) End of mapping system Atom system Initialized and it checks and runs Initialize(mapload = TRUE) on world Also if you dynamicly load a map, like snowdin or such, it will Initialize all atoms at once and then run LateInitialize properly * Initialize and LateInitialize runs correctly at round start Co-authored-by: WarlockD --- code/controllers/subsystem/atoms.dm | 7 ++++++- code/modules/mapping/map_template.dm | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/code/controllers/subsystem/atoms.dm b/code/controllers/subsystem/atoms.dm index 40841f30f04..4e4543388c8 100644 --- a/code/controllers/subsystem/atoms.dm +++ b/code/controllers/subsystem/atoms.dm @@ -14,17 +14,22 @@ SUBSYSTEM_DEF(atoms) var/list/BadInitializeCalls = list() + initialized = INITIALIZATION_INSSATOMS + /datum/controller/subsystem/atoms/Initialize(timeofday) GLOB.fire_overlay.appearance_flags = RESET_COLOR setupGenetics() //to set the mutations' sequence + initialized = INITIALIZATION_INNEW_MAPLOAD InitializeAtoms() + initialized = INITIALIZATION_INNEW_REGULAR return ..() /datum/controller/subsystem/atoms/proc/InitializeAtoms(list/atoms) if(initialized == INITIALIZATION_INSSATOMS) return + old_initialized = initialized initialized = INITIALIZATION_INNEW_MAPLOAD var/count @@ -47,7 +52,7 @@ SUBSYSTEM_DEF(atoms) testing("Initialized [count] atoms") pass(count) - initialized = INITIALIZATION_INNEW_REGULAR + initialized = old_initialized if(late_loaders.len) for(var/I in late_loaders) diff --git a/code/modules/mapping/map_template.dm b/code/modules/mapping/map_template.dm index 9faa709c0b1..1f3472c7ba5 100644 --- a/code/modules/mapping/map_template.dm +++ b/code/modules/mapping/map_template.dm @@ -55,8 +55,9 @@ atmos_machines += A SSmapping.reg_in_areas_in_z(areas) - SSatoms.InitializeAtoms(turfs) - SSatoms.InitializeAtoms(atoms) + SSatoms.InitializeAtoms(areas + turfs + atoms) + // NOTE, now that Initialize and LateInitialize run correctly, do we really + // need these two below? SSmachines.setup_template_powernets(cables) SSair.setup_template_machinery(atmos_machines)