From b47f22ffb968d4aa6e74ecd8d50352a1072e5d5a Mon Sep 17 00:00:00 2001 From: Contrabang <91113370+Contrabang@users.noreply.github.com> Date: Sat, 22 Apr 2023 03:43:51 -0400 Subject: [PATCH] Fixes a runtime with cyborg stacks being initialized with no power source (#20848) * begone runtime * refactor --- code/game/objects/items/stacks/stack.dm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index 9dc6758cecf..1d4861b5c28 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -298,9 +298,12 @@ return TRUE /obj/item/stack/proc/get_amount() - if(is_cyborg) - return round(source.energy / cost) - return amount + if(!is_cyborg) + return amount + + if(!source) // The energy source has not yet been initializied + return 0 + return round(source.energy / cost) /obj/item/stack/proc/get_max_amount() return max_amount