From 9ae4e3650c39875bcd1579f421239605e53a31cf Mon Sep 17 00:00:00 2001 From: Menshin Date: Sat, 13 Sep 2014 00:38:39 +0200 Subject: [PATCH 1/2] * prevented empty stacks from being generated on tiles, when merging stacks on floor after crafting them (e.g metal => floor). Fixes #4775 * various clean-up of unnecessary checks related to stacks --- code/game/objects/items/stacks/stack.dm | 26 ++++++++++++++----- .../objects/items/stacks/tiles/plasteel.dm | 5 ++-- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index 80fc7c2ec0b..b968b86039a 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -135,23 +135,32 @@ usr << "Building [R.title] ..." if (!do_after(usr, R.time)) return - if (src.get_amount() < R.req_amount*multiplier) - return + if (src.get_amount() < R.req_amount*multiplier) + return + var/atom/O = new R.result_type( usr.loc ) O.dir = usr.dir + use(R.req_amount * multiplier) + + //is it a stack ? if (R.max_res_amount > 1) var/obj/item/stack/new_item = O new_item.amount = R.res_amount*multiplier - new_item.add_to_stacks(usr) - use(R.req_amount * multiplier) + new_item.add_to_stacks(usr) //try to merge with existing stacks on current tile + + if(new_item.amount <= 0)//if the stack is empty, i.e it has been merged with an existing stack and has been garbage collected + return + if (istype(O,/obj/item)) usr.put_in_hands(O) O.add_fingerprint(usr) + //BubbleWrap - so newly formed boxes are empty if ( istype(O, /obj/item/weapon/storage) ) for (var/obj/item/I in O) qdel(I) //BubbleWrap END + if (src && usr.machine==src) //do not reopen closed window spawn( 0 ) src.interact(usr) @@ -167,6 +176,7 @@ if (amount <= 0) if(usr) usr.unEquip(src, 1) + src.loc = null qdel(src) return 1 @@ -188,7 +198,7 @@ continue oldsrc.attackby(item, usr) usr << "You add new [item.singular_name] to the stack. It now contains [item.amount] [item.singular_name]\s." - if(!oldsrc) + if(oldsrc.amount <= 0) break /obj/item/stack/attack_hand(mob/user as mob) @@ -206,7 +216,7 @@ return /obj/item/stack/attackby(obj/item/W as obj, mob/user as mob) - ..() + if (istype(W, src.type)) var/obj/item/stack/S = W if (S.is_cyborg) @@ -231,7 +241,9 @@ src.use(to_transfer) if (src && usr.machine==src) spawn(0) src.interact(usr) - else return ..() + + else + ..() /obj/item/stack/proc/copy_evidences(obj/item/stack/from as obj) src.blood_DNA = from.blood_DNA diff --git a/code/game/objects/items/stacks/tiles/plasteel.dm b/code/game/objects/items/stacks/tiles/plasteel.dm index a76a3e35da4..5e922c9a6c5 100644 --- a/code/game/objects/items/stacks/tiles/plasteel.dm +++ b/code/game/objects/items/stacks/tiles/plasteel.dm @@ -25,7 +25,7 @@ return /obj/item/stack/tile/plasteel/attackby(obj/item/W as obj, mob/user as mob) - ..() + if (istype(W, /obj/item/weapon/weldingtool)) var/obj/item/weapon/weldingtool/WT = W @@ -45,7 +45,8 @@ if (!R && replace) user.put_in_hands(new_item) return - ..() + else + ..() /* /obj/item/stack/tile/plasteel/attack_self(mob/user as mob) From abda57bc2612ef0fc35ba8096582e9612630c563 Mon Sep 17 00:00:00 2001 From: Menshin Date: Sun, 14 Sep 2014 11:51:02 +0200 Subject: [PATCH 2/2] Location nulling moved to Destroy() proc --- code/game/objects/items/stacks/stack.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index b968b86039a..9921a1ea472 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -29,6 +29,7 @@ return // Not supposed to be destroyed if (usr && usr.machine==src) usr << browse(null, "window=stack") + src.loc = null ..() /obj/item/stack/examine() @@ -176,7 +177,6 @@ if (amount <= 0) if(usr) usr.unEquip(src, 1) - src.loc = null qdel(src) return 1