Skip to content

Commit

Permalink
fix(code): storage subtypes not returning the removal result
Browse files Browse the repository at this point in the history
The return value of the `remove_from_storage` proc is used by the item
interactions code to determine if item was successfully removed or
stayed inside the storage.

Subtypes of storage had inconsistent overrides of the
`remove_from_storage` proc which led to interactions failing midway and
dropping items on the floor instead of letting the user take them out of
storage, e.g. when cigars were taken from the cigar case.
  • Loading branch information
rufuszero committed Jan 27, 2025
1 parent 2e5d329 commit 49bfd87
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 20 deletions.
5 changes: 3 additions & 2 deletions code/game/objects/items/storage/bags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
update_w_class()

/obj/item/storage/bag/remove_from_storage(obj/item/W as obj, atom/new_location)
. = ..()
if(.)
var/item_removed = ..()
if(item_removed)
update_w_class()
return item_removed

/obj/item/storage/bag/can_be_inserted(obj/item/W, mob/user, feedback = TRUE)
if(istype(loc, /obj/item/storage))
Expand Down
14 changes: 7 additions & 7 deletions code/game/objects/items/storage/fancy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
var/hasany = 0 //if an item only changes sprite upon being used/finished, w/out displaying each key_type occasion

/obj/item/storage/fancy/remove_from_storage()
. = ..()
if(!opened && .)
var/item_removed = ..()
if(!opened && item_removed)
opened = 1
update_icon()

return item_removed

/obj/item/storage/fancy/update_icon()
if(!opened)
Expand Down Expand Up @@ -156,11 +156,10 @@
create_reagents(5 * max_storage_space)//so people can inject cigarettes without opening a packet, now with being able to inject the whole one

/obj/item/storage/fancy/cigarettes/remove_from_storage(obj/item/W, atom/new_location)
// Don't try to transfer reagents to lighters
if(istype(W, /obj/item/clothing/mask/smokable/cigarette))
var/obj/item/clothing/mask/smokable/cigarette/C = W
reagents.trans_to_obj(C, (reagents.total_volume/contents.len))
..()
return ..()

/obj/item/storage/fancy/cigarettes/attack(mob/living/carbon/M, mob/living/carbon/user)
if(!ismob(M))
Expand Down Expand Up @@ -341,9 +340,10 @@

/obj/item/storage/fancy/cigar/remove_from_storage(obj/item/W, atom/new_location)
var/obj/item/clothing/mask/smokable/cigarette/cigar/C = W
if(!istype(C)) return
if(!istype(C))
return
reagents.trans_to_obj(C, (reagents.total_volume/contents.len))
..()
return ..()

/*
* Vial Box
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/storage/specialized.dm
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
/obj/item/storage/sheetsnatcher/remove_from_storage(obj/item/W as obj, atom/new_location)
var/obj/item/stack/material/S = W
if(!istype(S))
return 0
return FALSE

//I would prefer to drop a new stack, but the item/attack_hand code
// that calls this can't recieve a different object than you clicked on.
Expand All @@ -132,7 +132,7 @@
temp.amount = S.amount - S.max_amount
S.amount = S.max_amount

return ..(S,new_location)
return ..()

/obj/item/storage/sheetsnatcher/borg
name = "sheet snatcher 9000"
Expand Down
2 changes: 2 additions & 0 deletions code/game/objects/items/storage/storage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@
// It also optionally updates the UI and storage's icon if `feedback` parameter is set to TRUE.
//
// If `new_location` is not passed, the item is removed from the storage and placed on the turf below instead.
//
// The return value indicates if removal from storage was successful and the item was moved.
/obj/item/storage/proc/remove_from_storage(obj/item/W as obj, atom/new_location, feedback = TRUE)
if(!istype(W))
return FALSE
Expand Down
12 changes: 6 additions & 6 deletions code/game/objects/items/storage/wallets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@
. = ..()

/obj/item/storage/wallet/remove_from_storage(obj/item/W as obj, atom/new_location)
. = ..(W, new_location)
if(.)
if(W == front_id)
front_id = null
SetName(initial(name))
update_icon()
var/item_removed = ..()
if(item_removed && (W == front_id))
front_id = null
SetName(initial(name))
update_icon()
return item_removed

/obj/item/storage/wallet/handle_item_insertion(obj/item/W as obj, feedback = TRUE)
. = ..()
Expand Down
6 changes: 3 additions & 3 deletions code/modules/spells/racial_wizard.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@

//HUMAN
/obj/item/storage/bag/cash/infinite/remove_from_storage(obj/item/W as obj, atom/new_location)
. = ..()
if(.)
var/item_removed = ..()
if(item_removed)
if(istype(W,/obj/item/spacecash)) //only matters if its spacecash.
var/obj/item/I = new /obj/item/spacecash/bundle/c1000()
src.handle_item_insertion(I, feedback = FALSE)

return item_removed

//Tajaran
/datum/spell/messa_shroud
Expand Down

0 comments on commit 49bfd87

Please sign in to comment.