From 9e6a7412b1d278d8f7a168bf2cf47f49652ff4cd Mon Sep 17 00:00:00 2001 From: Lucy Date: Wed, 26 Jun 2024 15:11:04 -0400 Subject: [PATCH] Adds a unit test to ensure that xenobio pens are properly mapped in (#2374) * Adds a unit test to ensure that xenobio pens are properly mapped in * byeah --- code/modules/unit_tests/_unit_tests.dm | 1 + .../modules/unit_tests/linked_xenobio_pens.dm | 20 +++++++++++++++++++ .../modules/slimecore/machines/ooze_sucker.dm | 7 +++++++ .../machines/slime_pen_controller.dm | 7 +++++++ 4 files changed, 35 insertions(+) create mode 100644 code/modules/unit_tests/linked_xenobio_pens.dm diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index 80895a0dfd56..da3c7922bc0b 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -138,6 +138,7 @@ #include "leash.dm" #include "lesserform.dm" #include "limbsanity.dm" +#include "linked_xenobio_pens.dm" #include "load_map_security.dm" #include "lungs.dm" #include "machine_disassembly.dm" diff --git a/code/modules/unit_tests/linked_xenobio_pens.dm b/code/modules/unit_tests/linked_xenobio_pens.dm new file mode 100644 index 000000000000..8dc582a73e56 --- /dev/null +++ b/code/modules/unit_tests/linked_xenobio_pens.dm @@ -0,0 +1,20 @@ +/// This test ensures that any mapped xenobiology pens properly have a unique mapping ID set between each ooze sucker and slime pen management console. +/datum/unit_test/linked_xenobio_pens + +/datum/unit_test/linked_xenobio_pens/Run() + var/list/obj/machinery/plumbing/ooze_sucker/used_map_ids = list() + for(var/obj/machinery/slime_pen_controller/pen as anything in GLOB.slime_pen_controllers) + if(!pen.mapping_id) + TEST_FAIL("Found a slime pen management console without a mapping ID at [AREACOORD(pen)]!") + else if(used_map_ids[pen.mapping_id]) + TEST_FAIL("Found a slime pen management console with duplicate mapping_id [pen.mapping_id] at [AREACOORD(pen)], which is already used by the console at [AREACOORD(used_map_ids[pen.mapping_id])]!") + else + used_map_ids[pen.mapping_id] = pen + for(var/obj/machinery/plumbing/ooze_sucker/sucker as anything in GLOB.ooze_suckers) + if(!sucker.mapping_id) + TEST_FAIL("Found an ooze sucker without a mapping ID at [AREACOORD(sucker)]!") + else if(!used_map_ids[sucker.mapping_id]) + TEST_FAIL("Found an ooze sucker with an unused mapping ID at [AREACOORD(sucker)]!") + else if(!sucker.linked_controller) + TEST_FAIL("Ooze sucker failed to link to controller at [AREACOORD(sucker)]!") + diff --git a/monkestation/code/modules/slimecore/machines/ooze_sucker.dm b/monkestation/code/modules/slimecore/machines/ooze_sucker.dm index 61f37dd8e126..204b2e61d097 100644 --- a/monkestation/code/modules/slimecore/machines/ooze_sucker.dm +++ b/monkestation/code/modules/slimecore/machines/ooze_sucker.dm @@ -2,6 +2,8 @@ #define SUCKER_UPGRADE_BALANCER "balancer" #define SUCKER_UPGRADE_CAPACITY "capacity" +GLOBAL_LIST_EMPTY_TYPED(ooze_suckers, /obj/machinery/plumbing/ooze_sucker) + ///this cannablizes floor_pump code but rips specific reagents and and such just does stuff itself so it can be expanded easier in the future /obj/machinery/plumbing/ooze_sucker name = "ooze sucker" @@ -45,6 +47,7 @@ /obj/machinery/plumbing/ooze_sucker/Initialize(mapload, bolt, layer) . = ..() + GLOB.ooze_suckers += src AddComponent(/datum/component/plumbing/simple_supply, bolt, layer) return INITIALIZE_HINT_LATELOAD @@ -52,6 +55,10 @@ . = ..() locate_machinery() +/obj/machinery/plumbing/ooze_sucker/Destroy() + GLOB.ooze_suckers -= src + return ..() + /obj/machinery/plumbing/ooze_sucker/locate_machinery(multitool_connection) if(!mapping_id) return diff --git a/monkestation/code/modules/slimecore/machines/slime_pen_controller.dm b/monkestation/code/modules/slimecore/machines/slime_pen_controller.dm index 274c482a5863..04bd25de1a8a 100644 --- a/monkestation/code/modules/slimecore/machines/slime_pen_controller.dm +++ b/monkestation/code/modules/slimecore/machines/slime_pen_controller.dm @@ -1,3 +1,5 @@ +GLOBAL_LIST_EMPTY_TYPED(slime_pen_controllers, /obj/machinery/slime_pen_controller) + /obj/item/wallframe/slime_pen_controller name = "slime pen management frame" desc = "Used for building slime pen consoles." @@ -21,6 +23,7 @@ /obj/machinery/slime_pen_controller/Initialize(mapload) . = ..() + GLOB.slime_pen_controllers += src register_context() return INITIALIZE_HINT_LATELOAD @@ -28,6 +31,10 @@ . = ..() locate_machinery() +/obj/machinery/slime_pen_controller/Destroy() + GLOB.slime_pen_controllers -= src + return ..() + /obj/machinery/slime_pen_controller/add_context(atom/source, list/context, obj/item/held_item, mob/user) . = ..()