-
-
Notifications
You must be signed in to change notification settings - Fork 681
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ded19de
commit 3ea806e
Showing
8 changed files
with
178 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/datum/unit_test/map_test/active_turfs/check_map() | ||
var/list/failures = list() | ||
for(var/turf/t in GLOB.active_turfs_startlist) | ||
failures += "Roundstart active turf at ([t.x], [t.y], [t.z] in [t.loc])" | ||
if (length(failures)) | ||
TEST_FAIL(jointext(failures, "\n")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/datum/unit_test/map_test/apc/check_area(area/check_area) | ||
if (!check_area.requires_power) | ||
return | ||
if (!check_area.apc && !check_area.always_unpowered) | ||
return "No APC in an area that requires power" | ||
if (check_area.apc && check_area.always_unpowered) | ||
return "APC found in an always unpowered area" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/datum/unit_test/map_test/camera/check_turf(turf/check_turf, is_map_border) | ||
var/found = FALSE | ||
for (var/obj/machinery/camera/camera in check_turf) | ||
if (found) | ||
return "Multiple cameras detected" | ||
if (!isclosedturf(get_step(check_turf, camera.dir))) | ||
return "Camera not attached to a wall" | ||
found = TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/obj/structure/disposalpipe/var/_traversed = 0 | ||
|
||
/datum/unit_test/map_test/check_disposals | ||
var/failure_reason | ||
var/is_sorting_network | ||
|
||
// Find all entries into the disposal system | ||
/datum/unit_test/map_test/check_disposals/collect_targets(list/turfs) | ||
var/located = list() | ||
for (var/turf/check_turf in turfs) | ||
var/found = locate(/obj/machinery/disposal) | ||
if (found) | ||
located += found | ||
return located | ||
|
||
// Make sure that we can end up in the correct location | ||
/datum/unit_test/map_test/check_disposals/check_target(obj/machinery/disposal/target) | ||
var/list/failures = list() | ||
failure_reason = null | ||
is_sorting_network = FALSE | ||
if (!target.trunk) | ||
return "[target.name] not attached to a trunk" | ||
// Create a terrible disposal holder object | ||
var/obj/structure/disposalholder/holder = new() | ||
traverse_loop(target.trunk, holder) | ||
// Abuse byonds variables to get out (We can use pointers as an out variable in 515) | ||
if (failure_reason) | ||
failures += failure_reason | ||
// This is fine, we probably are a bin that leads to space or something | ||
if (!is_sorting_network) | ||
return failures | ||
holder.last_pipe = null | ||
holder.current_pipe = null | ||
failure_reason = null | ||
// Since we have filters, lets make sure this is a proper, fully connected and fully functioning loop | ||
// We should be able to enter the loop at any point from an input gate to get to our destination | ||
for (var/sort_code in GLOB.TAGGERLOCATIONS) | ||
holder.destinationTag = sort_code | ||
var/obj/structure/disposaloutlet/destination = traverse_loop(target.trunk, holder) | ||
if (failure_reason) | ||
return failure_reason | ||
var/arrived = FALSE | ||
for (var/valid_destination in GLOB.tagger_destination_areas[sort_code]) | ||
if (istype(get_area(destination), valid_destination)) | ||
arrived = TRUE | ||
break | ||
if (!arrived) | ||
failures += "Disposal track starting at [COORD(target)] does not end up in the correct destination. Expected [sort_code], got [get_area(destination)] at [COORD(destination)]" | ||
return failures | ||
|
||
/datum/unit_test/map_test/check_disposals/proc/traverse_loop(obj/structure/disposalholder/holder, obj/structure/disposalpipe/start) | ||
// First check to ensure that we end up somewhere | ||
var/obj/structure/disposalpipe/current = holder | ||
while (current) | ||
holder.current_pipe = current | ||
var/turf/T = get_step(current, current.nextdir(holder)) | ||
current = locate(/obj/structure/disposalpipe) in T | ||
// Found a valid ending | ||
if (locate(/obj/structure/disposaloutlet) in T) | ||
return locate(/obj/structure/disposaloutlet) | ||
// Detect ending back at an input | ||
if (locate(/obj/machinery/disposal) in T) | ||
failure_reason = "Disposal loop starting at [COORD(start)] leads to an input node at [COORD(T)] but should lead to an outlet" | ||
if (locate(/obj/structure/disposalpipe/sorting)) | ||
is_sorting_network = TRUE | ||
// End detection | ||
if (current == null) | ||
failure_reason = "Disposal network starting at [COORD(start)] has a pipe with no output at [COORD(T)] but should lead to an outlet" | ||
// Loop detection | ||
if (current._traversed == 1) | ||
failure_reason = "Disposal network starting at [COORD(start)] contains a loop at [COORD(T)] which is not allowed" | ||
current._traversed = 1 | ||
holder.last_pipe = current |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/datum/unit_test/map_test/lights/check_turf(turf/check_turf, is_map_border) | ||
var/found = FALSE | ||
for (var/obj/machinery/light/light in check_turf) | ||
if (istype(light, /obj/machinery/light/floor)) | ||
continue | ||
if (found) | ||
return "Multiple lights detected" | ||
if (!isclosedturf(get_step(check_turf, light.dir))) | ||
return "Light not attached to a wall" | ||
found = TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,60 @@ | ||
/datum/unit_test/map_test/Run() | ||
var/list/failures | ||
var/list/areas = list() | ||
var/list/turfs = list() | ||
// Check turfs | ||
for (var/z in 1 to world.maxz) | ||
if (!is_station_level(z)) | ||
continue | ||
for (var/x in 1 to world.maxx) | ||
for (var/y in 1 to world.maxy) | ||
var/turf/tile = locate(x, y, z) | ||
turfs += tile | ||
areas[tile.loc] = TRUE | ||
var/result = check_tile(tile, x == 1 || x == world.maxx || y == 1 || y == world.maxy) | ||
var/result = check_turf(tile, x == 1 || x == world.maxx || y == 1 || y == world.maxy) | ||
if (result) | ||
LAZYADD(failures, result) | ||
LAZYADD(failures, "([x], [y], [z]): [result]") | ||
// Check areas | ||
for (var/area/A in areas) | ||
var/result = check_area(A) | ||
if (result) | ||
LAZYADD(failures, result) | ||
if (LAZYLEN(failures)) | ||
TEST_FAIL(jointext(failures, "\n")) | ||
LAZYADD(failures, "([A.type]): [result]") | ||
// Check Zs | ||
for (var/z in 1 to world.maxz) | ||
if (!is_station_level(z)) | ||
continue | ||
var/result = check_z_level(z) | ||
if (result) | ||
LAZYADD(failures, result) | ||
// Get things we want to specifically test for | ||
var/list/targets = collect_targets(turfs) | ||
for (var/target in targets) | ||
var/result = check_target(target) | ||
if (result) | ||
LAZYADD(failures, result) | ||
// Full map general checks | ||
var/result = check_map() | ||
if (result) | ||
LAZYADD(failures, result) | ||
// Fail if necessary | ||
if (LAZYLEN(failures)) | ||
TEST_FAIL(jointext(failures, "\n")) | ||
|
||
/// Return a string if failed, return null otherwise | ||
/datum/unit_test/map_test/proc/check_turf(turf/check_turf, is_map_border) | ||
|
||
/// Return a string if failed, return null otherwise | ||
/datum/unit_test/map_test/proc/check_tile(turf/T, is_map_border) | ||
/datum/unit_test/map_test/proc/check_map(turf/check_turf, is_map_border) | ||
|
||
/// Return a string if failed, return null otherwise | ||
/datum/unit_test/map_test/proc/check_area(area/T) | ||
/datum/unit_test/map_test/proc/check_area(area/check_area) | ||
|
||
/// Return a string if failed, return null otherwise | ||
/datum/unit_test/map_test/proc/check_z_level(z_value) | ||
|
||
/datum/unit_test/map_test/test/check_tile(turf/T, is_map_border) | ||
if (istype(T, /turf/closed/wall)) | ||
return "[T.type] detected" | ||
/// Returns a list of things that you want to specifically check | ||
/datum/unit_test/map_test/proc/collect_targets(list/turfs) | ||
return list() | ||
|
||
/// Return a string if failed, return null otherwise | ||
/datum/unit_test/map_test/proc/check_target(atom/target) |