Skip to content

Commit

Permalink
code_imp: Set key wrapper (#6492)
Browse files Browse the repository at this point in the history
* 1

* comsig mob login

* fix
  • Loading branch information
Antoonij authored Feb 1, 2025
1 parent 0e1e29e commit 77e43eb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
6 changes: 3 additions & 3 deletions code/datums/components/pref_holder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
src.preferences = preferences || forge_preferences()

/datum/component/pref_holder/RegisterWithParent()
RegisterSignal(parent, COMSIG_BODY_TRANSFER_TO, PROC_REF(on_mind_transfer))
RegisterSignal(parent, COMSIG_MOB_LOGIN, PROC_REF(handle_transfer))

/datum/component/pref_holder/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_BODY_TRANSFER_TO)
UnregisterSignal(parent, COMSIG_MOB_LOGIN)

/datum/component/pref_holder/proc/on_mind_transfer(mob/source)
/datum/component/pref_holder/proc/handle_transfer(mob/source)
SIGNAL_HANDLER

preferences = forge_preferences()
Expand Down
18 changes: 9 additions & 9 deletions code/datums/mind.dm
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,22 @@
if(!istype(new_character))
stack_trace("transfer_to(): Some idiot has tried to transfer_to() a non mob/living mob.")

var/datum/atom_hud/antag/hud_to_transfer = antag_hud //we need this because leave_hud() will clear this list
var/datum/atom_hud/antag/hud_to_transfer = antag_hud // we need this because leave_hud() will clear this list
var/mob/living/old_current = current

if(current) //remove ourself from our old body's mind variable
if(current) // remove ourself from our old body's mind variable
current.mind = null
leave_all_huds() //leave all the huds in the old body, so it won't get huds if somebody else enters it
leave_all_huds() // leave all the huds in the old body, so it won't get huds if somebody else enters it

SStgui.on_transfer(current, new_character)

if(new_character.mind) //remove any mind currently in our new body's mind variable
if(new_character.mind) // remove any mind currently in our new body's mind variable
new_character.mind.current = null

current = new_character //link ourself to our new body
new_character.mind = src //and link our new body to ourself
current = new_character // link ourself to our new body
new_character.mind = src // and link our new body to ourself

transfer_antag_huds(hud_to_transfer) //inherit the antag HUD
transfer_antag_huds(hud_to_transfer) // inherit the antag HUD
transfer_actions(new_character, old_current)

if(martial_art)
Expand All @@ -177,11 +177,11 @@
if(!MA.temporary)
MA.teach(current)

for(var/datum/antagonist/antag in antag_datums) //Makes sure all antag datums effects are applied in the new body
for(var/datum/antagonist/antag in antag_datums) // Makes sure all antag datums effects are applied in the new body
antag.on_body_transfer(old_current, current)

if(active)
new_character.key = key //now transfer the key to link the client to our new body
new_character.set_key(key) // now transfer the key to link the client to our new body

// essential mob updates
new_character.update_blind_effects()
Expand Down
3 changes: 2 additions & 1 deletion code/modules/mob/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1219,4 +1219,5 @@ GLOBAL_LIST_INIT(holy_areas, typecacheof(list(
add_misc_logs(src, "Z-TRACKING: [src] of type [src.type] has a Z-registration despite not having a client.")
update_z(null)


/mob/proc/set_key(key)
src.key = key
15 changes: 9 additions & 6 deletions code/modules/mob/new_player/new_player.dm
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@
popup.open(0) // 0 is passed to open so that it doesn't use the onclose() proc

/mob/new_player/proc/create_character()
spawning = 1
spawning = TRUE
close_spawn_windows()

check_prefs_are_sane()
Expand All @@ -627,19 +627,22 @@


if(mind)
mind.active = 0 //we wish to transfer the key manually
if(mind.assigned_role == JOB_TITLE_CLOWN) //give them a clownname if they are a clown
new_character.real_name = pick(GLOB.clown_names) //I hate this being here of all places but unfortunately dna is based on real_name!
mind.active = FALSE // we wish to transfer the key manually

if(mind.assigned_role == JOB_TITLE_CLOWN) // give them a clownname if they are a clown
new_character.real_name = pick(GLOB.clown_names) // I hate this being here of all places but unfortunately dna is based on real_name!
new_character.rename_self(JOB_TITLE_CLOWN)

else if(mind.assigned_role == JOB_TITLE_MIME)
new_character.real_name = pick(GLOB.mime_names)
new_character.rename_self(JOB_TITLE_MIME)

mind.set_original_mob(new_character)
mind.transfer_to(new_character) //won't transfer key since the mind is not active
mind.transfer_to(new_character) // won't transfer key since the mind is not active
GLOB.human_names_list += new_character.real_name


new_character.key = key // Manually transfer the key to log them in
new_character.set_key(key) // Manually transfer the key to log them in

return new_character

Expand Down

0 comments on commit 77e43eb

Please sign in to comment.