From c59496b35cfec7cc88ee50fc3b446df19670c6e4 Mon Sep 17 00:00:00 2001 From: Kashargul <144968721+Kashargul@users.noreply.github.com> Date: Sun, 9 Feb 2025 00:08:36 +0100 Subject: [PATCH] changes change Turf, see PR#3726 (#10078) --- code/game/turfs/turf_changing.dm | 91 ++++++++--------------- code/modules/lighting/lighting_overlay.dm | 2 + 2 files changed, 32 insertions(+), 61 deletions(-) diff --git a/code/game/turfs/turf_changing.dm b/code/game/turfs/turf_changing.dm index 81dca41144..6d9b1ac56c 100644 --- a/code/game/turfs/turf_changing.dm +++ b/code/game/turfs/turf_changing.dm @@ -77,70 +77,39 @@ cut_overlays(TRUE) RemoveElement(/datum/element/turf_z_transparency) + changing_turf = TRUE + qdel(src) - var/turf/new_turf //CHOMPEdit + var/turf/W = new N( locate(src.x, src.y, src.z) ) if(ispath(N, /turf/simulated/floor)) - //CHOMPEdit Begin - var/turf/simulated/W = new N( locate(src.x, src.y, src.z), is_turfchange=TRUE ) - W.lighting_corners_initialised = old_lighting_corners_initialized - if(old_shandler) - W.shandler = old_shandler - old_shandler.holder = W - else if((SSplanets && SSplanets.z_to_planet.len >= z && SSplanets.z_to_planet[z]) && has_dynamic_lighting()) - W.shandler = new(src) - W.shandler.manualInit() - //CHOMPEdit End if(old_fire) - fire = old_fire + W.fire = old_fire + W.RemoveLattice() + //CHOMPEdit Begin + W.lighting_corners_initialised = old_lighting_corners_initialized + var/turf/simulated/W_sim = W + if(istype(W_sim) && old_shandler) + W_sim.shandler = old_shandler + old_shandler.holder = W + else if(istype(W_sim) && (SSplanets && SSplanets.z_to_planet.len >= z && SSplanets.z_to_planet[z]) && has_dynamic_lighting()) + W_sim.shandler = new(src) + W_sim.shandler.manualInit() + //CHOMPEdit End + if(old_fire) + old_fire.RemoveFire() - if (istype(W,/turf/simulated/floor)) - W.RemoveLattice() + if(tell_universe) + universe.OnTurfChange(W) - if(tell_universe) - universe.OnTurfChange(W) - - if(SSair) - SSair.mark_for_update(src) //handle the addition of the new turf. - - for(var/turf/space/S in range(W,1)) - S.update_starlight() - - W.levelupdate() - W.update_icon(1) - W.post_change() - new_turf = W //CHOMPEdit - . = W - - else - //CHOMPEdit Begin - var/turf/W = new N( locate(src.x, src.y, src.z), is_turfchange=TRUE ) - W.lighting_corners_initialised = old_lighting_corners_initialized - var/turf/simulated/W_sim = W - if(istype(W_sim) && old_shandler) - W_sim.shandler = old_shandler - old_shandler.holder = W - else if(istype(W_sim) && (SSplanets && SSplanets.z_to_planet.len >= z && SSplanets.z_to_planet[z]) && has_dynamic_lighting()) - W_sim.shandler = new(src) - W_sim.shandler.manualInit() - //CHOMPEdit End - if(old_fire) - old_fire.RemoveFire() - - if(tell_universe) - universe.OnTurfChange(W) - - if(SSair) - SSair.mark_for_update(src) - - for(var/turf/space/S in range(W,1)) - S.update_starlight() - - W.levelupdate() - W.update_icon(1) - W.post_change() - new_turf = W //CHOMPEdit - . = W + if(SSair) + SSair.mark_for_update(W) + for(var/turf/space/S in range(W, 1)) + S.update_starlight() + W.levelupdate() + W.update_icon(1) + W.post_change() + . = W dangerous_objects = old_dangerous_objects @@ -177,10 +146,10 @@ if(SUNLIGHT_ONLY_SHADE) vis_contents += sim_self.shandler.pshandler.vis_shade - var/is_open = istype(new_turf,/turf/simulated/open) + var/is_open = istype(W,/turf/simulated/open) - propogate_sunlight_changes(oldtype, old_density, new_turf) + propogate_sunlight_changes(oldtype, old_density, W) var/turf/simulated/cur_turf = src if(istype(cur_turf) && is_open != was_open) do @@ -189,7 +158,7 @@ cur_turf.make_outdoors() else cur_turf.make_indoors() - cur_turf.propogate_sunlight_changes(oldtype, old_density, new_turf, above = TRUE) + cur_turf.propogate_sunlight_changes(oldtype, old_density, W, above = TRUE) while(istype(cur_turf,/turf/simulated/open) && HasBelow(cur_turf.z)) //CHOMPEdit End diff --git a/code/modules/lighting/lighting_overlay.dm b/code/modules/lighting/lighting_overlay.dm index 9cc4e267c2..b5eb4921e6 100644 --- a/code/modules/lighting/lighting_overlay.dm +++ b/code/modules/lighting/lighting_overlay.dm @@ -112,6 +112,8 @@ //CHOMPEdit Begin /datum/lighting_object/proc/update_sun() + if(QDELETED(src)) + return //Used to have more code here, but it became redundant. affected_turf.set_luminosity(1)