From 745e59b941a918cfb75bdfb7fe4e9a3dc830b09a Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Fri, 15 Dec 2023 03:57:01 +0100 Subject: [PATCH] [MIRROR] [NO GBP] Fixes a mistake with mutation cleanup [MDB IGNORE] (#25615) * [NO GBP] Fixes a mistake with mutation cleanup (#80242) ## About The Pull Request Fixes https://github.com/tgstation/tgstation/issues/80199 `on_lose()` tends to call the parent first, where the `qdel(src)` was happening. The issue with that: it returns from the parent call, and now due to being qdeled the `owner` is set to `null`. Certain mutations try to access owner to do various things post-removal, cue the runtimes... --- I just moved the mutation qdeletion out of the proc and into `force_lose()` instead. There are only two other places where `on_lose()` gets called, one of which is for unstable mutations and it already immediately qdels the mutation afterwards. The other is when hulks get put into crit. I added a qdel to the latter. This should ensure that mutations always get deleted after removal (but without breaking anything this time). Also renamed some abbreviated vars. Fixes https://github.com/Skyrat-SS13/Skyrat-tg/issues/25543 ## Why It's Good For The Game Fixes a bug that I accidentally introduced. ## Changelog :cl: fix: fixes a bug which was causing certain mutations to only get partially removed /:cl: * [NO GBP] Fixes a mistake with mutation cleanup --------- Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> Co-authored-by: SomeRandomOwl <2568378+SomeRandomOwl@users.noreply.github.com> --- code/datums/dna.dm | 21 +++++++++++---------- code/datums/mutations/_mutations.dm | 1 - code/datums/mutations/hulk.dm | 1 + 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/code/datums/dna.dm b/code/datums/dna.dm index 6b53310261a..3651735ddfd 100644 --- a/code/datums/dna.dm +++ b/code/datums/dna.dm @@ -415,20 +415,21 @@ GLOBAL_LIST_INIT(total_uf_len_by_block, populate_total_uf_len_by_block()) //SKYRAT EDIT REMOVAL END //Please use add_mutation or activate_mutation instead -/datum/dna/proc/force_give(datum/mutation/human/HM) - if(holder && HM) - if(HM.class == MUT_NORMAL) - set_se(1, HM) - . = HM.on_acquiring(holder) +/datum/dna/proc/force_give(datum/mutation/human/human_mutation) + if(holder && human_mutation) + if(human_mutation.class == MUT_NORMAL) + set_se(1, human_mutation) + . = human_mutation.on_acquiring(holder) if(.) - qdel(HM) + qdel(human_mutation) update_instability() //Use remove_mutation instead -/datum/dna/proc/force_lose(datum/mutation/human/HM) - if(holder && (HM in mutations)) - set_se(0, HM) - . = HM.on_losing(holder) +/datum/dna/proc/force_lose(datum/mutation/human/human_mutation) + if(holder && (human_mutation in mutations)) + set_se(0, human_mutation) + . = human_mutation.on_losing(holder) + qdel(human_mutation) // qdel mutations on removal update_instability(FALSE) return diff --git a/code/datums/mutations/_mutations.dm b/code/datums/mutations/_mutations.dm index bb9b37fd03e..cc99917c746 100644 --- a/code/datums/mutations/_mutations.dm +++ b/code/datums/mutations/_mutations.dm @@ -147,7 +147,6 @@ mut_overlay.Remove(get_visual_indicator()) owner.overlays_standing[layer_used] = mut_overlay owner.apply_overlay(layer_used) - qdel(src) /mob/living/carbon/proc/update_mutations_overlay() return diff --git a/code/datums/mutations/hulk.dm b/code/datums/mutations/hulk.dm index 1049e5660af..a76adac10ac 100644 --- a/code/datums/mutations/hulk.dm +++ b/code/datums/mutations/hulk.dm @@ -82,6 +82,7 @@ if(owner.health < owner.crit_threshold) on_losing(owner) to_chat(owner, span_danger("You suddenly feel very weak.")) + qdel(src) /datum/mutation/human/hulk/on_losing(mob/living/carbon/human/owner) if(..())