From d7e8928f0d9a2e713fccbaa2bf16ff2ee0723f70 Mon Sep 17 00:00:00 2001 From: Bloop <13398309+vinylspiders@users.noreply.github.com> Date: Tue, 10 Oct 2023 14:45:00 -0400 Subject: [PATCH] Fixes a runtime in obj/item/organ/on_death() (#78882) ## About The Pull Request Fixes the following runtime caught by CI. ![firefox_BCIl7d348X](https://github.com/tgstation/tgstation/assets/13398309/8ee2a657-7d25-4793-a5e5-d1e489107188) `owner` can be null so we have to check for it just like we do before calling `on_life()`. https://github.com/tgstation/tgstation/blob/e5385508107f043fb8f646abfd7686509b239cb6/code/modules/mob/living/carbon/life.dm#L472-L473 ## Why It's Good For The Game Less runtimes ## Changelog :cl: fix: fixes a runtime in organ on_death() /:cl: --- code/modules/mob/living/carbon/life.dm | 3 ++- .../surgery/organs/internal/cyberimp/augments_chest.dm | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/code/modules/mob/living/carbon/life.dm b/code/modules/mob/living/carbon/life.dm index 355f5bf61ca..78aee97effa 100644 --- a/code/modules/mob/living/carbon/life.dm +++ b/code/modules/mob/living/carbon/life.dm @@ -458,7 +458,8 @@ return for(var/obj/item/organ/internal/organ in organs) // On-death is where organ decay is handled - organ?.on_death(seconds_per_tick, times_fired) // organ can be null due to reagent metabolization causing organ shuffling + if(organ?.owner) // organ + owner can be null due to reagent metabolization causing organ shuffling + organ.on_death(seconds_per_tick, times_fired) // We need to re-check the stat every organ, as one of our others may have revived us if(stat != DEAD) break diff --git a/code/modules/surgery/organs/internal/cyberimp/augments_chest.dm b/code/modules/surgery/organs/internal/cyberimp/augments_chest.dm index 24a3afe47f1..1ea3a1bf9c4 100644 --- a/code/modules/surgery/organs/internal/cyberimp/augments_chest.dm +++ b/code/modules/surgery/organs/internal/cyberimp/augments_chest.dm @@ -57,7 +57,9 @@ COOLDOWN_DECLARE(reviver_cooldown) /obj/item/organ/internal/cyberimp/chest/reviver/on_death(seconds_per_tick, times_fired) - try_heal() // Allowes implant to work even on dead people + if(isnull(owner)) // owner can be null, on_death() gets called by /obj/item/organ/internal/process() for decay + return + try_heal() // Allows implant to work even on dead people /obj/item/organ/internal/cyberimp/chest/reviver/on_life(seconds_per_tick, times_fired) try_heal() @@ -89,7 +91,7 @@ // this check goes after revive_dead() to delay revival a bit if(owner.stat == DEAD) can_defib_owner = owner.can_defib() - if(can_defib_owner == DEFIB_POSSIBLE) + if(can_defib_owner == DEFIB_POSSIBLE) owner.notify_ghost_cloning("You are being revived by [src]!") owner.grab_ghost() /// boolean that stands for if PHYSICAL damage being patched @@ -114,7 +116,7 @@ if(body_damage_patched && prob(35)) // healing is called every few seconds, not every tick owner.visible_message(span_warning("[owner]'s body twitches a bit."), span_notice("You feel like something is patching your injured body.")) - + /obj/item/organ/internal/cyberimp/chest/reviver/proc/revive_dead() owner.grab_ghost()