From b6265096226b4d1cefe69df08cc66a413484f178 Mon Sep 17 00:00:00 2001 From: SmArtKar <44720187+SmArtKar@users.noreply.github.com> Date: Mon, 21 Apr 2025 02:54:09 +0200 Subject: [PATCH] [MDB IGNORE] Implements an automatic nearstation area tiler (#90660) ## About The Pull Request Space turfs will now assign the nearspace area to themselves whenever they're replaced, or lattice or catwalks are placed ontop of them. This fixes lighting missing from player-created space structures until they create a custom area, and resolves a similar issue with shuttle ceilings. To track this we had ceilings spawn the "shit be fucked" marker whenever they were created outside of nearspace, which is now gone. Shuttles bypass this autotiler for non-space areas, because they'd replace it anyways. **This does not work on mapload to cut down on init times**, mappers still have to place nearstation areas on their maps where they place some sort of a structure in space. They do not have to do this for shuttle landing areas now, however. Closes #84597 ## Why It's Good For The Game Shit be fucked markers created by ceilings are a god awful solution because we have player-controlled shuttles with custom positioning, so every time you moved a shuttle to a bottom level of any multiz map, you get a bunch of them on your shuttle's roof. ## Changelog :cl: fix: Fixed "shit be fucked" errors and missing lighting on shuttle ceilings docked to bottom z levels of multiz maps /:cl: --- .../map_files/NebulaStation/NebulaStation.dmm | 187 +++++++++--------- _maps/map_files/wawastation/wawastation.dmm | 156 +++++++-------- code/__DEFINES/turfs.dm | 1 + code/__HELPERS/areas.dm | 33 ++-- code/game/objects/structures/lattice.dm | 9 +- code/game/turfs/baseturfs.dm | 8 +- code/game/turfs/change_turf.dm | 28 +-- code/game/turfs/closed/wall/mineral_walls.dm | 12 +- code/game/turfs/open/floor/hull.dm | 10 - code/game/turfs/open/space/space.dm | 8 + .../shuttle/mobile_port/shuttle_move.dm | 2 +- .../mobile_port/shuttle_move_callbacks.dm | 16 +- 12 files changed, 238 insertions(+), 232 deletions(-) diff --git a/_maps/map_files/NebulaStation/NebulaStation.dmm b/_maps/map_files/NebulaStation/NebulaStation.dmm index 1c1b8c3b69b..5e288d30579 100644 --- a/_maps/map_files/NebulaStation/NebulaStation.dmm +++ b/_maps/map_files/NebulaStation/NebulaStation.dmm @@ -29389,9 +29389,6 @@ }, /turf/open/floor/iron/dark, /area/station/cargo/sorting) -"eri" = ( -/turf/open/space/openspace, -/area/space/nearstation) "erl" = ( /obj/effect/turf_decal/stripes/white/line{ dir = 10 @@ -246505,10 +246502,10 @@ txW txW txW txW -eri -eri -eri -eri +txW +txW +txW +txW oOb pIn uty @@ -246762,8 +246759,8 @@ txW txW txW txW -eri -eri +txW +txW kaB pCa oOb @@ -247019,10 +247016,10 @@ txW txW txW txW -eri -eri -eri -eri +txW +txW +txW +txW oOb dPm uty @@ -247533,10 +247530,10 @@ txW txW txW txW -eri -eri -eri -eri +txW +txW +txW +txW oOb pIn uty @@ -247790,8 +247787,8 @@ txW txW txW txW -eri -eri +txW +txW kaB pCa yjT @@ -248047,10 +248044,10 @@ txW txW txW txW -eri -eri -eri -eri +txW +txW +txW +txW yjT iFP mKY @@ -248561,10 +248558,10 @@ txW txW txW txW -eri -eri -eri -eri +txW +txW +txW +txW oOb pIn mKY @@ -248818,8 +248815,8 @@ txW txW txW txW -eri -eri +txW +txW kaB pCa oOb @@ -249075,10 +249072,10 @@ txW txW txW txW -eri -eri -eri -eri +txW +txW +txW +txW yjT iFP uty @@ -257511,14 +257508,14 @@ txW txW txW txW -eri -eri +txW +txW dtb -eri -eri -eri +txW +txW +txW dtb -eri +txW txW txW dtb @@ -257767,16 +257764,16 @@ txW txW txW txW -eri -eri -eri -eri -eri -eri -eri -eri -eri -eri +txW +txW +txW +txW +txW +txW +txW +txW +txW +txW mGv tGj tGj @@ -258024,16 +258021,16 @@ txW txW txW txW -eri -eri -eri -eri -eri -eri -eri -eri -eri -eri +txW +txW +txW +txW +txW +txW +txW +txW +txW +txW vGi uty uty @@ -258281,16 +258278,16 @@ txW txW txW txW -eri -eri -eri -eri -eri -eri -eri -eri -eri -eri +txW +txW +txW +txW +txW +txW +txW +txW +txW +txW sXU mKY uty @@ -258538,16 +258535,16 @@ txW txW txW txW -eri -eri -eri -eri -eri -eri -eri -eri -eri -eri +txW +txW +txW +txW +txW +txW +txW +txW +txW +txW sXU uty uty @@ -258795,16 +258792,16 @@ txW txW txW txW -eri -eri -eri -eri -eri -eri -eri -eri -eri -eri +txW +txW +txW +txW +txW +txW +txW +txW +txW +txW nnZ sFS sFS @@ -259053,14 +259050,14 @@ txW txW txW txW -eri -eri +txW +txW dtb -eri -eri -eri +txW +txW +txW dtb -eri +txW txW txW dtb diff --git a/_maps/map_files/wawastation/wawastation.dmm b/_maps/map_files/wawastation/wawastation.dmm index bd3dffa59e8..3c3fc943b1c 100644 --- a/_maps/map_files/wawastation/wawastation.dmm +++ b/_maps/map_files/wawastation/wawastation.dmm @@ -16353,10 +16353,6 @@ /obj/effect/landmark/start/atmospheric_technician, /turf/open/floor/glass/reinforced, /area/station/engineering/atmos/project) -"fOe" = ( -/obj/effect/landmark/carpspawn, -/turf/open/space/openspace, -/area/space/nearstation) "fOi" = ( /obj/effect/turf_decal/stripes{ dir = 8 @@ -39869,7 +39865,7 @@ start_on = 1 }, /turf/open/misc/asteroid/airless, -/area/space/nearstation) +/area/station/asteroid) "nRj" = ( /obj/effect/turf_decal/stripes/line{ dir = 9 @@ -144287,9 +144283,9 @@ hhX hhX hhX hhX -hen -hen -hen +hhX +hhX +hhX hhX hhX hhX @@ -144544,9 +144540,9 @@ hhX hhX hhX hhX -hen -hen -hen +hhX +hhX +hhX hhX hhX hhX @@ -144801,9 +144797,9 @@ vxX hhX hhX fZF -hen -hen -hen +hhX +hhX +hhX fZF hhX hhX @@ -145058,9 +145054,9 @@ fYe fYe qHE fZF -hen -hen -hen +hhX +hhX +hhX fZF hhX hhX @@ -147044,11 +147040,11 @@ hhX hhX hhX hhX -hen -hen -hen -hen -hen +hhX +hhX +hhX +hhX +hhX vxX vxX vxX @@ -147301,11 +147297,11 @@ hhX hhX hhX hhX -hen -fOe -hen -hen -hen +hhX +fNW +hhX +hhX +hhX vxX vxX vxX @@ -147558,11 +147554,11 @@ hhX hhX hhX hhX -hen -hen -hen -hen -hen +hhX +hhX +hhX +hhX +hhX vxX vxX vxX @@ -157600,10 +157596,10 @@ vxX vxX unk unk -cxg -cxg -cxg -cxg +fYe +fYe +fYe +fYe unk unk vxX @@ -157856,12 +157852,12 @@ vxX vxX vxX unk -cxg -cxg -cxg +fYe +fYe +fYe nQT -cxg -cxg +fYe +fYe unk jCD gYW @@ -158113,12 +158109,12 @@ dsG vxX vxX unk -cxg -joM -joM -joM -joM -cxg +fYe +ivx +ivx +ivx +ivx +fYe eOx wMY apb @@ -158370,12 +158366,12 @@ dsG dsG dsG any -cxg -joM -joM -joM -joM -cxg +fYe +ivx +ivx +ivx +ivx +fYe eOx fFt cTH @@ -158627,12 +158623,12 @@ fYe fYe fYe unk -cxg -cxg -cxg -cxg -cxg -cxg +fYe +fYe +fYe +fYe +fYe +fYe unk jCD jCD @@ -158885,10 +158881,10 @@ fYe fYe unk unk -cxg -cxg -cxg -cxg +fYe +fYe +fYe +fYe unk unk vxX @@ -172061,9 +172057,9 @@ vxX vxX vxX vxX -hen -hen -hen +hhX +hhX +hhX jVV hhX hhX @@ -180985,8 +180981,8 @@ uif mNZ mNZ fYe -hen -hen +hhX +hhX fYe mNZ mNZ @@ -181242,9 +181238,9 @@ fYe fYe fYe fYe -hen -hen -hen +hhX +hhX +hhX mNZ mNZ mNZ @@ -181499,9 +181495,9 @@ mNZ mNZ mNZ fYe -hen -hen -hen +hhX +hhX +hhX umg hhX jVV @@ -181756,9 +181752,9 @@ hhX hhX hhX hhX -hen -hen -hen +hhX +hhX +hhX hhX hhX jVV @@ -182013,9 +182009,9 @@ hhX hhX hhX hhX -hen -hen -hen +hhX +hhX +hhX hhX hhX uOY diff --git a/code/__DEFINES/turfs.dm b/code/__DEFINES/turfs.dm index f66edbed8ad..41319ab7b9e 100644 --- a/code/__DEFINES/turfs.dm +++ b/code/__DEFINES/turfs.dm @@ -6,6 +6,7 @@ #define CHANGETURF_RECALC_ADJACENT (1<<5) //Immediately recalc adjacent atmos turfs instead of queuing. #define CHANGETURF_TRAPDOOR_INDUCED (1<<6) // Caused by a trapdoor, for trapdoor to know that this changeturf was caused by itself #define CHANGETURF_GENERATE_SHUTTLE_CEILING (1<<7) // Generate a shuttle ceiling on the above turf +#define CHANGETURF_NO_AREA_CHANGE (1<<8) // Prevents turfs like space from autoadjusting their area #define IS_OPAQUE_TURF(turf) (turf.directional_opacity == ALL_CARDINALS) diff --git a/code/__HELPERS/areas.dm b/code/__HELPERS/areas.dm index 2395bcbde95..11548f468bd 100644 --- a/code/__HELPERS/areas.dm +++ b/code/__HELPERS/areas.dm @@ -91,25 +91,28 @@ GLOBAL_LIST_INIT(typecache_powerfailure_safe_areas, typecacheof(list( /proc/set_turfs_to_area(list/turf/turfs, area/new_area, list/area/affected_areas = list()) for(var/turf/the_turf as anything in turfs) - var/area/old_area = the_turf.loc + set_turf_to_area(the_turf, new_area, affected_areas) - //keep rack of all areas affected by turf changes - affected_areas[old_area.name] = old_area +/proc/set_turf_to_area(turf/the_turf, area/new_area, list/area/affected_areas = list()) + var/area/old_area = the_turf.loc - //move the turf to its new area and unregister it from the old one - the_turf.change_area(old_area, new_area) + //keep rack of all areas affected by turf changes + affected_areas[old_area.name] = old_area - //inform atoms on the turf that their area has changed - for(var/atom/stuff as anything in the_turf) - //unregister the stuff from its old area - SEND_SIGNAL(stuff, COMSIG_EXIT_AREA, old_area) + //move the turf to its new area and unregister it from the old one + the_turf.change_area(old_area, new_area) - //register the stuff to its new area. special exception for apc as its not registered to this signal - if(istype(stuff, /obj/machinery/power/apc)) - var/obj/machinery/power/apc/area_apc = stuff - area_apc.assign_to_area() - else - SEND_SIGNAL(stuff, COMSIG_ENTER_AREA, new_area) + //inform atoms on the turf that their area has changed + for(var/atom/stuff as anything in the_turf) + //unregister the stuff from its old area + SEND_SIGNAL(stuff, COMSIG_EXIT_AREA, old_area) + + //register the stuff to its new area. special exception for apc as its not registered to this signal + if(istype(stuff, /obj/machinery/power/apc)) + var/obj/machinery/power/apc/area_apc = stuff + area_apc.assign_to_area() + else + SEND_SIGNAL(stuff, COMSIG_ENTER_AREA, new_area) /proc/create_area(mob/creator, new_area_type = /area) // Passed into the above proc as list/break_if_found diff --git a/code/game/objects/structures/lattice.dm b/code/game/objects/structures/lattice.dm index 7258ebe561c..cf5a90ce469 100644 --- a/code/game/objects/structures/lattice.dm +++ b/code/game/objects/structures/lattice.dm @@ -20,10 +20,17 @@ /obj/structure/lattice/Initialize(mapload) . = ..() - if(length(give_turf_traits)) + if (length(give_turf_traits)) give_turf_traits = string_list(give_turf_traits) AddElement(/datum/element/give_turf_traits, give_turf_traits) AddElement(/datum/element/footstep_override, footstep = FOOTSTEP_CATWALK) + // We check for objects in non-nearspace space in both linters and tests, so we can ignore these checks on mapload for performance + if (mapload || !isspaceturf(loc)) + return + + var/area/new_turf_area = get_area(loc) + if (istype(new_turf_area, /area/space) && !istype(new_turf_area, /area/space/nearstation)) + set_turf_to_area(loc, GLOB.areas_by_type[/area/space/nearstation]) /datum/armor/structure_lattice melee = 50 diff --git a/code/game/turfs/baseturfs.dm b/code/game/turfs/baseturfs.dm index 832b7c1def5..09ca2b81c5e 100644 --- a/code/game/turfs/baseturfs.dm +++ b/code/game/turfs/baseturfs.dm @@ -68,7 +68,7 @@ // Copy an existing turf and put it on top // Returns the new turf -/turf/proc/CopyOnTop(turf/copytarget, ignore_bottom=1, depth=INFINITY, copy_air = FALSE) +/turf/proc/CopyOnTop(turf/copytarget, ignore_bottom = 1, depth = INFINITY, copy_air = FALSE, flags = null) var/list/new_baseturfs = list() new_baseturfs += baseturfs new_baseturfs += type @@ -85,9 +85,9 @@ target_baseturfs -= new_baseturfs & GLOB.blacklisted_automated_baseturfs new_baseturfs += target_baseturfs - var/turf/newT = copytarget.copyTurf(src, copy_air) - newT.baseturfs = baseturfs_string_list(new_baseturfs, newT) - return newT + var/turf/new_turf = copytarget.copyTurf(src, copy_air, flags) + new_turf.baseturfs = baseturfs_string_list(new_baseturfs, new_turf) + return new_turf /// Tries to find the given type in baseturfs. /// If found, returns how deep it is for use in other baseturf procs, or null if it cannot be found. diff --git a/code/game/turfs/change_turf.dm b/code/game/turfs/change_turf.dm index 30222e6124e..2deb6f36781 100644 --- a/code/game/turfs/change_turf.dm +++ b/code/game/turfs/change_turf.dm @@ -18,9 +18,9 @@ GLOBAL_LIST_INIT(blacklisted_automated_baseturfs, typecacheof(list( SSair.remove_from_active(new_turf) CALCULATE_ADJACENT_TURFS(new_turf, KILL_EXCITED) -/turf/proc/copyTurf(turf/copy_to_turf) +/turf/proc/copyTurf(turf/copy_to_turf, copy_air = FALSE, flags = null) if(copy_to_turf.type != type) - copy_to_turf.ChangeTurf(type) + copy_to_turf.ChangeTurf(type, flags) if(copy_to_turf.icon_state != icon_state) copy_to_turf.icon_state = icon_state if(copy_to_turf.icon != icon) @@ -35,7 +35,7 @@ GLOBAL_LIST_INIT(blacklisted_automated_baseturfs, typecacheof(list( copy_to_turf.setDir(dir) return copy_to_turf -/turf/open/copyTurf(turf/open/copy_to_turf, copy_air = FALSE) +/turf/open/copyTurf(turf/open/copy_to_turf, copy_air = FALSE, flags = null) . = ..() ASSERT(istype(copy_to_turf, /turf/open)) var/datum/component/wet_floor/slip = GetComponent(/datum/component/wet_floor) @@ -69,6 +69,7 @@ GLOBAL_LIST_INIT(blacklisted_automated_baseturfs, typecacheof(list( if(!GLOB.use_preloader && path == type && !(flags & CHANGETURF_FORCEOP) && (baseturfs == new_baseturfs)) // Don't no-op if the map loader requires it to be reconstructed, or if this is a new set of baseturfs return src + if(flags & CHANGETURF_SKIP) return new path(src) @@ -293,13 +294,16 @@ GLOBAL_LIST_INIT(blacklisted_automated_baseturfs, typecacheof(list( /// Attempts to replace a tile with lattice. Amount is the amount of tiles to scrape away. /turf/proc/attempt_lattice_replacement(amount = 2) - if(lattice_underneath) - var/list/successful_replacement_callbacks = list() - SEND_SIGNAL(src, COMSIG_TURF_ATTEMPT_LATTICE_REPLACEMENT, successful_replacement_callbacks) - var/turf/new_turf = ScrapeAway(amount, flags = CHANGETURF_INHERIT_AIR) - if(!istype(new_turf, /turf/open/floor)) - var/new_lattice = new /obj/structure/lattice(src) - for(var/datum/callback/callback as anything in successful_replacement_callbacks) - callback.Invoke(new_lattice) - else + if (!lattice_underneath) ScrapeAway(amount, flags = CHANGETURF_INHERIT_AIR) + return + + var/list/successful_replacement_callbacks = list() + SEND_SIGNAL(src, COMSIG_TURF_ATTEMPT_LATTICE_REPLACEMENT, successful_replacement_callbacks) + var/turf/new_turf = ScrapeAway(amount, flags = CHANGETURF_INHERIT_AIR) + if (istype(new_turf, /turf/open/floor)) + return + + var/new_lattice = new /obj/structure/lattice(src) + for (var/datum/callback/callback as anything in successful_replacement_callbacks) + callback.Invoke(new_lattice) diff --git a/code/game/turfs/closed/wall/mineral_walls.dm b/code/game/turfs/closed/wall/mineral_walls.dm index f2c076c3228..f3ddf778db3 100644 --- a/code/game/turfs/closed/wall/mineral_walls.dm +++ b/code/game/turfs/closed/wall/mineral_walls.dm @@ -291,13 +291,13 @@ smoothing_flags = SMOOTH_BITMASK | SMOOTH_DIAGONAL_CORNERS fixed_underlay = list("space" = TRUE) -/turf/closed/wall/mineral/titanium/interior/copyTurf(turf/T) +/turf/closed/wall/mineral/titanium/interior/copyTurf(turf/copy_to_turf, copy_air = FALSE, flags = null) . = ..() - T.transform = transform + copy_to_turf.transform = transform -/turf/closed/wall/mineral/titanium/copyTurf(turf/T) +/turf/closed/wall/mineral/titanium/copyTurf(turf/copy_to_turf, copy_air = FALSE, flags = null) . = ..() - T.transform = transform + copy_to_turf.transform = transform /turf/closed/wall/mineral/titanium/survival name = "pod wall" @@ -379,6 +379,6 @@ /turf/closed/wall/mineral/plastitanium/hulk_recoil(obj/item/bodypart/arm, mob/living/carbon/human/hulkman, damage = 41) return ..() -/turf/closed/wall/mineral/plastitanium/copyTurf(turf/T) +/turf/closed/wall/mineral/plastitanium/copyTurf(turf/copy_to_turf, copy_air = FALSE, flags = null) . = ..() - T.transform = transform + copy_to_turf.transform = transform diff --git a/code/game/turfs/open/floor/hull.dm b/code/game/turfs/open/floor/hull.dm index 2aec1f97fd3..89fbb9294af 100644 --- a/code/game/turfs/open/floor/hull.dm +++ b/code/game/turfs/open/floor/hull.dm @@ -9,16 +9,6 @@ /turf/open/floor/engine/hull/ceiling name = "shuttle ceiling plating" -/turf/open/floor/engine/hull/ceiling/Initialize(mapload) - . = ..() - if(!istype(loc, /area/space)) - return - if(istype(loc, /area/space/nearstation)) - return - new /obj/effect/mapping_error (src) //We're in a normal space tile, meaning we aren't lit correct. - ///datum/unit_test/mapping_nearstation_test.dm SHOULD fail this case automatically - //this is just here so the mapper responsible can easily see where the issues are directly on the map. - /turf/open/floor/engine/hull/reinforced name = "exterior reinforced hull plating" desc = "Extremely sturdy exterior hull plating that separates you from the uncaring vacuum of space." diff --git a/code/game/turfs/open/space/space.dm b/code/game/turfs/open/space/space.dm index b672dad62ba..8963ae574b6 100644 --- a/code/game/turfs/open/space/space.dm +++ b/code/game/turfs/open/space/space.dm @@ -242,6 +242,14 @@ GLOBAL_LIST_EMPTY(starlight) return FALSE +/turf/open/space/ChangeTurf(path, list/new_baseturfs, flags) + . = ..() + if (!. || isspaceturf(.)) + return + + var/area/new_turf_area = get_area(.) + if (istype(new_turf_area, /area/space) && !istype(new_turf_area, /area/space/nearstation)) + set_turf_to_area(., GLOB.areas_by_type[/area/space/nearstation]) /turf/open/space/attempt_lattice_replacement() var/dest_x = destination_x diff --git a/code/modules/shuttle/mobile_port/shuttle_move.dm b/code/modules/shuttle/mobile_port/shuttle_move.dm index 5c748bc2cfd..7f1ce86ed84 100644 --- a/code/modules/shuttle/mobile_port/shuttle_move.dm +++ b/code/modules/shuttle/mobile_port/shuttle_move.dm @@ -141,7 +141,7 @@ var/move_mode = old_turfs[oldT] if(move_mode & MOVE_TURF) - oldT.onShuttleMove(newT, movement_force, movement_direction) //turfs + oldT.onShuttleMove(newT, movement_force, movement_direction, move_mode & MOVE_AREA) //turfs if(move_mode & MOVE_AREA) var/area/shuttle_area = oldT.loc diff --git a/code/modules/shuttle/mobile_port/shuttle_move_callbacks.dm b/code/modules/shuttle/mobile_port/shuttle_move_callbacks.dm index c09052a7e89..db3d734f8d5 100644 --- a/code/modules/shuttle/mobile_port/shuttle_move_callbacks.dm +++ b/code/modules/shuttle/mobile_port/shuttle_move_callbacks.dm @@ -43,8 +43,8 @@ All ShuttleMove procs go here qdel(thing) // Called on the old turf to move the turf data -/turf/proc/onShuttleMove(turf/newT, list/movement_force, move_dir) - if(newT == src) // In case of in place shuttle rotation shenanigans. +/turf/proc/onShuttleMove(turf/new_turf, list/movement_force, move_dir, ignore_area_change = FALSE) + if(new_turf == src) // In case of in place shuttle rotation shenanigans. return // Destination turf changes. // Baseturfs is definitely a list or this proc wouldnt be called. @@ -52,15 +52,15 @@ All ShuttleMove procs go here if(!shuttle_depth) CRASH("A turf queued to move via shuttle somehow had no skipover in baseturfs. [src]([type]):[loc]") - newT.CopyOnTop(src, 1, shuttle_depth, TRUE) - newT.blocks_air = TRUE - newT.air_update_turf(TRUE, FALSE) + new_turf.CopyOnTop(src, 1, shuttle_depth, TRUE, ignore_area_change ? CHANGETURF_NO_AREA_CHANGE : NONE) // Don't automatically change space area to nearspace if we'll override it later + new_turf.blocks_air = TRUE + new_turf.air_update_turf(TRUE, FALSE) blocks_air = TRUE air_update_turf(TRUE, TRUE) - if(isopenturf(newT)) - var/turf/open/new_open = newT + if(isopenturf(new_turf)) + var/turf/open/new_open = new_turf new_open.copy_air_with_tile(src) - SEND_SIGNAL(src, COMSIG_TURF_ON_SHUTTLE_MOVE, newT) + SEND_SIGNAL(src, COMSIG_TURF_ON_SHUTTLE_MOVE, new_turf) return TRUE