From 61169e265206b277b4c8417c100e9ef97a0ce4ca Mon Sep 17 00:00:00 2001 From: Iajret Creature <122297233+Steals-The-PRs@users.noreply.github.com> Date: Mon, 27 Nov 2023 12:19:02 +0300 Subject: [PATCH] [MIRROR] Fixes race condition in Life() [MDB IGNORE] (#844) * Fixes race condition in Life() (#79934) --------- Co-authored-by: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> Co-authored-by: MrMelbert <51863163+MrMelbert@ users.noreply.github.com> --- code/modules/mob/living/carbon/life.dm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/modules/mob/living/carbon/life.dm b/code/modules/mob/living/carbon/life.dm index 182eba52b71..84d125c89c3 100644 --- a/code/modules/mob/living/carbon/life.dm +++ b/code/modules/mob/living/carbon/life.dm @@ -15,7 +15,7 @@ if(HAS_TRAIT(src, TRAIT_STASIS)) . = ..() - reagents.handle_stasis_chems(src, seconds_per_tick, times_fired) + reagents?.handle_stasis_chems(src, seconds_per_tick, times_fired) else //Reagent processing needs to come before breathing, to prevent edge cases. handle_dead_metabolization(seconds_per_tick, times_fired) //Dead metabolization first since it can modify life metabolization. @@ -488,7 +488,7 @@ /mob/living/carbon/proc/handle_organs(seconds_per_tick, times_fired) if(stat == DEAD) - if(reagents.has_reagent(/datum/reagent/toxin/formaldehyde, 1) || reagents.has_reagent(/datum/reagent/cryostylane)) // No organ decay if the body contains formaldehyde. + if(reagents && (reagents.has_reagent(/datum/reagent/toxin/formaldehyde, 1) || reagents.has_reagent(/datum/reagent/cryostylane))) // No organ decay if the body contains formaldehyde. return for(var/obj/item/organ/internal/organ in organs) // On-death is where organ decay is handled @@ -569,9 +569,9 @@ * - times_fired: The number of times SSmobs has ticked. */ /mob/living/carbon/proc/handle_dead_metabolization(seconds_per_tick, times_fired) - if (stat != DEAD) + if(stat != DEAD) return - reagents.metabolize(src, seconds_per_tick, times_fired, can_overdose = TRUE, liverless = TRUE, dead = TRUE) // Your liver doesn't work while you're dead. + reagents?.metabolize(src, seconds_per_tick, times_fired, can_overdose = TRUE, liverless = TRUE, dead = TRUE) // Your liver doesn't work while you're dead. /// Base carbon environment handler, adds natural stabilization /mob/living/carbon/handle_environment(datum/gas_mixture/environment, seconds_per_tick, times_fired)