From 09d344195532bd6b7a3868d0ad718589bfb065f2 Mon Sep 17 00:00:00 2001 From: Kano <89972582+kano-dot@users.noreply.github.com> Date: Tue, 2 Dec 2025 13:53:45 +0300 Subject: [PATCH] Fixes exoplanet turfs missing their light (#21632) ## About PR Carries light handling from `New()` to `Initialize()`. Also makes exoplanet theme generation handle lighting in itself, since it still didn't properly initialize the light. Gas/temperature property handling was left out because handling them in `Initialize()` was causing ZAS active edge issues for exoplanet ruins I am not entirely sure where the problem occurs, everything runs as it supposed to in proc call chain. My guess is `New()` is too early for setting up lights. Upon testing I didn't notice any changes in gas and temperature assignments in exoplanets, Odyssey and away site maps ## To-Do - [x] Look into `exoplanet_themes` and turfs affected by it, then find out why it got hands. Regular exoplanet turfs works fine, it's just this feature becoming an exception --- code/game/turfs/turf_changing.dm | 4 +- .../overmap/exoplanets/decor/_turfs.dm | 75 +++++++++++-------- .../overmap/exoplanets/themes/_theme.dm | 13 +++- .../kano-dot-exoplanet-lightening.yml | 7 ++ 4 files changed, 64 insertions(+), 35 deletions(-) create mode 100644 html/changelogs/kano-dot-exoplanet-lightening.yml diff --git a/code/game/turfs/turf_changing.dm b/code/game/turfs/turf_changing.dm index ed7a7f40f12..9badc58d1db 100644 --- a/code/game/turfs/turf_changing.dm +++ b/code/game/turfs/turf_changing.dm @@ -27,11 +27,11 @@ // exoplanet var/obj/effect/overmap/visitable/sector/exoplanet/exoplanet = GLOB.map_sectors["[z]"] if (istype(exoplanet) && istype(exoplanet.theme)) - exoplanet.theme.on_turf_generation(src, exoplanet.planetary_area) + exoplanet.theme.on_turf_generation(src, exoplanet.planetary_area, exoplanet) // away site var/datum/map_template/ruin/away_site/away_site = GLOB.map_templates["[z]"] if (istype(away_site) && istype(away_site.exoplanet_theme_base)) - away_site.exoplanet_theme_base.on_turf_generation(src, null) + away_site.exoplanet_theme_base.on_turf_generation(src, null, away_site) // Helper to change this turf into an appropriate openturf type, generally you should use this instead of ChangeTurf(/turf/simulated/open). /turf/proc/ChangeToOpenturf() diff --git a/code/modules/overmap/exoplanets/decor/_turfs.dm b/code/modules/overmap/exoplanets/decor/_turfs.dm index 3b0772ec47c..44221f0947b 100644 --- a/code/modules/overmap/exoplanets/decor/_turfs.dm +++ b/code/modules/overmap/exoplanets/decor/_turfs.dm @@ -13,36 +13,6 @@ var/diggable = 1 var/dirt_color = "#7c5e42" -/turf/simulated/floor/exoplanet/New() - // try to get the the atmos and area of the planet - if(SSatlas.current_map.use_overmap) - // if exoplanet - var/datum/site = GLOB.map_sectors["[z]"] - var/datum/template = GLOB.map_templates["[z]"] - if(istype(site, /obj/effect/overmap/visitable/sector/exoplanet)) - var/obj/effect/overmap/visitable/sector/exoplanet/exoplanet = site - if(exoplanet.atmosphere) - initial_gas = exoplanet.atmosphere.gas.Copy() - temperature = exoplanet.atmosphere.temperature - else - initial_gas = list() - temperature = T0C - //Must be done here, as light data is not fully carried over by ChangeTurf (but overlays are). - set_light(MINIMUM_USEFUL_LIGHT_RANGE, exoplanet.lightlevel, exoplanet.lightcolor) - if(exoplanet.planetary_area && istype(loc, world.area)) - change_area(loc, exoplanet.planetary_area) - // if away site - else if(istype(template, /datum/map_template/ruin/away_site)) - var/datum/map_template/ruin/away_site/away_site = template - if(away_site.exoplanet_atmosphere) - initial_gas = away_site.exoplanet_atmosphere.gas.Copy() - temperature = away_site.exoplanet_atmosphere.temperature - if(away_site.exoplanet_lightlevel && is_outside()) - set_light(MINIMUM_USEFUL_LIGHT_RANGE, away_site.exoplanet_lightlevel, away_site.exoplanet_lightcolor) - - // if not on an exoplanet, instead just keep the default or mapped in atmos - ..() - /turf/simulated/floor/exoplanet/attackby(obj/item/attacking_item, mob/user) if(diggable && istype(attacking_item, /obj/item/shovel)) visible_message(SPAN_NOTICE("\The [user] starts digging \the [src]")) @@ -74,11 +44,52 @@ if(prob(40)) ChangeTurf(get_base_turf_by_area(src)) -/turf/simulated/floor/exoplanet/Initialize() - . = ..() +/turf/simulated/floor/exoplanet/New() footprint_color = dirt_color update_icon(1) + if(SSatlas.current_map.use_overmap) + // if exoplanet + var/datum/site = GLOB.map_sectors["[z]"] + var/datum/template = GLOB.map_templates["[z]"] + if(istype(site, /obj/effect/overmap/visitable/sector/exoplanet)) + var/obj/effect/overmap/visitable/sector/exoplanet/exoplanet = site + if(exoplanet.atmosphere) + initial_gas = exoplanet.atmosphere.gas.Copy() + temperature = exoplanet.atmosphere.temperature + else + initial_gas = list() + temperature = T0C + + if(exoplanet.planetary_area && istype(loc, world.area)) + change_area(loc, exoplanet.planetary_area) + + // if away site + else if(istype(template, /datum/map_template/ruin/away_site)) + var/datum/map_template/ruin/away_site/away_site = template + if(away_site.exoplanet_atmosphere) + initial_gas = away_site.exoplanet_atmosphere.gas.Copy() + temperature = away_site.exoplanet_atmosphere.temperature + + ..() + +/turf/simulated/floor/exoplanet/Initialize() + . = ..() + if(SSatlas.current_map.use_overmap) + // if exoplanet + var/datum/site = GLOB.map_sectors["[z]"] + var/datum/template = GLOB.map_templates["[z]"] + if(istype(site, /obj/effect/overmap/visitable/sector/exoplanet)) + var/obj/effect/overmap/visitable/sector/exoplanet/exoplanet = site + // Must be done here, as light data is not fully carried over by ChangeTurf (but overlays are). + set_light(MINIMUM_USEFUL_LIGHT_RANGE, exoplanet.lightlevel, exoplanet.lightcolor) + + // if away site + else if(istype(template, /datum/map_template/ruin/away_site)) + var/datum/map_template/ruin/away_site/away_site = template + if(away_site.exoplanet_lightlevel && is_outside()) + set_light(MINIMUM_USEFUL_LIGHT_RANGE, away_site.exoplanet_lightlevel, away_site.exoplanet_lightcolor) + /turf/simulated/floor/exoplanet/update_icon(var/update_neighbors) if(initial_flooring) . = ..() diff --git a/code/modules/overmap/exoplanets/themes/_theme.dm b/code/modules/overmap/exoplanets/themes/_theme.dm index 44ed9c82588..d82acd2f109 100644 --- a/code/modules/overmap/exoplanets/themes/_theme.dm +++ b/code/modules/overmap/exoplanets/themes/_theme.dm @@ -335,13 +335,24 @@ CHECK_TICK -/datum/exoplanet_theme/proc/on_turf_generation(turf/T, area/use_area) +/datum/exoplanet_theme/proc/on_turf_generation(turf/T, area/use_area, property_owner) if(use_area && istype(T.loc, world.area)) T.change_area(T.loc, use_area) // Switch our generated turfs from world.area (space) to our chosen exoplanet area if(surface_color && is_type_in_list(T, surface_turfs)) T.color = surface_color + // we re-add lights here because somehow ChangeTurf() messes with lighting + // exoplanet + if(istype(property_owner, /obj/effect/overmap/visitable/sector/exoplanet)) + var/obj/effect/overmap/visitable/sector/exoplanet/exoplanet = property_owner + T.set_light(MINIMUM_USEFUL_LIGHT_RANGE, exoplanet.lightlevel, exoplanet.lightcolor) + // away_site + else if(istype(property_owner, /datum/map_template/ruin/away_site)) + var/datum/map_template/ruin/away_site/away_site = property_owner + if(away_site.exoplanet_lightlevel && T.is_outside()) + T.set_light(MINIMUM_USEFUL_LIGHT_RANGE, away_site.exoplanet_lightlevel, away_site.exoplanet_lightcolor) + var/turf/simulated/mineral/M = T if(use_area && istype(M)) M.mined_turf = use_area.base_turf diff --git a/html/changelogs/kano-dot-exoplanet-lightening.yml b/html/changelogs/kano-dot-exoplanet-lightening.yml new file mode 100644 index 00000000000..3cc2cfa69db --- /dev/null +++ b/html/changelogs/kano-dot-exoplanet-lightening.yml @@ -0,0 +1,7 @@ + +author: Kano + +delete-after: True + +changes: + - bugfix: "Fixed exoplanet turfs not properly initializing their own light."