Files
Bubberstation/code/modules/unit_tests/mapload_space_verification.dm
SkyratBot 1e4eea1177 [MIRROR] Unit tests for stuff accidentally placed in space by mappers (#28538)
* Unit tests for stuff accidentally placed in space by mappers (#84453)

This unit test detects all turfs & other movables that aren't in a lit
area (ie area/space/nearspace) on station zlevels

The grep detects movables placed on shuttles that do not have the
correct area assigned, which caused those atoms to break off of the
shuttle & literally get launched into random parts of space (usually on
station z-levels; the only reason I found this issue was cause the unit
test was detecting random shit ending up on station maps lol)

Minor fix for the mapload_space_verification unit test - it was falsely
detecting turfs that shuttle grids (that were template_noop) were parked
ontop of, which aren't effected by the shuttle in any way. This allowed
the following fix

Fixed a number of shuttles having atoms in /area/template_noop areas.
Atoms in these areas are treated as not actually part of the shuttle
itself & were launched off into random space tiles across all z-levels
via dump_in_space(). Corrected those grids to have the correct area, and
as such, shuttles now stay together properly.

🆑 ShizCalev
fix: Fixed a number of shuttles having parts (such as lattices)
completely disappearing.
fix: Fixed the ceilings above shuttles on station maps being
full-bright.
fix: Fixed lattices sometimes appearing at random locations in space on
station maps.
fix: Cleaned up a number of accidentally placed objects in space across
all station maps.
fix: Fixed a false positive with the mapload_space_verification unit
test failing on turfs that weren't actually part of shuttles.
code: Added a unit test that automatically finds all base space turfs
with objects on them, as well as non-space turfs that are set to space
areas (meaning that these squares weren't lit properly.)
/🆑

Shuttle Ceiling Fix:
Before

![2024-06-30_23-15-18-dreamseeker-Doctor_s_Spess_Junk_Eta](https://github.com/tgstation/tgstation/assets/6209658/4d1fb186-460a-409f-ab5d-3258b4e205f8)
Fixed
![Screenshot 2024-06-30
231528](https://github.com/tgstation/tgstation/assets/6209658/bd957384-4ba5-4fb6-9919-7f17f01d723c)

Shuttle Fix:
Before

![image](https://github.com/tgstation/tgstation/assets/6209658/4b408c40-0a25-4d8c-a9c7-65157eaf1172)
Fixed (look at the lattices in the middle. the stuff in the shuttle are
randomized / not part of this)

![image](https://github.com/tgstation/tgstation/assets/6209658/80a9e5f2-8c30-492e-8cd3-31f9b8ffb275)

* Unit tests for stuff accidentally placed in space by mappers

* Fixes maps for nearspace unit test (#28557)

Fixes maps

---------

Co-authored-by: Afevis <ShizCalev@users.noreply.github.com>
Co-authored-by: SpaceLoveSs13 <68121607+SpaceLoveSs13@users.noreply.github.com>
2024-07-02 15:25:34 +05:30

62 lines
4.3 KiB
Plaintext

/// Verifies that there are no space turfs inside a station area, or on any planetary z-level. Sometimes, these are introduced during the load of the map and are not present in the DMM itself.
/// Let's just make sure that we have a stop-gap measure in place to catch these if they pop up so we don't put it onto production servers should something errant come up.
/datum/unit_test/mapload_space_verification
// This test is quite taxing time-wise, so let's run it later than other faster tests.
priority = TEST_LONGER
/datum/unit_test/mapload_space_verification/Run()
// Is our current map a planetary station (NO space turfs allowed)? If so, check for ANY space turfs.
if(SSmapping.is_planetary())
validate_planetary_map()
return
// Let's explicitly outline valid areas to catch anything that we're... okay with for now, because there are some valid use cases (though we should try to avoid them).
var/list/excluded_area_typecache = typecacheof(list(
// Space! This is likely an intentional space turf, so let's not worry about it.
/area/space,
// Transit areas have space turfs in a valid placement.
/area/shuttle/transit,
// Space Ruins do their own thing (dilapidated lattices over space turfs, for instance). Rather than fuss over it, let's just let it through.
/area/ruin/space,
// Same stipulation as space ruins, but they're (ruined) shuttles instead.
/area/shuttle/ruin,
/area/shuttle/abandoned,
// Solars have lattices over space turfs, and are a valid placement for space turfs in a station area.
/area/station/solars,
//Birdshot Atmos has a special area, so we'll exclude that from lints here.
/area/station/engineering/atmos/space_catwalk,
))
// We aren't planetary, so let's check area placements and ensure stuff lines up.
for(var/turf/iterated_turf in ALL_TURFS())
var/area/turf_area = get_area(iterated_turf)
if(!isspaceturf(iterated_turf) || is_type_in_typecache(turf_area, excluded_area_typecache))
continue // Alright, so let's assume we have intended behavior. If something yorks, we'll get a bare `/area` (maploader?) or a mapper is doing something they shouldn't be doing.
if(HAS_TRAIT(iterated_turf, TRAIT_HYPERSPACE_STOPPED))
continue // This means that a shuttle with a noop template turf is just temporarily parked ontop of us and that we're not actually a part of it. We don't have to care about it as it will leave us alone when it flies away.
// We need turf_area.type for the error message because we have fifteen million ruin areas named "Unexplored Location" and it's completely unhelpful here.
TEST_FAIL("Space turf [iterated_turf.type] found in non-allowed area ([turf_area.type]) at [AREACOORD(iterated_turf)]! Please ensure that all space turfs are in an /area/space!")
/// Verifies that there are ZERO space turfs on a valid planetary station. We NEVER want space turfs here, so we do not check for /area/space here since something completely undesirable is happening.
/// There are also a few considerations specific to planetary stations included within, so let's spin it out into a separate proc for clarity.
/datum/unit_test/mapload_space_verification/proc/validate_planetary_map()
// We want to get both the station level and the mining level (if the two are seperate for any reason).
var/list/testable_levels = list()
testable_levels += SSmapping.levels_by_trait(ZTRAIT_STATION) // Station z-levels get to be in by default because they can derail an entire round and cause LINDA to weep if a space turf is present.
var/list/mining_levels = SSmapping.levels_by_trait(ZTRAIT_MINING)
// Add in mining levels should they exist, and dupecheck to make sure we don't have any duplicates because it's valid to have a station and mining level be the same.
for(var/mining_level in mining_levels)
if(mining_level in testable_levels)
continue
testable_levels += mining_level
for(var/level in testable_levels)
var/testable_turfs = Z_TURFS(level)
// Remember, any space turf is a failure.
for(var/turf/open/space/iterated_turf in testable_turfs)
// grab the type of the area that we're in too, because there's three different types of area types that have the name "Icemoon Wastes", for example
var/area/invalid_area = get_area(iterated_turf)
TEST_FAIL("Space turf found on planetary map! [AREACOORD(iterated_turf)] ([invalid_area.type]) Please verify the map file and remove any space turfs.")