From 07d483203daf73c50142ccdd7dfc301aaff98793 Mon Sep 17 00:00:00 2001 From: Leshana Date: Thu, 25 Jun 2020 10:36:16 -0400 Subject: [PATCH] Fix sector initialization stack overflow crash. - Replace changes from 8c7371c5d4b900308cecdba5335989e8c9f191fe - Removed debugging prints in skybox generation - Reverted change to GetConnnectedZLevels to avoid the chicken-or-egg initialization issue of find_z_levels() requiring knowledge of a sector's z-levels during the attempt to determine a sector's z-levels. - Make find_z_levels() always called again so that lazy open space initialization works on landable ships again. - Instead, allow static configuration of sector map_z to override the default behavior of calling GetConnectedZLevels() --- code/controllers/subsystems/skybox.dm | 6 +----- code/modules/multiz/basic.dm | 2 -- code/modules/overmap/sectors.dm | 8 ++++---- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/code/controllers/subsystems/skybox.dm b/code/controllers/subsystems/skybox.dm index 09f0081533..356458517d 100644 --- a/code/controllers/subsystems/skybox.dm +++ b/code/controllers/subsystems/skybox.dm @@ -71,8 +71,6 @@ SUBSYSTEM_DEF(skybox) return skybox_cache["[z]"] /datum/controller/subsystem/skybox/proc/generate_skybox(z) - to_world("generating skybox for z[z]") - var/datum/skybox_settings/settings = global.using_map.get_skybox_datum(z) var/image/res = image(settings.icon) @@ -91,12 +89,10 @@ SUBSYSTEM_DEF(skybox) if(global.using_map.use_overmap && settings.use_overmap_details) var/obj/effect/overmap/visitable/O = get_overmap_sector(z) if(istype(O)) - to_world("found sector [O] \ref[O] for z[z]") var/image/overmap = image(settings.icon) overmap.overlays += O.generate_skybox() for(var/obj/effect/overmap/visitable/other in O.loc) if(other != O) - to_world("found secondary sector [other] \ref[other]") overmap.overlays += other.get_skybox_representation() overmap.appearance_flags = RESET_COLOR res.overlays += overmap @@ -121,7 +117,7 @@ SUBSYSTEM_DEF(skybox) var/icon_state = "dyable" var/color var/random_color = FALSE - + var/use_stars = TRUE var/star_icon = 'icons/skybox/skybox.dmi' var/star_state = "stars" diff --git a/code/modules/multiz/basic.dm b/code/modules/multiz/basic.dm index 92bfe2a480..62ffc46518 100644 --- a/code/modules/multiz/basic.dm +++ b/code/modules/multiz/basic.dm @@ -37,8 +37,6 @@ var/list/z_levels = list()// Each bit re... haha just kidding this is a list of return HasBelow(turf.z) ? get_step(turf, DOWN) : null /proc/GetConnectedZlevels(z) - if(z in using_map.map_levels) - return using_map.get_map_levels(z, FALSE) // Connected z levels aren't necessarily attached by multi-z, using_map shound know the details . = list(z) for(var/level = z, HasBelow(level), level--) . |= level-1 diff --git a/code/modules/overmap/sectors.dm b/code/modules/overmap/sectors.dm index dcad9796cc..e0f2ac4afc 100644 --- a/code/modules/overmap/sectors.dm +++ b/code/modules/overmap/sectors.dm @@ -5,7 +5,7 @@ name = "map object" scannable = TRUE - var/list/map_z = null + var/list/map_z = list() var/list/extra_z_levels //if you need to manually insist that these z-levels are part of this sector, for things like edge-of-map step trigger transitions rather than multi-z complexes var/list/initial_generic_waypoints //store landmark_tag of landmarks that should be added to the actual lists below on init. @@ -30,8 +30,7 @@ if(. == INITIALIZE_HINT_QDEL) return - if(!map_z) // If map_z is already defined, we don't need to find where we are - find_z_levels() // This populates map_z and assigns z levels to the ship. + find_z_levels() // This populates map_z and assigns z levels to the ship. register_z_levels() // This makes external calls to update global z level information. if(!global.using_map.overmap_z) @@ -59,7 +58,8 @@ . += A /obj/effect/overmap/visitable/proc/find_z_levels() - map_z = GetConnectedZlevels(z) + if(!LAZYLEN(map_z)) // If map_z is already populated use it as-is, otherwise start with connected z-levels. + map_z = GetConnectedZlevels(z) if(LAZYLEN(extra_z_levels)) map_z |= extra_z_levels