From 63aee8e1eae85ccb968f38cb4528a3ef091b279e Mon Sep 17 00:00:00 2001 From: Fira Date: Fri, 13 Oct 2023 16:48:54 +0100 Subject: [PATCH 1/3] fix: Fixes stacks/sheets building turfs not calling ChangeTurf --- code/game/objects/items/stacks/stack.dm | 30 ++++++++++++++++--------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index ac778c0569ed..3d6e55876e66 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -202,13 +202,21 @@ Also change the icon to reflect the amount of sheets, if possible.*/ if(check_one_per_turf(R,usr)) return - var/atom/O = new R.result_type(usr.loc, usr) - usr.visible_message(SPAN_NOTICE("[usr] assembles \a [O]."), - SPAN_NOTICE("You assemble \a [O].")) - O.setDir(usr.dir) + var/atom/new_item + if(ispath(R.result_type, /turf)) + var/turf/current_turf = get_turf(usr) + if(!current_turf) + return + new_item = current_turf.ChangeTurf(R.result_type) + else + new_item = new R.result_type(usr.loc, usr) + + usr.visible_message(SPAN_NOTICE("[usr] assembles \a [new_item]."), + SPAN_NOTICE("You assemble \a [new_item].")) + new_item.setDir(usr.dir) if(R.max_res_amount > 1) - var/obj/item/stack/new_item = O - new_item.amount = R.res_amount * multiplier + var/obj/item/stack/new_stack = new_item + new_stack.amount = R.res_amount * multiplier amount -= R.req_amount * multiplier update_icon() @@ -218,8 +226,8 @@ Also change the icon to reflect the amount of sheets, if possible.*/ usr.drop_inv_item_on_ground(oldsrc) qdel(oldsrc) - if(istype(O,/obj/item/stack)) //floor stacking convenience - var/obj/item/stack/S = O + if(istype(new_item,/obj/item/stack)) //floor stacking convenience + var/obj/item/stack/S = new_item for(var/obj/item/stack/F in usr.loc) if(S.stack_id == F.stack_id && S != F) var/diff = F.max_amount - F.amount @@ -231,11 +239,11 @@ Also change the icon to reflect the amount of sheets, if possible.*/ F.amount += diff break - O?.add_fingerprint(usr) + new_item?.add_fingerprint(usr) //BubbleWrap - so newly formed boxes are empty - if(isstorage(O)) - for (var/obj/item/I in O) + if(isstorage(new_item)) + for (var/obj/item/I in new_item) qdel(I) //BubbleWrap END if(src && usr.interactee == src) //do not reopen closed window From 28353952506a46dea731d444b1fbae7aeba6a336 Mon Sep 17 00:00:00 2001 From: Fira Date: Sun, 15 Oct 2023 00:02:09 +0100 Subject: [PATCH 2/3] single letter vars --- code/game/objects/items/stacks/stack.dm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index 3d6e55876e66..4e1ed8a6b836 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -227,24 +227,24 @@ Also change the icon to reflect the amount of sheets, if possible.*/ qdel(oldsrc) if(istype(new_item,/obj/item/stack)) //floor stacking convenience - var/obj/item/stack/S = new_item - for(var/obj/item/stack/F in usr.loc) - if(S.stack_id == F.stack_id && S != F) - var/diff = F.max_amount - F.amount - if (S.amount < diff) - F.amount += S.amount + var/obj/item/stack/stack_item = new_item + for(var/obj/item/stack/found_item in usr.loc) + if(stack_item.stack_id == found_item.stack_id && stack_item != found_item) + var/diff = found_item.max_amount - found_item.amount + if (stack_item.amount < diff) + found_item.amount += stack_item.amount qdel(S) else - S.amount -= diff - F.amount += diff + stack_item.amount -= diff + found_item.amount += diff break new_item?.add_fingerprint(usr) //BubbleWrap - so newly formed boxes are empty if(isstorage(new_item)) - for (var/obj/item/I in new_item) - qdel(I) + for (var/obj/item/found_item in new_item) + qdel(found_item) //BubbleWrap END if(src && usr.interactee == src) //do not reopen closed window INVOKE_ASYNC(src, PROC_REF(interact), usr) From a6d4e234c2410b68a123dc11eabf67553c8c904e Mon Sep 17 00:00:00 2001 From: Fira Date: Sun, 15 Oct 2023 00:04:39 +0100 Subject: [PATCH 3/3] PAIN --- 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 4e1ed8a6b836..d85e615bc1c8 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -233,7 +233,7 @@ Also change the icon to reflect the amount of sheets, if possible.*/ var/diff = found_item.max_amount - found_item.amount if (stack_item.amount < diff) found_item.amount += stack_item.amount - qdel(S) + qdel(stack_item) else stack_item.amount -= diff found_item.amount += diff