diff --git a/code/datums/mind.dm b/code/datums/mind.dm index a438d8e557a..ee22a686fc5 100644 --- a/code/datums/mind.dm +++ b/code/datums/mind.dm @@ -135,8 +135,11 @@ RegisterSignal(current, COMSIG_PARENT_QDELETING, PROC_REF(archive_deleted_body), override = TRUE) /datum/mind/proc/unbind() + if(isnull(current)) + return UnregisterSignal(current, COMSIG_PARENT_QDELETING) - current.mind = null + if(current.mind == src) + current.mind = null current = null /datum/mind/proc/transfer_to(mob/living/new_character) diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index c62633d9986..d344cde1ab7 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -18,9 +18,13 @@ return INITIALIZE_HINT_NORMAL /mob/new_player/Destroy() + if(spawning) + // The mind is being reused elsewhere, so just unhook it here. + mind = null if(mind) // Minds really shouldn't bind to new players, but just in case... mind.unbind() + qdel(mind) return ..() /mob/new_player/proc/new_player_panel() @@ -552,21 +556,16 @@ H.flavor_text = "" stop_sound_channel(CHANNEL_LOBBYMUSIC) + mind.set_original_mob(new_character) + mind.transfer_to(new_character) - if(mind) - mind.active = FALSE //we wish to transfer the key manually - // Clowns and mimes get appropriate default names, and the chance to pick a custom one. - if(mind.assigned_role == "Clown") - new_character.rename_character(new_character.real_name, pick(GLOB.clown_names)) - new_character.rename_self("clown") - else if(mind.assigned_role == "Mime") - new_character.rename_character(new_character.real_name, pick(GLOB.mime_names)) - new_character.rename_self("mime") - mind.set_original_mob(new_character) - mind.transfer_to(new_character) //won't transfer key since the mind is not active - - - new_character.key = key //Manually transfer the key to log them in + // Clowns and mimes get appropriate default names, and the chance to pick a custom one. + if(mind.assigned_role == "Clown") + new_character.rename_character(new_character.real_name, pick(GLOB.clown_names)) + new_character.rename_self("clown") + else if(mind.assigned_role == "Mime") + new_character.rename_character(new_character.real_name, pick(GLOB.mime_names)) + new_character.rename_self("mime") return new_character diff --git a/code/modules/mob/new_player/new_player_login.dm b/code/modules/mob/new_player/new_player_login.dm index 036618d9751..d6f800afd7f 100644 --- a/code/modules/mob/new_player/new_player_login.dm +++ b/code/modules/mob/new_player/new_player_login.dm @@ -3,6 +3,10 @@ if(GLOB.join_motd) to_chat(src, "
[GLOB.join_motd]
") + if(!mind) + mind = new /datum/mind(key) + mind.active = TRUE + if(length(GLOB.newplayer_start)) loc = pick(GLOB.newplayer_start) else