From ac1b2f76efc49aa4ae4c8eca50a85e87e45c6121 Mon Sep 17 00:00:00 2001 From: John Ginnane Date: Mon, 15 Jan 2018 04:04:18 +0000 Subject: [PATCH] Fixed alt-click not working with stacks (#34396) * Can disable auto-merge New argument which lets you stop stacks from automatically merging when picking them up * Fix 0 stacks * Updated simple_animal/put_in_hands() --- code/game/objects/items/stacks/stack.dm | 2 +- code/modules/mob/inventory.dm | 24 +++++++++++-------- .../mob/living/simple_animal/simple_animal.dm | 4 ++-- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index 7463c69b4d..8dc0895d78 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -321,7 +321,7 @@ var/obj/item/stack/F = new type(user, amount, FALSE) . = F F.copy_evidences(src) - user.put_in_hands(F) + user.put_in_hands(F, merge_stacks=FALSE) add_fingerprint(user) F.add_fingerprint(user) use(amount, TRUE) diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index cc89f700dc..f494f32f6f 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -202,7 +202,7 @@ //Puts the item our active hand if possible. Failing that it tries other hands. Returns TRUE on success. //If both fail it drops it on the floor and returns FALSE. //This is probably the main one you need to know :) -/mob/proc/put_in_hands(obj/item/I, del_on_fail = FALSE) +/mob/proc/put_in_hands(obj/item/I, del_on_fail = FALSE, merge_stacks = TRUE) if(!I) return FALSE @@ -211,16 +211,20 @@ var/obj/item/stack/I_stack = I var/obj/item/stack/active_stack = get_active_held_item() - if (istype(active_stack) && istype(I_stack, active_stack.merge_type)) - if (I_stack.merge(active_stack)) - to_chat(usr, "Your [active_stack.name] stack now contains [active_stack.get_amount()] [active_stack.singular_name]\s.") - return TRUE - else - var/obj/item/stack/inactive_stack = get_inactive_held_item() - if (istype(inactive_stack) && istype(I_stack, inactive_stack.merge_type)) - if (I_stack.merge(inactive_stack)) - to_chat(usr, "Your [inactive_stack.name] stack now contains [inactive_stack.get_amount()] [inactive_stack.singular_name]\s.") + if (I_stack.zero_amount()) + return FALSE + + if (merge_stacks) + if (istype(active_stack) && istype(I_stack, active_stack.merge_type)) + if (I_stack.merge(active_stack)) + to_chat(usr, "Your [active_stack.name] stack now contains [active_stack.get_amount()] [active_stack.singular_name]\s.") return TRUE + else + var/obj/item/stack/inactive_stack = get_inactive_held_item() + if (istype(inactive_stack) && istype(I_stack, inactive_stack.merge_type)) + if (I_stack.merge(inactive_stack)) + to_chat(usr, "Your [inactive_stack.name] stack now contains [inactive_stack.get_amount()] [inactive_stack.singular_name]\s.") + return TRUE if(put_in_active_hand(I)) return TRUE diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index a668593095..634c1ebb5f 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -502,8 +502,8 @@ if(H) H.update_icon() -/mob/living/simple_animal/put_in_hands(obj/item/I) - ..() +/mob/living/simple_animal/put_in_hands(obj/item/I, del_on_fail = FALSE, merge_stacks = TRUE) + ..(I, del_on_fail, merge_stacks) update_inv_hands() /mob/living/simple_animal/update_inv_hands()