diff --git a/code/datums/mind.dm b/code/datums/mind.dm index d11ab68f21b..7a96a1ed48d 100644 --- a/code/datums/mind.dm +++ b/code/datums/mind.dm @@ -65,10 +65,19 @@ //put this here for easier tracking ingame var/datum/money_account/initial_account + /datum/mind/New(var/key) src.key = key ..() +/datum/mind/proc/handle_mob_deletion(mob/living/deleted_mob) + if (current == deleted_mob) + current.spellremove() + current = null + + if (original == deleted_mob) + original = null + /datum/mind/proc/transfer_to(mob/living/new_character) if(!istype(new_character)) world.log << "## DEBUG: transfer_to(): Some idiot has tried to transfer_to() a non mob/living mob. Please inform Carn" diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 3aa6865b7bc..f514caa4c64 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -11,8 +11,8 @@ for(var/atom/movable/AM in client.screen) qdel(AM) client.screen = list() - if(mind && mind.current == src) - spellremove(src) + if (mind) + mind.handle_mob_deletion(src) for(var/infection in viruses) qdel(infection) viruses.Cut()