From 01b6114c0160585f718ececa267effd60dc9d3f0 Mon Sep 17 00:00:00 2001 From: Meghan-Rossi <56671765+Meghan-Rossi@users.noreply.github.com> Date: Thu, 12 Mar 2020 22:32:55 +0000 Subject: [PATCH] Fix runtimes in lungs.dm Prevents lungs with null owner from causing runtimes. Lungs can have null owner if they are removed and also sometimes seem to end up with null owner during unit testing, at least downstream. This sometimes at random causes travis to fail the tests. --- code/modules/organs/internal/lungs.dm | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/code/modules/organs/internal/lungs.dm b/code/modules/organs/internal/lungs.dm index 07ef683e06..f123ea127b 100644 --- a/code/modules/organs/internal/lungs.dm +++ b/code/modules/organs/internal/lungs.dm @@ -15,28 +15,29 @@ if(is_bruised()) if(prob(4)) - spawn owner.emote("me", 1, "coughs up blood!") + spawn owner?.emote("me", 1, "coughs up blood!") owner.drip(10) if(prob(8)) - spawn owner.emote("me", 1, "gasps for air!") + spawn owner?.emote("me", 1, "gasps for air!") owner.AdjustLosebreath(15) if(owner.internal_organs_by_name[O_BRAIN]) // As the brain starts having Trouble, the lungs start malfunctioning. var/obj/item/organ/internal/brain/Brain = owner.internal_organs_by_name[O_BRAIN] if(Brain.get_control_efficiency() <= 0.8) if(prob(4 / max(0.1,Brain.get_control_efficiency()))) - spawn owner.emote("me", 1, "gasps for air!") + spawn owner?.emote("me", 1, "gasps for air!") owner.AdjustLosebreath(round(3 / max(0.1,Brain.get_control_efficiency()))) /obj/item/organ/internal/lungs/proc/rupture() - var/obj/item/organ/external/parent = owner.get_organ(parent_organ) - if(istype(parent)) - owner.custom_pain("You feel a stabbing pain in your [parent.name]!", 50) + if(owner) + var/obj/item/organ/external/parent = owner.get_organ(parent_organ) + if(istype(parent)) + owner.custom_pain("You feel a stabbing pain in your [parent.name]!", 50) bruise() /obj/item/organ/internal/lungs/handle_germ_effects() . = ..() //Up should return an infection level as an integer - if(!.) return + if(!. || !owner) return //Bacterial pneumonia if (. >= 1) @@ -54,6 +55,6 @@ ..() var/mob/living/carbon/human/H = null spawn(15) - if(ishuman(owner)) + if(owner && ishuman(owner)) H = owner color = H.species.blood_color