From a7b06341dbcf7366a1c3a19ae8b621c8e4e5f671 Mon Sep 17 00:00:00 2001 From: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Date: Sat, 8 May 2021 04:48:59 -0700 Subject: [PATCH] Fixes slightly more harddels (#58935) --- code/datums/mind.dm | 4 ++-- code/datums/wounds/_wounds.dm | 5 ++--- code/datums/wounds/slash.dm | 20 ++++++++++++++++---- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/code/datums/mind.dm b/code/datums/mind.dm index a4e6f9d53a0..8656e2ab558 100644 --- a/code/datums/mind.dm +++ b/code/datums/mind.dm @@ -96,8 +96,8 @@ /datum/mind/Destroy() SSticker.minds -= src - if(islist(antag_datums)) - QDEL_LIST(antag_datums) + QDEL_LIST(antag_datums) + QDEL_NULL(language_holder) current = null return ..() diff --git a/code/datums/wounds/_wounds.dm b/code/datums/wounds/_wounds.dm index 8e2508046d3..99f2d6081cb 100644 --- a/code/datums/wounds/_wounds.dm +++ b/code/datums/wounds/_wounds.dm @@ -80,7 +80,7 @@ /// What kind of scars this wound will create description wise once healed var/scar_keyword = "generic" - /// If we've already tried scarring while removing (since remove_wound calls qdel, and qdel calls remove wound, .....) TODO: make this cleaner + /// If we've already tried scarring while removing (remove_wound can be called twice in a del chain, let's be nice to our code yeah?) TODO: make this cleaner var/already_scarred = FALSE /// If we forced this wound through badmin smite, we won't count it towards the round totals var/from_smite @@ -91,8 +91,7 @@ /datum/wound/Destroy() if(attached_surgery) QDEL_NULL(attached_surgery) - if(limb?.wounds && (src in limb.wounds)) // destroy can call remove_wound() and remove_wound() calls qdel, so we check to make sure there's anything to remove first - remove_wound() + remove_wound() set_limb(null) victim = null return ..() diff --git a/code/datums/wounds/slash.dm b/code/datums/wounds/slash.dm index d57f6e92f29..a8ef9843aa5 100644 --- a/code/datums/wounds/slash.dm +++ b/code/datums/wounds/slash.dm @@ -35,12 +35,24 @@ if(old_wound) blood_flow = max(old_wound.blood_flow, initial_flow) if(old_wound.severity > severity && old_wound.highest_scar) - highest_scar = old_wound.highest_scar - old_wound.highest_scar = null + set_highest_scar(old_wound.highest_scar) + old_wound.clear_highest_scar() if(!highest_scar) - highest_scar = new - highest_scar.generate(limb, src, add_to_scars=FALSE) + var/datum/scar/new_scar = new + set_highest_scar(new_scar) + new_scar.generate(limb, src, add_to_scars=FALSE) + +/datum/wound/slash/proc/set_highest_scar(datum/scar/new_scar) + if(highest_scar) + UnregisterSignal(highest_scar, COMSIG_PARENT_QDELETING) + if(new_scar) + RegisterSignal(new_scar, COMSIG_PARENT_QDELETING, .proc/clear_highest_scar) + highest_scar = new_scar + +/datum/wound/slash/proc/clear_highest_scar(datum/source) + SIGNAL_HANDLER + set_highest_scar(null) /datum/wound/slash/remove_wound(ignore_limb, replaced) if(!replaced && highest_scar)