Skip to content

Commit

Permalink
inventory bugfixes (#1110)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kapu1178 authored Oct 31, 2024
1 parent 85c3dd4 commit 79914bf
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 47 deletions.
2 changes: 1 addition & 1 deletion code/_onclick/drag_drop.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
if(proximity_check)
return proximity_check

if(!Adjacent(usr) || !over.Adjacent(usr) && !istype(over, /atom/movable/screen))
if(!istype(over, /atom/movable/screen) && (!Adjacent(usr) || !over.Adjacent(usr)))
return // should stop you from dragging through windows

over.MouseDroppedOn(src, usr, params2list(params))
Expand Down
3 changes: 2 additions & 1 deletion code/_onclick/hud/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@
if(item_index)
user.swapHeldIndexes(item_index, held_index)
else
user.putItemFromInventoryInHandIfPossible(dropping, held_index)
user.putItemFromInventoryInHandIfPossible(dropping, held_index, use_unequip_delay = TRUE)
I.add_fingerprint(user)
return TRUE

/atom/movable/screen/close
Expand Down
8 changes: 0 additions & 8 deletions code/game/objects/items/defib.dm
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,6 @@
ui_action_click() //checks for this are handled in defibrillator.mount.dm
return ..()

/obj/item/defibrillator/MouseDrop(obj/over_object)
. = ..()
if(ismob(loc))
var/mob/M = loc
if(!M.incapacitated() && istype(over_object, /atom/movable/screen/inventory/hand))
var/atom/movable/screen/inventory/hand/H = over_object
M.putItemFromInventoryInHandIfPossible(src, H.held_index)

/obj/item/defibrillator/screwdriver_act(mob/living/user, obj/item/tool)
if(cell)
cell.update_appearance()
Expand Down
8 changes: 0 additions & 8 deletions code/game/objects/items/devices/portable_chem_mixer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,6 @@
return
return

/obj/item/storage/portable_chem_mixer/MouseDrop(obj/over_object)
. = ..()
if(ismob(loc))
var/mob/M = loc
if(!M.incapacitated() && istype(over_object, /atom/movable/screen/inventory/hand))
var/atom/movable/screen/inventory/hand/H = over_object
M.putItemFromInventoryInHandIfPossible(src, H.held_index)

/obj/item/storage/portable_chem_mixer/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
Expand Down
7 changes: 0 additions & 7 deletions code/game/objects/items/tanks/watertank.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,6 @@
else
return ..()

/obj/item/watertank/MouseDrop(obj/over_object)
var/mob/M = loc
if(istype(M) && istype(over_object, /atom/movable/screen/inventory/hand))
var/atom/movable/screen/inventory/hand/H = over_object
M.putItemFromInventoryInHandIfPossible(src, H.held_index)
return ..()

/obj/item/watertank/attackby(obj/item/attacking_item, mob/user, params)
if(attacking_item == noz)
remove_noz()
Expand Down
12 changes: 0 additions & 12 deletions code/modules/clothing/clothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,6 @@
if(!icon_state)
item_flags |= ABSTRACT

/obj/item/clothing/MouseDrop(atom/over_object)
. = ..()
var/mob/M = usr

if(ismecha(M.loc)) // stops inventory actions in a mech
return

if(!M.incapacitated() && loc == M && istype(over_object, /atom/movable/screen/inventory/hand))
var/atom/movable/screen/inventory/hand/H = over_object
if(M.putItemFromInventoryInHandIfPossible(src, H.held_index))
add_fingerprint(usr)

//This code is cursed, moths are cursed, and someday I will destroy it. but today is not that day.
/obj/item/food/clothing
name = "temporary moth clothing snack item"
Expand Down
11 changes: 7 additions & 4 deletions code/modules/mob/inventory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,14 @@
for(var/obj/item/I in held_items)
. |= dropItemToGround(I)

/mob/proc/putItemFromInventoryInHandIfPossible(obj/item/I, hand_index, force_removal = FALSE)
/mob/proc/putItemFromInventoryInHandIfPossible(obj/item/I, hand_index, force_removal = FALSE, use_unequip_delay = FALSE)
if(!can_put_in_hand(I, hand_index))
return FALSE
if(!temporarilyRemoveItemFromInventory(I, force_removal))
if(!temporarilyRemoveItemFromInventory(I, force_removal, use_unequip_delay = use_unequip_delay))
return FALSE

I.remove_item_from_storage(src)

if(!pickup_item(I, hand_index, ignore_anim = TRUE))
qdel(I)
CRASH("Assertion failure: putItemFromInventoryInHandIfPossible") //should never be possible
Expand Down Expand Up @@ -417,7 +419,8 @@
if((SEND_SIGNAL(I, COMSIG_ITEM_PRE_UNEQUIP, force, newloc, no_move, invdrop, silent) & COMPONENT_ITEM_BLOCK_UNEQUIP) && !force)
return FALSE

if(use_unequip_delay && !unequip_delay_self_check(I))
var/static/list/exclude_from_unequip_delay = list(null, ITEM_SLOT_RPOCKET, ITEM_SLOT_LPOCKET, ITEM_SLOT_SUITSTORE, ITEM_SLOT_BACKPACK, ITEM_SLOT_HANDS)
if(use_unequip_delay && !(get_slot_by_item(I) in exclude_from_unequip_delay) && !unequip_delay_self_check(I))
return FALSE

var/hand_index = get_held_index_of_item(I)
Expand Down Expand Up @@ -683,7 +686,7 @@
if(.)
visible_message(
span_notice("[src] takes off [I]."),
span_notice("You takes off [I].")
span_notice("You take off [I].")
)

/// Called by equip_delay_self and unequip_delay_self.
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/species.dm
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ GLOBAL_LIST_EMPTY(features_by_species)
return H.equip_delay_self_check(I, bypass_equip_delay_self)

if(ITEM_SLOT_NECK)
return TRUE
return H.equip_delay_self_check(I, bypass_equip_delay_self)

if(ITEM_SLOT_BACK)
return H.equip_delay_self_check(I, bypass_equip_delay_self)
Expand Down
8 changes: 3 additions & 5 deletions code/modules/mod/mod_control.dm
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,14 @@
/obj/item/mod/control/MouseDrop(atom/over_object)
if(usr != wearer || !istype(over_object, /atom/movable/screen/inventory/hand))
return ..()

for(var/obj/item/part as anything in get_parts())
if(part.loc != src)
balloon_alert(wearer, "retract parts first!")
playsound(src, 'sound/machines/scanbuzz.ogg', 25, FALSE, SILENCED_SOUND_EXTRARANGE)
return
if(!wearer.incapacitated())
var/atom/movable/screen/inventory/hand/ui_hand = over_object
if(wearer.putItemFromInventoryInHandIfPossible(src, ui_hand.held_index))
add_fingerprint(usr)
return ..()

return ..()

/obj/item/mod/control/wrench_act(mob/living/user, obj/item/wrench)
if(..())
Expand Down

0 comments on commit 79914bf

Please sign in to comment.