diff --git a/_maps/templates/unit_tests.dmm b/_maps/templates/unit_tests.dmm new file mode 100644 index 00000000000..deab00c38cf --- /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/objects/effects/landmarks.dm b/code/game/objects/effects/landmarks.dm index 897b40f27db..c09c677ccfb 100644 --- a/code/game/objects/effects/landmarks.dm +++ b/code/game/objects/effects/landmarks.dm @@ -435,3 +435,13 @@ INITIALIZE_IMMEDIATE(/obj/effect/landmark/start/new_player) name = "portal exit" icon_state = "portal_exit" var/id + +/// 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/modules/unit_tests/chain_pull_through_space.dm b/code/modules/unit_tests/chain_pull_through_space.dm index ffdd1bf7c90..10363d5aadf 100644 --- a/code/modules/unit_tests/chain_pull_through_space.dm +++ b/code/modules/unit_tests/chain_pull_through_space.dm @@ -1,6 +1,6 @@ /datum/unit_test/chain_pull_through_space var/turf/open/space/space_tile - var/turf/claimed_tile + var/claimed_tile var/mob/living/carbon/human/alice var/mob/living/carbon/human/bob var/mob/living/carbon/human/charlie @@ -9,25 +9,25 @@ ..() // Create a space tile that goes to another z-level - claimed_tile = run_loc_bottom_left + claimed_tile = run_loc_floor_bottom_left.type - space_tile = new(locate(run_loc_bottom_left.x, run_loc_bottom_left.y, run_loc_bottom_left.z)) + space_tile = new(locate(run_loc_floor_bottom_left.x, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z)) space_tile.destination_x = 100 space_tile.destination_y = 100 space_tile.destination_z = 5 // Create our list of humans, all adjacent to one another - alice = new(locate(run_loc_bottom_left.x + 2, run_loc_bottom_left.y, run_loc_bottom_left.z)) + alice = new(locate(run_loc_floor_bottom_left.x + 2, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z)) alice.name = "Alice" - bob = new(locate(run_loc_bottom_left.x + 3, run_loc_bottom_left.y, run_loc_bottom_left.z)) + bob = new(locate(run_loc_floor_bottom_left.x + 3, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z)) bob.name = "Bob" - charlie = new(locate(run_loc_bottom_left.x + 4, run_loc_bottom_left.y, run_loc_bottom_left.z)) + charlie = new(locate(run_loc_floor_bottom_left.x + 4, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z)) charlie.name = "Charlie" /datum/unit_test/chain_pull_through_space/Destroy() - space_tile.copyTurf(claimed_tile) + space_tile.ChangeTurf(claimed_tile) qdel(alice) qdel(bob) qdel(charlie) @@ -40,14 +40,14 @@ bob.start_pulling(charlie) // Walk normally to the left, make sure we're still a chain - alice.Move(locate(run_loc_bottom_left.x + 1, run_loc_bottom_left.y, run_loc_bottom_left.z)) - if (bob.x != run_loc_bottom_left.x + 2) + alice.Move(locate(run_loc_floor_bottom_left.x + 1, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z)) + if (bob.x != run_loc_floor_bottom_left.x + 2) return Fail("During normal move, Bob was not at the correct x ([bob.x])") - if (charlie.x != run_loc_bottom_left.x + 3) + if (charlie.x != run_loc_floor_bottom_left.x + 3) return Fail("During normal move, Charlie was not at the correct x ([charlie.x])") // We're going through the space turf now that should teleport us - alice.Move(run_loc_bottom_left) + alice.Move(run_loc_floor_bottom_left) if (alice.z != space_tile.destination_z) return Fail("Alice did not teleport to the destination z-level. Current location: ([alice.x], [alice.y], [alice.z])") diff --git a/code/modules/unit_tests/combat.dm b/code/modules/unit_tests/combat.dm index 1bff1c52159..0ff236a3bed 100644 --- a/code/modules/unit_tests/combat.dm +++ b/code/modules/unit_tests/combat.dm @@ -76,15 +76,15 @@ var/obj/structure/barricade/dense_object = allocate(/obj/structure/barricade) // Attacker --> Victim --> Empty space --> Wall - attacker.forceMove(run_loc_bottom_left) - victim.forceMove(locate(run_loc_bottom_left.x + 1, run_loc_bottom_left.y, run_loc_bottom_left.z)) - dense_object.forceMove(locate(run_loc_bottom_left.x + 3, run_loc_bottom_left.y, run_loc_bottom_left.z)) + attacker.forceMove(run_loc_floor_bottom_left) + victim.forceMove(locate(run_loc_floor_bottom_left.x + 1, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z)) + dense_object.forceMove(locate(run_loc_floor_bottom_left.x + 3, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z)) // First disarm, world should now look like: // Attacker --> Empty space --> Victim --> Wall victim.attack_hand(attacker, list(RIGHT_CLICK = TRUE)) - TEST_ASSERT_EQUAL(victim.loc.x, run_loc_bottom_left.x + 2, "Victim wasn't moved back after being pushed") + TEST_ASSERT_EQUAL(victim.loc.x, run_loc_floor_bottom_left.x + 2, "Victim wasn't moved back after being pushed") TEST_ASSERT(!victim.has_status_effect(STATUS_EFFECT_KNOCKDOWN), "Victim was knocked down despite not being against a wall") TEST_ASSERT_EQUAL(victim.get_active_held_item(), toolbox, "Victim dropped toolbox despite not being against a wall") @@ -93,6 +93,6 @@ // Second disarm, victim was against wall and should be down victim.attack_hand(attacker, list(RIGHT_CLICK = TRUE)) - TEST_ASSERT_EQUAL(victim.loc.x, run_loc_bottom_left.x + 2, "Victim was moved after being pushed against a wall") + TEST_ASSERT_EQUAL(victim.loc.x, run_loc_floor_bottom_left.x + 2, "Victim was moved after being pushed against a wall") TEST_ASSERT(victim.has_status_effect(STATUS_EFFECT_KNOCKDOWN), "Victim was not knocked down after being pushed against a wall") //TEST_ASSERT_EQUAL(victim.get_active_held_item(), null, "Victim didn't drop toolbox after being pushed against a wall") //SKYRAT EDIT REMOVAL - COMBAT (knockdowns dont disarm no more) diff --git a/code/modules/unit_tests/hydroponics_harvest.dm b/code/modules/unit_tests/hydroponics_harvest.dm index 96215b68742..e4377499e58 100644 --- a/code/modules/unit_tests/hydroponics_harvest.dm +++ b/code/modules/unit_tests/hydroponics_harvest.dm @@ -27,7 +27,7 @@ var/mob/living/carbon/human/human = allocate(/mob/living/carbon/human) - hydroponics_tray.loc = run_loc_bottom_left + hydroponics_tray.loc = run_loc_floor_bottom_left human.loc = hydroponics_tray.loc human.x += 1 diff --git a/code/modules/unit_tests/projectiles.dm b/code/modules/unit_tests/projectiles.dm index f28b84b2daf..61189454c32 100644 --- a/code/modules/unit_tests/projectiles.dm +++ b/code/modules/unit_tests/projectiles.dm @@ -10,8 +10,6 @@ var/mob/living/carbon/human/victim = allocate(/mob/living/carbon/human) var/mob/living/carbon/human/gunner = allocate(/mob/living/carbon/human) - ADD_TRAIT(victim, TRAIT_RESISTLOWPRESSURE, INNATE_TRAIT) // so pressure damage doesn't throw off our damage check - var/obj/item/ammo_casing/loaded_casing = test_gun.chambered TEST_ASSERT(loaded_casing, "Gun started without round chambered, should be loaded") var/obj/projectile/loaded_bullet = loaded_casing.loaded_projectile diff --git a/code/modules/unit_tests/spawn_humans.dm b/code/modules/unit_tests/spawn_humans.dm index 0500deae0af..1bc7ca3d8a5 100644 --- a/code/modules/unit_tests/spawn_humans.dm +++ b/code/modules/unit_tests/spawn_humans.dm @@ -1,5 +1,5 @@ /datum/unit_test/spawn_humans/Run() - var/locs = block(run_loc_bottom_left, run_loc_top_right) + var/locs = block(run_loc_floor_bottom_left, run_loc_floor_top_right) for(var/I in 1 to 5) new /mob/living/carbon/human(pick(locs)) diff --git a/code/modules/unit_tests/teleporters.dm b/code/modules/unit_tests/teleporters.dm index fa2624adaa0..2cb047304fb 100644 --- a/code/modules/unit_tests/teleporters.dm +++ b/code/modules/unit_tests/teleporters.dm @@ -1,8 +1,8 @@ /datum/unit_test/auto_teleporter_linking/Run() // Put down the teleporter machinery var/obj/machinery/teleport/hub/hub = allocate(/obj/machinery/teleport/hub) - var/obj/machinery/teleport/station/station = allocate(/obj/machinery/teleport/station, locate(run_loc_bottom_left.x + 1, run_loc_bottom_left.y, run_loc_bottom_left.z)) - var/obj/machinery/computer/teleporter/computer = allocate(/obj/machinery/computer/teleporter, locate(run_loc_bottom_left.x + 2, run_loc_bottom_left.y, run_loc_bottom_left.z)) + var/obj/machinery/teleport/station/station = allocate(/obj/machinery/teleport/station, locate(run_loc_floor_bottom_left.x + 1, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z)) + var/obj/machinery/computer/teleporter/computer = allocate(/obj/machinery/computer/teleporter, locate(run_loc_floor_bottom_left.x + 2, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z)) TEST_ASSERT_EQUAL(hub.power_station, station, "Hub didn't link to the station") TEST_ASSERT_EQUAL(station.teleporter_console, computer, "Station didn't link to the teleporter console") diff --git a/code/modules/unit_tests/unit_test.dm b/code/modules/unit_tests/unit_test.dm index a55c0c95ca8..3cacc1c4d2c 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 */ @@ -19,14 +19,11 @@ GLOBAL_VAR(test_log) //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/iron + /// The top right floor turf of the testing zone + var/turf/run_loc_floor_top_right //internal shit var/focus = FALSE @@ -34,24 +31,28 @@ GLOBAL_VAR(test_log) 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) QDEL_LIST(allocated) + // 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) return ..() /datum/unit_test/proc/Run() @@ -70,9 +71,9 @@ GLOBAL_VAR(test_log) /datum/unit_test/proc/allocate(type, ...) var/list/arguments = args.Copy(2) if (!arguments.len) - 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 @@ -120,3 +121,7 @@ GLOBAL_VAR(test_log) file(file_name) << json_encode(test_results) SSticker.force_ending = TRUE + +/datum/map_template/unit_tests + name = "Unit Tests Zone" + mappath = "_maps/templates/unit_tests.dmm"