Skip to content

Commit

Permalink
Adds a unit test to ensure that xenobio pens are properly mapped in (#…
Browse files Browse the repository at this point in the history
…2374)

* Adds a unit test to ensure that xenobio pens are properly mapped in

* byeah
  • Loading branch information
Absolucy authored Jun 26, 2024
1 parent 1360950 commit 9e6a741
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions code/modules/unit_tests/_unit_tests.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
20 changes: 20 additions & 0 deletions code/modules/unit_tests/linked_xenobio_pens.dm
Original file line number Diff line number Diff line change
@@ -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)]!")

7 changes: 7 additions & 0 deletions monkestation/code/modules/slimecore/machines/ooze_sucker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -45,13 +47,18 @@

/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

/obj/machinery/plumbing/ooze_sucker/LateInitialize()
. = ..()
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
Expand Down
Original file line number Diff line number Diff line change
@@ -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."
Expand All @@ -21,13 +23,18 @@

/obj/machinery/slime_pen_controller/Initialize(mapload)
. = ..()
GLOB.slime_pen_controllers += src
register_context()
return INITIALIZE_HINT_LATELOAD

/obj/machinery/slime_pen_controller/LateInitialize()
. = ..()
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)
. = ..()

Expand Down

0 comments on commit 9e6a741

Please sign in to comment.