From 49b7f8445ed78dce6f2cf0b5fdcffdb364ce9594 Mon Sep 17 00:00:00 2001 From: Bloop <13398309+vinylspiders@users.noreply.github.com> Date: Wed, 20 Dec 2023 13:44:50 -0500 Subject: [PATCH] Creates a unit test for loadout item duplicates (#25747) * Creates a unit test for loadout item duplicates * Update loadout_dupes.dm * Update loadout_dupes.dm * Update loadout_dupes.dm * Update loadout_datum_under.dm * I'm going to put the cargo shorts under misc/under * Revert "I'm going to put the cargo shorts under misc/under" This reverts commit e4cdbd80e42424091ad76be67502ced2cbadec13. --- code/modules/unit_tests/_unit_tests.dm | 1 + code/modules/unit_tests/~skyrat/loadout_dupes.dm | 14 ++++++++++++++ .../loadout_items/under/loadout_datum_under.dm | 8 -------- 3 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 code/modules/unit_tests/~skyrat/loadout_dupes.dm diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index 56c10327441..491edbcd580 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -275,6 +275,7 @@ #include "worn_icons.dm" // SKYRAT EDIT START #include "~skyrat\automapper.dm" +#include "~skyrat\loadout_dupes.dm" #include "~skyrat\opposing_force.dm" // SKYRAT EDIT END // END_INCLUDE diff --git a/code/modules/unit_tests/~skyrat/loadout_dupes.dm b/code/modules/unit_tests/~skyrat/loadout_dupes.dm new file mode 100644 index 00000000000..23bfe368905 --- /dev/null +++ b/code/modules/unit_tests/~skyrat/loadout_dupes.dm @@ -0,0 +1,14 @@ +///Checks that loadout items' item_paths are unique to the category of loadout item it belongs to +/datum/unit_test/loadout_dupes + +/datum/unit_test/loadout_dupes/Run() + var/list/item_paths = list() + for(var/datum/loadout_item/item as anything in subtypesof(/datum/loadout_item)) + var/loadout_item_category = initial(item.category) + var/item_path = initial(item.item_path) + if(item_paths[item_path] == loadout_item_category) + TEST_FAIL("Duplicate loadout item! [item_path] is already being used by [item].") + if(isnull(item_path)) // can be null, for subcategories of loadout items + continue + + item_paths[item_path] = loadout_item_category diff --git a/modular_skyrat/modules/loadouts/loadout_items/under/loadout_datum_under.dm b/modular_skyrat/modules/loadouts/loadout_items/under/loadout_datum_under.dm index 46ca5d512b8..14aa3ca4b44 100644 --- a/modular_skyrat/modules/loadouts/loadout_items/under/loadout_datum_under.dm +++ b/modular_skyrat/modules/loadouts/loadout_items/under/loadout_datum_under.dm @@ -179,10 +179,6 @@ GLOBAL_LIST_INIT(loadout_miscunders, generate_loadout_items(/datum/loadout_item/ item_path = /obj/item/clothing/under/rank/cargo/tech restricted_roles = list(JOB_CARGO_TECHNICIAN, JOB_QUARTERMASTER, JOB_CUSTOMS_AGENT) -/datum/loadout_item/under/jumpsuit/cargo/shorts - name = "Cargo Technician's Shorts" - item_path = /obj/item/clothing/under/rank/cargo/tech/alt - /datum/loadout_item/under/jumpsuit/cargo/skirt name = "Cargo Technician's Skirt" item_path = /obj/item/clothing/under/rank/cargo/tech/skirt @@ -747,10 +743,6 @@ GLOBAL_LIST_INIT(loadout_miscunders, generate_loadout_items(/datum/loadout_item/ name = "Navy Suit" item_path = /obj/item/clothing/under/suit/navy -/datum/loadout_item/under/formal/maid_outfit - name = "Maid Outfit" - item_path = /obj/item/clothing/under/costume/maid - /datum/loadout_item/under/formal/maid_uniform name = "Maid Uniform" item_path = /obj/item/clothing/under/rank/civilian/janitor/maid