Skip to content

Commit

Permalink
[MIRROR] Makes mutations clean up after themselves [MDB IGNORE] (#1016)
Browse files Browse the repository at this point in the history
* Makes mutations clean up after themselves (#80107)

---------

Co-authored-by: SkyratBot <[email protected]>
Co-authored-by: Bloop <[email protected]>
  • Loading branch information
3 people authored Dec 7, 2023
1 parent 4f576bf commit 2cc7ffd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions code/datums/dna.dm
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ GLOBAL_LIST_INIT(total_uf_len_by_block, populate_total_uf_len_by_block())
/datum/dna/Destroy()
if(iscarbon(holder))
var/mob/living/carbon/cholder = holder
remove_all_mutations() // mutations hold a reference to the dna
if(cholder.dna == src)
cholder.dna = null
holder = null
Expand Down
12 changes: 7 additions & 5 deletions code/datums/mutations/_mutations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@
copy_mutation(copymut)
update_valid_chromosome_list()

/datum/mutation/human/Destroy()
power_path = null
dna = null
owner = null
return ..()

/datum/mutation/human/proc/on_acquiring(mob/living/carbon/human/acquirer)
if(!acquirer || !istype(acquirer) || acquirer.stat == DEAD || (src in acquirer.dna.mutations))
return TRUE
Expand Down Expand Up @@ -141,11 +147,7 @@
mut_overlay.Remove(get_visual_indicator())
owner.overlays_standing[layer_used] = mut_overlay
owner.apply_overlay(layer_used)
if(power_path)
// Any powers we made are linked to our mutation datum,
// so deleting ourself will also delete it and remove it
// ...Why don't all mutations delete on loss? Not sure.
qdel(src)
qdel(src)

/mob/living/carbon/proc/update_mutations_overlay()
return
Expand Down
2 changes: 1 addition & 1 deletion code/datums/mutations/body.dm
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
. = owner.monkeyize()

/datum/mutation/human/race/on_losing(mob/living/carbon/human/owner)
if(owner && owner.stat != DEAD && (owner.dna.mutations.Remove(src)) && ismonkey(owner))
if(!QDELETED(owner) && owner.stat != DEAD && (owner.dna.mutations.Remove(src)) && ismonkey(owner))
owner.fully_replace_character_name(null, original_name)
. = owner.humanize(original_species)

Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/dna_injector.dm
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@
if(mutation == /datum/mutation/human/race)
if(!ismonkey(target))
continue
target = target.dna.remove_mutation(mutation)
target.dna.remove_mutation(mutation)
else
target.dna.remove_mutation(mutation)
for(var/mutation in add_mutations)
if(target.dna.get_mutation(mutation))
continue //Skip permanent mutations we already have.
if(mutation == /datum/mutation/human/race && !ismonkey(target))
message_admins("[ADMIN_LOOKUPFLW(user)] injected [key_name_admin(target)] with the [name] [span_danger("(MONKEY)")]")
target = target.dna.add_mutation(mutation, MUT_OTHER, endtime)
target.dna.add_mutation(mutation, MUT_OTHER, endtime)
else
target.dna.add_mutation(mutation, MUT_OTHER, endtime)
if(fields)
Expand Down

0 comments on commit 2cc7ffd

Please sign in to comment.