From 2ade62ff93863452f613dfdb9588ea140a80b571 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Mon, 26 Jun 2023 22:47:07 +0200 Subject: [PATCH] [MIRROR] Fixes a runtime in atom init management [MDB IGNORE] (#21984) Fixes a runtime in atom init management Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: GoldenAlpharex --- code/controllers/subsystem/atoms.dm | 4 +++- code/modules/mapping/reader.dm | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/code/controllers/subsystem/atoms.dm b/code/controllers/subsystem/atoms.dm index 63fe801d7b0..14e58869389 100644 --- a/code/controllers/subsystem/atoms.dm +++ b/code/controllers/subsystem/atoms.dm @@ -175,7 +175,9 @@ SUBSYSTEM_DEF(atoms) initialized = state /datum/controller/subsystem/atoms/proc/clear_tracked_initalize(source) - for(var/i in length(initialized_state) to 1) + if(!length(initialized_state)) + return + for(var/i in length(initialized_state) to 1 step -1) if(initialized_state[i][1] == source) initialized_state.Cut(i, i+1) break diff --git a/code/modules/mapping/reader.dm b/code/modules/mapping/reader.dm index d620ddfb69a..a1ef04e204f 100644 --- a/code/modules/mapping/reader.dm +++ b/code/modules/mapping/reader.dm @@ -107,6 +107,9 @@ /// Pulls out model paths for DMM var/static/regex/model_path = new(@'(\/[^\{]*?(?:\{.*?\})?)(?:,|$)', "g") + /// If we are currently loading this map + var/loading = FALSE + #ifdef TESTING var/turfsSkipped = 0 #endif @@ -249,9 +252,13 @@ #define MAPLOADING_CHECK_TICK \ if(TICK_CHECK) { \ - SSatoms.map_loader_stop(REF(src)); \ - stoplag(); \ - SSatoms.map_loader_begin(REF(src)); \ + if(loading) { \ + SSatoms.map_loader_stop(REF(src)); \ + stoplag(); \ + SSatoms.map_loader_begin(REF(src)); \ + } else { \ + stoplag(); \ + } \ } // Do not call except via load() above. @@ -259,6 +266,7 @@ PRIVATE_PROC(TRUE) // Tell ss atoms that we're doing maploading // We'll have to account for this in the following tick_checks so it doesn't overflow + loading = TRUE SSatoms.map_loader_begin(REF(src)) // Loading used to be done in this proc @@ -273,6 +281,7 @@ // And we are done lads, call it off SSatoms.map_loader_stop(REF(src)) + loading = FALSE if(new_z) for(var/z_index in bounds[MAP_MINZ] to bounds[MAP_MAXZ])