[MDB Ignore] Unit Tests for Invalid Space Turfs (Area Bullshit Edition) (#70967)

## About The Pull Request

So, there's some bullshit with the map loader(?) sometimes where it'll
let space turfs spawn in spots where we REALLY don't want space turfs.
Or, it could also just be a mapper screwing up. Anyways, we might miss
these, so let's set up a broad Unit Test that checks and verifies that
these round-ruining snagglers do _not_ exist.

In order to help me to do this, I standardized and fixed the
nomenclature such that `/area/ruin/space` is default for any map file in
`_maps/RandomRuins/SpaceRuins`, as well as it's subtypes. I also touched
up how we handle shuttle areas in these scenarios. This got a lot of
Unit Test noise filtered out, and is crucial for its functioning. It
should also be how we did it from the start anyways. I added in an
UpdatePaths for any compatible change, but it was completely
non-workable for some of the area type updates.

I also fixed any organic bugs that didn't require an areas type update.
Cool.

Placing space turfs on IceBox:

![image](https://user-images.githubusercontent.com/34697715/199177940-21c64964-1808-41b0-9a92-bf5b82eee2fa.png)

Organically found issues:

![image](https://user-images.githubusercontent.com/34697715/199177972-b27a89de-0e1a-41e5-8fa4-3bee1763b9da.png)

I also added a `planetary` variable to `/datum/map_config` because I
didn't like the hack I was using to see if we had a planetary map, and
I'd rather it just be an explicit variable in the map's JSON.

## Why It's Good For The Game

The less times we get Space Turfs showing up on IceBoxStation, the
better. It also standardizes areas a bit more, which I like (we were
using some incorrect ones in the wrong spots, so those were touched up
in this PR as well). Like, if it's a space ruin, we don't need to use
the lengthy `/area/ruin/unpowered/no_grav` when `/area/ruin/space` does
the same thing.
## Changelog
Nothing in here should concern a player (unless I broke something)

Expect a few commits as I spam unit tests a few times and play
whack-a-mole with bugs.
This commit is contained in:
san7890
2022-11-21 00:59:54 -07:00
committed by GitHub
parent 2e00fa2282
commit cb20ec99f9
48 changed files with 7471 additions and 7393 deletions
+1
View File
@@ -124,6 +124,7 @@
#include "limbsanity.dm"
#include "load_map_security.dm"
#include "machine_disassembly.dm"
#include "mapload_space_verification.dm"
#include "mapping.dm"
#include "mecha_damage.dm"
#include "medical_wounds.dm"
@@ -0,0 +1,60 @@
/// 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()
// Get the datum associated with our currently running map.
var/datum/map_config/current_map = SSmapping.config
// Is our current map a planetary station (NO space turfs allowed)? If so, check for ANY space turfs.
if(current_map.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,
))
// 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.
// 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 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.")
+1
View File
@@ -17,3 +17,4 @@
continue
TEST_FAIL(log_entry)