Skip to content

Commit

Permalink
Revert "Fixes for inserting/removing storage items/swapping items bet…
Browse files Browse the repository at this point in the history
…ween han…" (ParadiseSS13#27706)

This reverts commit 012e1f1.
  • Loading branch information
warriorstar-orion authored Dec 22, 2024
1 parent 012e1f1 commit 718b578
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 82 deletions.
17 changes: 9 additions & 8 deletions code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -338,25 +338,26 @@ GLOBAL_DATUM_INIT(welding_sparks, /mutable_appearance, mutable_appearance('icons
if(affecting && affecting.receive_damage(0, 5)) // 5 burn damage
H.UpdateDamageIcon()

if(isstorage(src.loc))
/// If the item is in a storage item, take it out
var/obj/item/storage/S = src.loc
S.remove_from_storage(src)

if(..())
return

if(throwing)
throwing.finalize(FALSE)
if(loc == user)
if(HAS_TRAIT(user, TRAIT_I_WANT_BRAINS))
return FALSE
if(!user.canUnEquip(src, force = FALSE))
if(HAS_TRAIT(user, TRAIT_I_WANT_BRAINS) || !user.unEquip(src, silent = TRUE))
return FALSE

if(flags & ABSTRACT)
return FALSE

if(user.is_in_inactive_hand(src))
return user.swap_item_between_hands()

if(isliving(loc))
return FALSE
else
if(isliving(loc))
return FALSE

pickup(user)
add_fingerprint(user)
Expand Down
48 changes: 25 additions & 23 deletions code/game/objects/items/weapons/storage/storage_base.dm
Original file line number Diff line number Diff line change
Expand Up @@ -436,42 +436,38 @@
* * prevent_warning - Stop the insertion message being displayed. Intended for cases when you are inserting multiple items at once.
*/
/obj/item/storage/proc/handle_item_insertion(obj/item/I, mob/user, prevent_warning = FALSE)
if(!istype(I) || QDELING(I))
if(!istype(I))
return FALSE
if(silent || HAS_TRAIT(I, TRAIT_SILENT_INSERTION))
prevent_warning = TRUE
if(user)
if(!Adjacent(user) && !isnewplayer(user))
return FALSE
if(!user.unEquip(I, force = FALSE, silent = TRUE, destination = src))
if(!user.unEquip(I, silent = TRUE))
return FALSE
user.update_icons() //update our overlays
if(QDELING(I))
return FALSE
if(silent || HAS_TRAIT(I, TRAIT_SILENT_INSERTION))
prevent_warning = TRUE
I.forceMove(src)
if(QDELING(I))
return FALSE
I.on_enter_storage(src)

for(var/_M in mobs_viewing)
var/mob/M = _M
if((M.s_active == src) && M.client)
M.client.screen += I
if(user)
if(user.client && user.s_active != src)
user.client.screen -= I
if(length(user.observers))
for(var/mob/observer in user.observers)
if(observer.client && observer.s_active != src)
observer.client.screen -= I

I.dropped(user, TRUE)
if(user)
add_fingerprint(user)

user.update_icons()

orient2hud(user)
if(user.s_active)
user.s_active.show_to(user)
else
I.forceMove(src)

I.on_enter_storage(src)
// So you can click on the area around the item to equip it, instead of having to pixel hunt
I.mouse_opacity = MOUSE_OPACITY_OPAQUE
I.in_inventory = TRUE

for(var/_M in mobs_viewing)
var/mob/M = _M
if((M.s_active == src) && M.client)
M.client.screen += I

if(!prevent_warning)
// the item's user will always get a notification
to_chat(user, "<span class='notice'>You put [I] into [src].</span>")
Expand All @@ -485,7 +481,13 @@
// restrict player list to include only those in view
for(var/mob/M in oviewers(7, user))
M.show_message("<span class='notice'>[user] puts [I] into [src].</span>")
orient2hud(user)
if(user)
if(user.s_active)
user.s_active.show_to(user)

I.mouse_opacity = MOUSE_OPACITY_OPAQUE //So you can click on the area around the item to equip it, instead of having to pixel hunt
I.in_inventory = TRUE
update_icon()
return TRUE

Expand Down
50 changes: 5 additions & 45 deletions code/modules/mob/inventory_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,34 +66,6 @@
if(ITEM_SLOT_RIGHT_HAND)
return put_in_r_hand(I)

/**
* Swaps items between hands.
*
* A separate implementation is required for this because all of the
* pre-existing equip/unEquip procs perform forceMoves we don't want.
*/
/mob/proc/swap_item_between_hands()
var/obj/item/I = get_inactive_hand()
if(!put_in_hand_check(I))
return FALSE

if(I == r_hand && has_left_hand())
r_hand = null
l_hand = I
update_inv_r_hand()
update_inv_l_hand()
I.equipped(src, ITEM_SLOT_LEFT_HAND)
return TRUE
else if(I == l_hand && has_right_hand())
l_hand = null
r_hand = I
update_inv_l_hand()
update_inv_r_hand()
I.equipped(src, ITEM_SLOT_RIGHT_HAND)
return TRUE

return FALSE

//Puts the item into your l_hand if possible and calls all necessary triggers/updates. returns 1 on success.
/mob/proc/put_in_l_hand(obj/item/W, skip_blocked_hands_check = FALSE)
if(!put_in_hand_check(W, skip_blocked_hands_check))
Expand Down Expand Up @@ -194,26 +166,13 @@

return TRUE

/**
* Unequip an item from the hand that the item is found in.
*
* `force` overrides NODROP for things like wizarditis and admin undress.
*
* `destination` allows for items to be unequipped directly into storage and
* should only be used for that.
*
* Horrid stop-gap until we get atom storage or something.
*/
/mob/proc/unEquip(obj/item/I, force = FALSE, silent = FALSE, atom/destination)
/mob/proc/unEquip(obj/item/I, force, silent = FALSE) //Force overrides NODROP for things like wizarditis and admin undress.
if(!I) //If there's nothing to drop, the drop is automatically succesfull. If(unEquip) should generally be used to check for NODROP.
return 1

if(!canUnEquip(I, force))
return 0

if(isnull(destination))
destination = drop_location()

if(I == r_hand)
r_hand = null
update_inv_r_hand()
Expand All @@ -222,13 +181,14 @@
update_inv_l_hand()
else if(I in tkgrabbed_objects)
var/obj/item/tk_grab/tkgrab = tkgrabbed_objects[I]
unEquip(tkgrab, force, silent, destination)
unEquip(tkgrab, force)

if(I)
if(client)
client.screen -= I
if(destination)
I.forceMove(destination)
var/turf/drop_loc = drop_location()
if(drop_loc)
I.forceMove(drop_loc)
else
I.moveToNullspace()
I.dropped(src, silent)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
//can't unequip since it can't equip anything // why the fuck is this it's own file
/mob/living/carbon/alien/larva/unEquip(obj/item/I, force = FALSE, silent = FALSE, atom/destination)
/mob/living/carbon/alien/larva/unEquip(obj/item/I, force, silent = FALSE)
return
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/carbon_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ GLOBAL_LIST_INIT(ventcrawl_machinery, list(/obj/machinery/atmospherics/unary/ven
/mob/living/carbon/get_restraining_item()
return handcuffed

/mob/living/carbon/unEquip(obj/item/I, force = FALSE, silent = FALSE, atom/destination)
/mob/living/carbon/unEquip(obj/item/I, force, silent = FALSE) //THIS PROC DID NOT CALL ..()
. = ..() //Sets the default return value to what the parent returns.
if(!. || !I) //We don't want to set anything to null if the parent returned 0.
return
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/human_inventory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
if(ITEM_SLOT_ACCESSORY)
return TRUE

/mob/living/carbon/human/unEquip(obj/item/I, force = FALSE, silent = FALSE, atom/destination)
/mob/living/carbon/human/unEquip(obj/item/I, force, silent = FALSE)
. = ..() //See mob.dm for an explanation on this and some rage about people copypasting instead of calling ..() like they should.
if(!. || !I)
return
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/silicon/robot/robot_inventory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
while(slot_start != slot_num) //If we wrap around without finding any free slots, just give up.
return

/mob/living/silicon/robot/unEquip(obj/item/I, force = FALSE, silent = FALSE, atom/destination)
/mob/living/silicon/robot/unEquip(obj/item/I, force, silent = FALSE)
if(I == module_active)
uneq_active(I)
return ..()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/simple_animal/simple_animal.dm
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@
if(ITEM_SLOT_COLLAR)
add_collar(W)

/mob/living/simple_animal/unEquip(obj/item/I, force = FALSE, silent = FALSE, atom/destination)
/mob/living/simple_animal/unEquip(obj/item/I, force, silent = FALSE)
. = ..()
if(!. || !I)
return
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/simple_animal/slime/slime_mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
return
return ..()

/mob/living/simple_animal/slime/unEquip(obj/item/I, force = FALSE, silent = FALSE, atom/destination)
/mob/living/simple_animal/slime/unEquip(obj/item/I, force, silent = FALSE)
return

/mob/living/simple_animal/slime/start_pulling(atom/movable/AM, state, force = pull_force, show_message = FALSE)
Expand Down

0 comments on commit 718b578

Please sign in to comment.