Skip to content

Commit 6bb8e09

Browse files
francinumKapu1178
andauthored
Genericized atom-counting unit tests (#1172)
* Genericized atom-counting unit test * fuck me * Fix standards failures * This one's experimental. * whoops * Update code/modules/unit_tests/mapping_standards/no_renamed_areas.dm * Update code/modules/unit_tests/mapping_standards/enforce_count/_enforce_count.dm * Killing you, asshole. * If it so pleases the court jester * Area exemption functionality --------- Co-authored-by: Kapu1178 <[email protected]>
1 parent 27fdd1a commit 6bb8e09

File tree

8 files changed

+102
-53
lines changed

8 files changed

+102
-53
lines changed

_maps/map_files/Theseus/Theseus.dmm

+4-22
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,6 @@
17131713
},
17141714
/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden/layer4,
17151715
/obj/machinery/atmospherics/pipe/smart/manifold4w/scrubbers/hidden/layer2,
1716-
/obj/machinery/door/firedoor,
17171716
/turf/open/floor/iron,
17181717
/area/station/hallway/primary/port)
17191718
"aDo" = (
@@ -23015,7 +23014,6 @@
2301523014
/obj/structure/disposalpipe/segment{
2301623015
dir = 4
2301723016
},
23018-
/obj/machinery/door/firedoor,
2301923017
/turf/open/floor/iron,
2302023018
/area/station/hallway/primary/port)
2302123019
"iEh" = (
@@ -24697,7 +24695,6 @@
2469724695
/obj/structure/cable/yellow{
2469824696
icon_state = "12"
2469924697
},
24700-
/obj/machinery/door/firedoor,
2470124698
/turf/open/floor/iron,
2470224699
/area/station/hallway/primary/port)
2470324700
"joU" = (
@@ -39900,12 +39897,6 @@
3990039897
req_access_txt = "69"
3990139898
},
3990239899
/obj/machinery/door/firedoor,
39903-
/obj/machinery/door/airlock/medical{
39904-
name = "Chemical Storage";
39905-
stripe_paint = "#ff9900";
39906-
req_access_txt = "69"
39907-
},
39908-
/obj/machinery/door/firedoor,
3990939900
/turf/open/floor/iron/white,
3991039901
/area/station/medical/medbay/central)
3991139902
"oPj" = (
@@ -63583,15 +63574,6 @@
6358363574
},
6358463575
/turf/open/floor/iron,
6358563576
/area/station/hallway/primary/central/fore)
63586-
"xGi" = (
63587-
/obj/machinery/door/airlock/security/glass{
63588-
name = "Security Deck";
63589-
req_one_access_txt = "1;4"
63590-
},
63591-
/obj/machinery/door/firedoor,
63592-
/obj/machinery/door/firedoor,
63593-
/turf/open/floor/iron/dark,
63594-
/area/station/security/deck)
6359563577
"xGs" = (
6359663578
/obj/structure/disposalpipe/segment{
6359763579
dir = 4
@@ -96273,9 +96255,9 @@ cgC
9627396255
cgC
9627496256
bhW
9627596257
gbw
96276-
xGi
96277-
iWI
9627896258
hQr
96259+
iWI
96260+
cgB
9627996261
tIJ
9628096262
wOR
9628196263
fBp
@@ -96530,9 +96512,9 @@ uiW
9653096512
uiW
9653196513
uiW
9653296514
aeU
96533-
xGi
96534-
iWI
9653596515
hQr
96516+
iWI
96517+
cgB
9653696518
nBb
9653796519
iuP
9653896520
eyI

code/modules/unit_tests/mapping_standards/__include.dm

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@
33
#include "_mapping_standards.dm"
44

55
#include "ladders_must_have_openspace.dm"
6-
#include "one_light_per_tile.dm"
6+
#include "no_renamed_areas.dm"
7+
8+
#include "enforce_count\_enforce_count.dm"
9+
#include "enforce_count\lights.dm"
10+
#include "enforce_count\doors.dm"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/datum/unit_test/mapping_standards/enforce_count
2+
abstract_type = /datum/unit_test/mapping_standards/enforce_count
3+
4+
5+
var/allowed_count = 1
6+
7+
/// Type to check. Includes subtypes.
8+
var/checked_type = null
9+
/// 'Friendly Name' used in fail messages.
10+
var/failed_name = "Bad Objects"
11+
12+
/datum/unit_test/mapping_standards/enforce_count/proc/get_collection()
13+
TEST_FAIL("Missing Collection Setup, Bad Test!")
14+
15+
/datum/unit_test/mapping_standards/enforce_count/Run()
16+
if(..())
17+
return
18+
19+
/// Turfs we've passed once. We don't fully count every tile.
20+
var/list/turf/checked_turfs = list()
21+
/// Tiles we've fully counted, If we reach these again, we can
22+
/// safely skip them.
23+
var/list/turf/counted_turfs = list()
24+
25+
for(var/atom/checked_atom as anything in get_collection())
26+
if(!istype(checked_atom, checked_type))
27+
continue //Skip types we aren't checking.
28+
var/area/atom_area = get_area(checked_atom)
29+
if(!(atom_area.type in GLOB.the_station_areas))
30+
continue //Not on station, Skip.
31+
32+
var/turf/atom_turf = get_turf(checked_atom)
33+
if(atom_turf in checked_turfs)
34+
if(atom_turf in counted_turfs)
35+
continue //Already reported.
36+
counted_turfs.Add(atom_turf)
37+
var/atom_count = 0
38+
for(var/_counter as anything in atom_turf)
39+
if(!istype(_counter, checked_type))
40+
continue // Not of the type we care about.
41+
atom_count++
42+
if(atom_count < allowed_count)
43+
continue //We've counted, but the count came up short. Not a failure.
44+
TEST_FAIL("[atom_count] [failed_name] on tile at [AREACOORD(atom_turf)]")
45+
continue //Already added to the checked list.
46+
//Else
47+
checked_turfs.Add(atom_turf)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/datum/unit_test/mapping_standards/enforce_count/doors
2+
abstract_type = /datum/unit_test/mapping_standards/enforce_count/doors
3+
4+
/datum/unit_test/mapping_standards/enforce_count/doors/get_collection()
5+
return INSTANCES_OF(/obj/machinery/door)
6+
7+
/datum/unit_test/mapping_standards/enforce_count/doors/airlock
8+
name = "MAPSTANDARDS: Tiles Must Have At Most 1 Airlock"
9+
checked_type = /obj/machinery/door/airlock
10+
failed_name = "Airlocks"
11+
12+
/datum/unit_test/mapping_standards/enforce_count/doors/firedoor
13+
name = "MAPSTANDARDS: Tiles Must Have At Most 1 Firedoor"
14+
checked_type = /obj/machinery/door/firedoor
15+
failed_name = "Firedoors"
16+
17+
/datum/unit_test/mapping_standards/enforce_count/doors/blastdoor
18+
name = "MAPSTANDARDS: Tiles Must Have At Most 1 Blast Door"
19+
checked_type = /obj/machinery/door/poddoor
20+
failed_name = "Blast Doors"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/datum/unit_test/mapping_standards/enforce_count/lights
2+
name = "MAPSTANDARDS: Tiles Must Have At Most 1 Light"
3+
4+
checked_type = /obj/machinery/light
5+
failed_name = "Lights"
6+
7+
/datum/unit_test/mapping_standards/enforce_count/lights/get_collection()
8+
return INSTANCES_OF(/obj/machinery/light)

code/modules/unit_tests/mapping_standards/ladders_must_have_openspace.dm

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
name = "MAPSTANDARDS: Ladders must have openspace"
88

99
/datum/unit_test/mapping_standards/ladders_must_have_openspace/Run()
10-
if(..()) {return};
10+
if(..())
11+
return
12+
1113
for(var/obj/structure/ladder/ladder as anything in INSTANCES_OF(/obj/structure/ladder))
1214
if(ladder.down && (!isopenspaceturf(get_turf(ladder))))
1315
TEST_FAIL("Ladder with down linkage is not on openspace turf, at: [AREACOORD(ladder)]")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/datum/unit_test/mapping_standards/no_renamed_areas
2+
name = "MAPSTANDARDS: Areas must not be renamed"
3+
4+
var/list/area/exempt_areas = list(
5+
//None
6+
)
7+
8+
/datum/unit_test/mapping_standards/no_renamed_areas/Run()
9+
if(..())
10+
return
11+
12+
for(var/area/area in GLOB.areas)
13+
if(!(area.type in exempt_areas) && (area.name != initial(area.name)))
14+
// Unique areas might be worth exempting here? But at the same time, there's no throws here with no check. -Francinum
15+
TEST_FAIL("Area [area]/([initial(area.name)]) at [AREACOORD(area.contents[1])] (Unique: [BOOLEAN(area.area_flags & UNIQUE_AREA)]) has been renamed. ")

code/modules/unit_tests/mapping_standards/one_light_per_tile.dm

-29
This file was deleted.

0 commit comments

Comments
 (0)