Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] Makes mutations clean up after themselves #1016

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading