From c26a19d52366d202a9ce313f2cc0c36837e9bcb9 Mon Sep 17 00:00:00 2001 From: YPOQ <30683121+YPOQ@users.noreply.github.com> Date: Wed, 9 May 2018 17:37:03 -0600 Subject: [PATCH] Removes recursion --- code/game/objects/items/stacks/stack.dm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index 86d3b16fbed..83cb82cb814 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -33,14 +33,13 @@ return return TRUE -/obj/item/stack/Initialize(mapload, new_amount=null , merge = TRUE) +/obj/item/stack/Initialize(mapload, new_amount, merge = TRUE) . = ..() if(new_amount) - if(new_amount > max_amount) - amount = max_amount - new type(loc, new_amount - max_amount, merge) - else - amount = new_amount + amount = new_amount + while(amount > max_amount) + amount -= max_amount + new type(loc, max_amount, FALSE) if(!merge_type) merge_type = type if(merge)