Skip to content

Commit

Permalink
Merge pull request Citadel-Station-13#16017 from SandPoot/silicons-fl…
Browse files Browse the repository at this point in the history
…avor-text-loading

Silicon flavor text loading (for real now)
  • Loading branch information
Linzolle authored Oct 16, 2023
2 parents c4c57d3 + 297ee64 commit b132498
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@
#define COMSIG_MOB_CLIENT_MOVE "mob_client_move" //sent when client/Move() finishes with no early returns: (client, direction, n, oldloc)
#define COMSIG_MOB_CLIENT_CHANGE_VIEW "mob_client_change_view" //from base of /client/change_view(): (client, old_view, view)
#define COMSIG_MOB_CLIENT_MOUSEMOVE "mob_client_mousemove" //from base of /client/MouseMove(): (object, location, control, params)
#define COMSIG_MOB_CLIENT_JOINED_FROM_LOBBY "mob_client_joined_from_lobby" //sent when a player joins/latejoins the game: (new_character, client, late_transfer)

///sent when a mob/login() finishes: (client)
#define COMSIG_MOB_CLIENT_LOGIN "comsig_mob_client_login"
Expand Down
23 changes: 21 additions & 2 deletions code/datums/elements/flavor_text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,17 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code
LAZYOR(GLOB.mobs_with_editable_flavor_text[M], src)
add_verb(M, /mob/proc/manage_flavor_tests)

if(save_key && ishuman(target))
if(!save_key)
return
if(ishuman(target))
RegisterSignal(target, COMSIG_HUMAN_PREFS_COPIED_TO, .proc/update_prefs_flavor_text)
else if(iscyborg(target))
RegisterSignal(target, COMSIG_MOB_ON_NEW_MIND, .proc/borged_update_flavor_text)
RegisterSignal(target, COMSIG_MOB_CLIENT_JOINED_FROM_LOBBY, .proc/borged_update_flavor_text)

/datum/element/flavor_text/Detach(atom/A)
. = ..()
UnregisterSignal(A, list(COMSIG_PARENT_EXAMINE, COMSIG_HUMAN_PREFS_COPIED_TO))
UnregisterSignal(A, list(COMSIG_PARENT_EXAMINE, COMSIG_HUMAN_PREFS_COPIED_TO, COMSIG_MOB_ON_NEW_MIND, COMSIG_MOB_CLIENT_JOINED_FROM_LOBBY))
texts_by_atom -= A
if(can_edit && ismob(A))
var/mob/M = A
Expand Down Expand Up @@ -149,6 +154,20 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code
if(P.features.Find(save_key))
texts_by_atom[H] = P.features[save_key]

/datum/element/flavor_text/proc/borged_update_flavor_text(mob/new_character, client/C)
C = C || GET_CLIENT(new_character)
if(!C)
LAZYREMOVE(texts_by_atom, new_character)
return
var/datum/preferences/P = C.prefs
if(!P)
LAZYREMOVE(texts_by_atom, new_character)
return
if(P.custom_names["cyborg"] == new_character.real_name)
LAZYSET(texts_by_atom, new_character, P.features[save_key])
else
LAZYREMOVE(texts_by_atom, new_character)

//subtypes with additional hooks for DNA and preferences.
/datum/element/flavor_text/carbon
//list of antagonists etcetera that should have nothing to do with people's snowflakes.
Expand Down
5 changes: 3 additions & 2 deletions code/modules/mob/dead/new_player/new_player.dm
Original file line number Diff line number Diff line change
Expand Up @@ -702,13 +702,14 @@
. = H
new_character = .
if(transfer_after)
transfer_character()
transfer_character(TRUE)

/mob/dead/new_player/proc/transfer_character()
/mob/dead/new_player/proc/transfer_character(late_transfer = FALSE)
. = new_character
if(.)
new_character.key = key //Manually transfer the key to log them in
new_character.stop_sound_channel(CHANNEL_LOBBYMUSIC)
SEND_SIGNAL(new_character, COMSIG_MOB_CLIENT_JOINED_FROM_LOBBY, new_character?.client, late_transfer)
new_character = null
qdel(src)

Expand Down

0 comments on commit b132498

Please sign in to comment.