From 4e1c2d5154e50d97cdf32ca3793da69d840eeb35 Mon Sep 17 00:00:00 2001 From: Leland Kemble <70413276+lelandkemble@users.noreply.github.com> Date: Sun, 21 Jun 2026 16:19:17 -0400 Subject: [PATCH] Fixes runtime when creating a stack out of a stack with full hands with a stack below you (#96582) ## About The Pull Request Stack's made, eaten by other stack the second it's created, tries to initialize materials with an amount of 0, predictably runtimes. Don't bother with materials if the stack's already eaten. ## Why It's Good For The Game image ## Changelog :cl: fix: fixed a runtime when creating a stack via another stack that's then eaten by another stack when it's created /:cl: --- code/game/objects/items/stacks/stack.dm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index 8d617c29117..a7b365b3e29 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -475,12 +475,13 @@ if(isstack(created)) var/obj/item/stack/crafted_stack = created - if(recipe.res_amount > 0 && recipe.req_amount != recipe.res_amount) - var/scale = recipe.req_amount / recipe.res_amount - for(var/mat in result_mats) - result_mats[mat] *= scale - crafted_stack.mats_per_unit = SSmaterials.get_material_set_cache(result_mats) - crafted_stack.update_custom_materials() + if(crafted_stack.amount) // If our stack's been emptied, it means another stack's already eaten it, and that stack'll deal with materials + if(recipe.res_amount > 0 && recipe.req_amount != recipe.res_amount) + var/scale = recipe.req_amount / recipe.res_amount + for(var/mat in result_mats) + result_mats[mat] *= scale + crafted_stack.mats_per_unit = SSmaterials.get_material_set_cache(result_mats) + crafted_stack.update_custom_materials() else created.set_custom_materials(result_mats, recipe.req_amount * multiplier)