diff --git a/_maps/templates/unit_tests.dmm b/_maps/templates/unit_tests.dmm new file mode 100644 index 0000000000000..deab00c38cfe8 --- /dev/null +++ b/_maps/templates/unit_tests.dmm @@ -0,0 +1,79 @@ +//MAP CONVERTED BY dmm2tgm.py THIS HEADER COMMENT PREVENTS RECONVERSION, DO NOT REMOVE +"a" = ( +/turf/closed/wall, +/area/testroom) +"m" = ( +/turf/open/floor/iron, +/area/testroom) +"r" = ( +/obj/effect/landmark/unit_test_top_right, +/turf/open/floor/iron, +/area/testroom) +"L" = ( +/obj/effect/landmark/unit_test_bottom_left, +/turf/open/floor/iron, +/area/testroom) + +(1,1,1) = {" +a +a +a +a +a +a +a +"} +(2,1,1) = {" +a +m +m +m +m +L +a +"} +(3,1,1) = {" +a +m +m +m +m +m +a +"} +(4,1,1) = {" +a +m +m +m +m +m +a +"} +(5,1,1) = {" +a +m +m +m +m +m +a +"} +(6,1,1) = {" +a +r +m +m +m +m +a +"} +(7,1,1) = {" +a +a +a +a +a +a +a +"} diff --git a/code/game/area/general.dm b/code/game/area/general.dm index 664eae661d1c1..da04f7c9ccdfe 100755 --- a/code/game/area/general.dm +++ b/code/game/area/general.dm @@ -218,6 +218,14 @@ static_lighting = FALSE base_lighting_alpha = 255 +/area/testroom + requires_power = FALSE + // Mobs should be able to see inside the testroom + static_lighting = FALSE + base_lighting_alpha = 255 + name = "Test Room" + icon_state = "test_room" + /area/syndicate_mothership name = "Abandoned Syndicate Base" diff --git a/code/game/objects/effects/landmarks/landmarks.dm b/code/game/objects/effects/landmarks/landmarks.dm index 884d8fe1635e9..b7d44487edbbe 100755 --- a/code/game/objects/effects/landmarks/landmarks.dm +++ b/code/game/objects/effects/landmarks/landmarks.dm @@ -485,3 +485,13 @@ /obj/effect/landmark/eord_roomba/Destroy() GLOB.eord_roomba_spawns -= src return ..() + +/// Marks the bottom left of the testing zone. +/// In landmarks.dm and not unit_test.dm so it is always active in the mapping tools. +/obj/effect/landmark/unit_test_bottom_left + name = "unit test zone bottom left" + +/// Marks the top right of the testing zone. +/// In landmarks.dm and not unit_test.dm so it is always active in the mapping tools. +/obj/effect/landmark/unit_test_top_right + name = "unit test zone top right" diff --git a/code/game/world.dm b/code/game/world.dm index 9fe96a67d9cd9..7931b9bacef22 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -146,6 +146,7 @@ GLOBAL_VAR(restart_counter) //trigger things to run the whole process Master.sleep_offline_after_initializations = FALSE SSticker.start_immediately = TRUE + SSticker.bypass_checks = TRUE CONFIG_SET(number/round_end_countdown, 0) var/datum/callback/cb #ifdef UNIT_TESTS diff --git a/code/modules/unit_tests/connect_loc.dm b/code/modules/unit_tests/connect_loc.dm index 457adab02d1d6..69cd4fa098564 100644 --- a/code/modules/unit_tests/connect_loc.dm +++ b/code/modules/unit_tests/connect_loc.dm @@ -11,7 +11,7 @@ SEND_SIGNAL(current_turf, COMSIG_MOCK_SIGNAL) TEST_ASSERT_EQUAL(watcher.times_called, 1, "After firing mock signal, connect_loc didn't send it") - watcher.forceMove(run_loc_top_right) + watcher.forceMove(run_loc_floor_top_right) SEND_SIGNAL(current_turf, COMSIG_MOCK_SIGNAL) TEST_ASSERT_EQUAL(watcher.times_called, 1, "Mock signal was fired on old turf, but connect_loc still picked it up") @@ -25,7 +25,7 @@ var/old_turf_type /datum/unit_test/connect_loc_change_turf/Run() - var/obj/item/watches_mock_calls/watcher = allocate(/obj/item/watches_mock_calls, run_loc_bottom_left) + var/obj/item/watches_mock_calls/watcher = allocate(/obj/item/watches_mock_calls, run_loc_floor_bottom_left) var/turf/current_turf = get_turf(watcher) old_turf_type = current_turf.type @@ -43,17 +43,17 @@ TEST_ASSERT_EQUAL(watcher.times_called, 3, "After changing turf a second time, connect_loc didn't reconnect it") /datum/unit_test/connect_loc_change_turf/Destroy() - run_loc_bottom_left.ChangeTurf(old_turf_type) + run_loc_floor_bottom_left.ChangeTurf(old_turf_type) return ..() /// Tests that multiple objects can have connect_loc on the same turf without runtimes. /datum/unit_test/connect_loc_multiple_on_turf /datum/unit_test/connect_loc_multiple_on_turf/Run() - var/obj/item/watches_mock_calls/watcher_one = allocate(/obj/item/watches_mock_calls, run_loc_bottom_left) + var/obj/item/watches_mock_calls/watcher_one = allocate(/obj/item/watches_mock_calls, run_loc_floor_bottom_left) qdel(watcher_one) - var/obj/item/watches_mock_calls/watcher_two = allocate(/obj/item/watches_mock_calls, run_loc_bottom_left) + var/obj/item/watches_mock_calls/watcher_two = allocate(/obj/item/watches_mock_calls, run_loc_floor_bottom_left) qdel(watcher_two) /obj/item/watches_mock_calls diff --git a/code/modules/unit_tests/unit_test.dm b/code/modules/unit_tests/unit_test.dm index 8d369ebc95047..5d25480d08fdb 100644 --- a/code/modules/unit_tests/unit_test.dm +++ b/code/modules/unit_tests/unit_test.dm @@ -7,7 +7,7 @@ Call Fail() to fail the test (You should specify a reason) You may use /New() and /Destroy() for setup/teardown respectively -You can use the run_loc_bottom_left and run_loc_top_right to get turfs for testing +You can use the run_loc_floor_bottom_left and run_loc_floor_top_right to get turfs for testing */ @@ -18,14 +18,11 @@ GLOBAL_VAR_INIT(failed_any_test, FALSE) //Bit of metadata for the future maybe var/list/procs_tested - /// The bottom left turf of the testing zone - var/turf/run_loc_bottom_left + /// The bottom left floor turf of the testing zone + var/turf/run_loc_floor_bottom_left - /// The top right turf of the testing zone - var/turf/run_loc_top_right - - /// The type of turf to allocate for the testing zone - var/test_turf_type = /turf/open/floor/plating + /// The top right floor turf of the testing zone + var/turf/run_loc_floor_top_right //internal shit var/focus = FALSE @@ -33,23 +30,27 @@ GLOBAL_VAR_INIT(failed_any_test, FALSE) var/list/allocated var/list/fail_reasons - var/static/datum/turf_reservation/turf_reservation + var/static/datum/space_level/reservation /datum/unit_test/New() - if (isnull(turf_reservation)) - turf_reservation = SSmapping.RequestBlockReservation(5, 5) - - for (var/turf/reserved_turf in turf_reservation.reserved_turfs) - reserved_turf.ChangeTurf(test_turf_type) + if (isnull(reservation)) + var/datum/map_template/unit_tests/template = new + reservation = template.load_new_z() allocated = new - run_loc_bottom_left = locate(turf_reservation.bottom_left_coords[1], turf_reservation.bottom_left_coords[2], turf_reservation.bottom_left_coords[3]) - run_loc_top_right = locate(turf_reservation.top_right_coords[1], turf_reservation.top_right_coords[2], turf_reservation.top_right_coords[3]) + run_loc_floor_bottom_left = get_turf(locate(/obj/effect/landmark/unit_test_bottom_left) in GLOB.landmarks_list) + run_loc_floor_top_right = get_turf(locate(/obj/effect/landmark/unit_test_top_right) in GLOB.landmarks_list) + + TEST_ASSERT(isfloorturf(run_loc_floor_bottom_left), "run_loc_floor_bottom_left was not a floor ([run_loc_floor_bottom_left])") + TEST_ASSERT(isfloorturf(run_loc_floor_top_right), "run_loc_floor_top_right was not a floor ([run_loc_floor_top_right])") /datum/unit_test/Destroy() - //clear the test area - for(var/atom/movable/AM in block(run_loc_bottom_left, run_loc_top_right)) - qdel(AM) + // clear the test area + for(var/turf/turf in block(locate(1, 1, run_loc_floor_bottom_left.z), locate(world.maxx, world.maxy, run_loc_floor_bottom_left.z))) + for(var/content in turf.contents) + if(iseffect(content)) + continue + qdel(content) QDEL_LIST(allocated) return ..() @@ -69,9 +70,9 @@ GLOBAL_VAR_INIT(failed_any_test, FALSE) /datum/unit_test/proc/allocate(type, ...) var/list/arguments = args.Copy(2) if (!length(arguments)) - arguments = list(run_loc_bottom_left) + arguments = list(run_loc_floor_bottom_left) else if (arguments[1] == null) - arguments[1] = run_loc_bottom_left + arguments[1] = run_loc_floor_bottom_left var/instance = new type(arglist(arguments)) allocated += instance return instance @@ -122,3 +123,7 @@ GLOBAL_VAR_INIT(failed_any_test, FALSE) SSticker.force_ending = TRUE SSticker.Reboot() + +/datum/map_template/unit_tests + name = "Unit Tests Zone" + mappath = "_maps/templates/unit_tests.dmm" diff --git a/code/modules/unit_tests/weed_ability.dm b/code/modules/unit_tests/weed_ability.dm index e4a500fbb7ca0..44a843f7d3157 100644 --- a/code/modules/unit_tests/weed_ability.dm +++ b/code/modules/unit_tests/weed_ability.dm @@ -1,21 +1,7 @@ /datum/unit_test/weed_ability - var/turf/open/open_tile - var/turf/claimed_tile - -/datum/unit_test/weed_ability/New() - ..() - - //create a tile so we can drop the weeds - claimed_tile = run_loc_bottom_left - open_tile = new(locate(run_loc_bottom_left.x, run_loc_bottom_left.y, run_loc_bottom_left.z)) - - -/datum/unit_test/weed_ability/Destroy() - open_tile.copyTurf(claimed_tile) - return ..() /datum/unit_test/weed_ability/Run() - var/mob/living/carbon/xenomorph/drone/drone = new(open_tile) + var/mob/living/carbon/xenomorph/drone/drone = new(run_loc_floor_bottom_left) var/datum/action/xeno_action/activable/plant_weeds/weed = drone.actions_by_path[/datum/action/xeno_action/activable/plant_weeds] if(!weed.can_use_action()) Fail("Drone could not activate weed ability!") diff --git a/code/modules/unit_tests/weed_spread.dm b/code/modules/unit_tests/weed_spread.dm index e59fd053babfd..50fdebcccb65c 100644 --- a/code/modules/unit_tests/weed_spread.dm +++ b/code/modules/unit_tests/weed_spread.dm @@ -1,5 +1,5 @@ /datum/unit_test/weed_spread/Run() - var/obj/alien/weeds/node/node = new(locate(run_loc_bottom_left.x+1, run_loc_bottom_left.y+1, run_loc_bottom_left.z)) + var/obj/alien/weeds/node/node = new(locate(run_loc_floor_bottom_left.x+1, run_loc_floor_bottom_left.y+1, run_loc_floor_bottom_left.z)) sleep(6 SECONDS) var/found = FALSE var/turf/origin = get_turf(node) diff --git a/tgmc.dme b/tgmc.dme index 5c08beb80dfdb..1d0c6f2e3275b 100755 --- a/tgmc.dme +++ b/tgmc.dme @@ -12,6 +12,7 @@ // BEGIN_INCLUDE #include "_maps\_basemap.dm" #include "_maps\map_files\generic\Admin_Level.dmm" +#include "_maps\templates\unit_tests.dmm" #include "code\__byond_version_compat.dm" #include "code\_compile_options.dm" #include "code\world.dm"