From d55f6d10da52cebd38ad4583f910aadb3715e1ee Mon Sep 17 00:00:00 2001 From: S34N <12197162+S34NW@users.noreply.github.com> Date: Mon, 19 Dec 2022 14:32:49 +0000 Subject: [PATCH] Fixes a niche dufflebag issue (#19883) * fixes chat issues * removal fixes * this --- .../objects/items/weapons/storage/backpack.dm | 21 +++++++++++++++---- .../objects/items/weapons/storage/storage.dm | 8 +++++++ .../kitchen_machinery/smartfridge.dm | 3 +++ code/modules/hydroponics/seed_extractor.dm | 3 +++ code/modules/mob/mob.dm | 4 ++-- code/modules/recycling/disposal.dm | 2 ++ 6 files changed, 35 insertions(+), 6 deletions(-) diff --git a/code/game/objects/items/weapons/storage/backpack.dm b/code/game/objects/items/weapons/storage/backpack.dm index 3d304cf2945..1c48b57d2c7 100644 --- a/code/game/objects/items/weapons/storage/backpack.dm +++ b/code/game/objects/items/weapons/storage/backpack.dm @@ -383,9 +383,12 @@ playsound(src, 'sound/items/zip.ogg', 75, TRUE) zipped = !zipped - if(!zipped && zip_time) // Handle slowdown and stuff now that we just zipped it - slowdown = 1 + if(!zipped) // Handle slowdown and stuff now that we just zipped it show_to(user) + + if(zip_time) + slowdown = 1 + return slowdown = 0 @@ -395,14 +398,24 @@ // The following three procs handle refusing access to contents if the duffel is zipped -/obj/item/storage/backpack/duffel/handle_item_insertion(obj/item/I, prevent_warning) +/obj/item/storage/backpack/duffel/handle_item_insertion(obj/item/I, prevent_warning, bypass_zip = FALSE) + if(bypass_zip) + return ..() + if(zipped) to_chat(usr, "[src] is zipped shut!") return FALSE return ..() -/obj/item/storage/backpack/duffel/remove_from_storage(obj/item/I, atom/new_location) +/obj/item/storage/backpack/duffel/removal_allowed_check(mob/user) + if(zipped) + to_chat(user, "[src] is zipped shut!") + return FALSE + + return TRUE + +/obj/item/storage/backpack/duffel/drop_inventory(user) if(zipped) to_chat(usr, "[src] is zipped shut!") return FALSE diff --git a/code/game/objects/items/weapons/storage/storage.dm b/code/game/objects/items/weapons/storage/storage.dm index abb6c7ad622..5639f044353 100644 --- a/code/game/objects/items/weapons/storage/storage.dm +++ b/code/game/objects/items/weapons/storage/storage.dm @@ -93,6 +93,9 @@ continue hide_from(player) +/obj/item/storage/proc/removal_allowed_check(mob/user) + return TRUE + /obj/item/storage/MouseDrop(obj/over_object) if(!ismob(usr)) //so monkeys can take off their backpacks -- Urist return @@ -110,6 +113,9 @@ if((istype(over_object, /obj/structure/table) || isfloorturf(over_object)) && length(contents) \ && loc == M && !M.stat && !M.restrained() && !HAS_TRAIT(M, TRAIT_HANDS_BLOCKED) && over_object.Adjacent(M) && !istype(src, /obj/item/storage/lockbox)) // Worlds longest `if()` var/turf/T = get_turf(over_object) + if(!removal_allowed_check(M)) + return + if(isfloorturf(over_object)) if(get_turf(M) != T) return // Can only empty containers onto the floor under you @@ -580,6 +586,8 @@ if((!ishuman(usr) && (loc != usr)) || usr.stat || usr.restrained()) return + if(!removal_allowed_check(usr)) + return drop_inventory(usr) diff --git a/code/modules/food_and_drinks/kitchen_machinery/smartfridge.dm b/code/modules/food_and_drinks/kitchen_machinery/smartfridge.dm index 32b0fb54d53..747a2dae44e 100644 --- a/code/modules/food_and_drinks/kitchen_machinery/smartfridge.dm +++ b/code/modules/food_and_drinks/kitchen_machinery/smartfridge.dm @@ -336,6 +336,9 @@ else if(isstorage(I.loc)) var/obj/item/storage/S = I.loc + if(!S.removal_allowed_check(user)) + return + S.remove_from_storage(I, src) else if(ismob(I.loc)) var/mob/M = I.loc diff --git a/code/modules/hydroponics/seed_extractor.dm b/code/modules/hydroponics/seed_extractor.dm index 4fe142f4426..94204086933 100644 --- a/code/modules/hydroponics/seed_extractor.dm +++ b/code/modules/hydroponics/seed_extractor.dm @@ -203,6 +203,9 @@ return else if(isstorage(O.loc)) var/obj/item/storage/S = O.loc + if(!S.removal_allowed_check(user)) + return + S.remove_from_storage(O, src) for(var/datum/seed_pile/N in piles) //this for loop physically hurts me diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index c1de6019696..ac4a28b63bf 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -249,8 +249,8 @@ //Mob can't equip it. Put it their backpack or toss it on the floor if(isstorage(back)) var/obj/item/storage/S = back - //Now, B represents a container we can insert W into. - S.handle_item_insertion(W,1) + //Now, S represents a container we can insert W into. + S.handle_item_insertion(W, TRUE, TRUE) return S var/turf/T = get_turf(src) diff --git a/code/modules/recycling/disposal.dm b/code/modules/recycling/disposal.dm index 06cc7eac8c5..233f60f4c41 100644 --- a/code/modules/recycling/disposal.dm +++ b/code/modules/recycling/disposal.dm @@ -98,6 +98,8 @@ if(isstorage(I)) var/obj/item/storage/S = I + if(!S.removal_allowed_check(user)) + return if((S.allow_quick_empty || S.allow_quick_gather) && S.contents.len) S.hide_from(user) user.visible_message("[user] empties \the [S] into \the [src].", "You empty \the [S] into \the [src].")