From 4a4f6db8f97780c493972aa022f701dde27bdc7a Mon Sep 17 00:00:00 2001 From: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Date: Tue, 25 Mar 2025 23:24:39 -0500 Subject: [PATCH] Fix storage whitelists / blacklists being ignored in some contexts (#90231) ## About The Pull Request It did not return FALSE unless it was set to print messages. Fixes #90226 ## Changelog :cl: Melbert fix: Fix storage whitelists / blacklists being ignored in some contexts (hotkeys) /:cl: --- code/datums/storage/storage.dm | 2 +- code/modules/unit_tests/storage.dm | 54 ++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/code/datums/storage/storage.dm b/code/datums/storage/storage.dm index 79222e6ad5d..4f99acaf9a7 100644 --- a/code/datums/storage/storage.dm +++ b/code/datums/storage/storage.dm @@ -441,7 +441,7 @@ GLOBAL_LIST_EMPTY(cached_storage_typecaches) stack_trace("[parent.type]:[to_insert.type] has TRAIT_NO_STORAGE_INSERT") else if(user) user.balloon_alert(user, "can't hold!") - return FALSE + return FALSE if(HAS_TRAIT(to_insert, TRAIT_NODROP)) if(messages) diff --git a/code/modules/unit_tests/storage.dm b/code/modules/unit_tests/storage.dm index cadf2261682..265acf2db0b 100644 --- a/code/modules/unit_tests/storage.dm +++ b/code/modules/unit_tests/storage.dm @@ -41,3 +41,57 @@ var/obj/item/item = allocate(item_type, run_loc_floor_bottom_left) item.melee_attack_chain(dummy, bag) TEST_ASSERT_EQUAL(item.loc, bag, "[item_type] was unable to be inserted into a backpack on click while off combat mode") + +// Tests that equip equip works +/datum/unit_test/quick_equip + +/datum/unit_test/quick_equip/Run() + var/mob/living/carbon/human/consistent/dummy = allocate(__IMPLIED_TYPE__, run_loc_floor_bottom_left) + var/obj/item/clothing/under/pants/jeans = allocate(__IMPLIED_TYPE__, run_loc_floor_bottom_left) + + dummy.equip_to_appropriate_slot(jeans) + + var/obj/item/assembly/flash/handheld/flash_one = allocate(__IMPLIED_TYPE__, run_loc_floor_bottom_left) + + dummy.put_in_active_hand(flash_one) + dummy.execute_quick_equip() + + TEST_ASSERT_EQUAL(dummy.l_store, flash_one, "Quick equip failed to equip the first flash to the left pocket") + + var/obj/item/assembly/flash/handheld/flash_two = allocate(__IMPLIED_TYPE__, run_loc_floor_bottom_left) + + dummy.put_in_active_hand(flash_two) + dummy.execute_quick_equip() + + TEST_ASSERT_EQUAL(dummy.r_store, flash_two, "Quick equip failed to equip the second flash to the right pocket") + + var/obj/item/assembly/flash/handheld/flash_three = allocate(__IMPLIED_TYPE__, run_loc_floor_bottom_left) + + dummy.put_in_active_hand(flash_three) + dummy.execute_quick_equip() + + TEST_ASSERT_EQUAL(dummy.get_active_held_item(), flash_three, "Quick equip should have left the third flash in the active hand") + +/// Tests that quick equip respects storage blacklists +/datum/unit_test/quick_equip_respects_storage + +/datum/unit_test/quick_equip_respects_storage/Run() + var/obj/item/storage/backpack/storage_item = allocate(__IMPLIED_TYPE__, run_loc_floor_bottom_left) + var/mob/living/carbon/human/consistent/dummy = allocate(__IMPLIED_TYPE__, run_loc_floor_bottom_left) + + dummy.equip_to_appropriate_slot(storage_item) + + var/obj/item/assembly/flash/handheld/flash_one = allocate(__IMPLIED_TYPE__, run_loc_floor_bottom_left) + + dummy.put_in_active_hand(flash_one) + dummy.execute_quick_equip() + + TEST_ASSERT_EQUAL(flash_one.loc, storage_item, "Quick equip failed to equip the first flash to the storage item") + + var/obj/item/assembly/flash/handheld/flash_two = allocate(__IMPLIED_TYPE__, run_loc_floor_bottom_left) + + storage_item.atom_storage.cant_hold = typecacheof(list(/obj/item/assembly/flash/handheld)) + dummy.put_in_active_hand(flash_two) + dummy.execute_quick_equip() + + TEST_ASSERT_EQUAL(dummy.get_active_held_item(), flash_two, "Quick equip should have left the second flash in the active hand")