Skip to content

Commit

Permalink
hopefully makes it so guestbook saves to character slots
Browse files Browse the repository at this point in the history
  • Loading branch information
meemofcourse committed Feb 26, 2024
1 parent df7ed0c commit c8f23db
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
13 changes: 13 additions & 0 deletions code/controllers/subsystem/persistence.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ SUBSYSTEM_DEF(persistence)
SavePaintings()
save_custom_outfits()
SavePanicBunker()
SaveGuestBooks()

/datum/controller/subsystem/persistence/proc/GetPhotoAlbums()
var/album_path = file("data/photo_albums.json")
Expand Down Expand Up @@ -255,6 +256,18 @@ SUBSYSTEM_DEF(persistence)
fdel(json_file)
WRITE_FILE(json_file, json_encode(paintings))

/datum/controller/subsystem/persistence/proc/SaveGuestBooks()
for(var/player in GLOB.joined_player_list)
var/mob/living/carbon/human/guy = get_mob_by_ckey(player)
if(!istype(guy) || !guy.mind || !guy.mind.guestbook || !guy.client)
continue

var/mob/living/carbon/human/guy_spawned_as = guy.mind.original_character
if(!(guy == guy_spawned_as))
return
guy.client.prefs.guestbook_names = guy.mind.guestbook.known_names
guy.client.prefs.save_character()

/datum/controller/subsystem/persistence/proc/load_custom_outfits()
var/file = file("data/custom_outfits.json")
if(!fexists(file))
Expand Down
3 changes: 3 additions & 0 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ GLOBAL_LIST_EMPTY(preferences_datums)
var/prefered_security_department = SEC_DEPT_RANDOM
var/generic_adjective = "Unremarkable"

// the list of known guestbook names we have saved
var/list/guestbook_names = list()

//Quirk list
var/list/all_quirks = list()

Expand Down
6 changes: 6 additions & 0 deletions code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car

READ_FILE(S["fbp"], fbp)

// guestbook names
READ_FILE(S["guestbook_names"], guestbook_names)

//Custom names
for(var/custom_name_id in GLOB.preferences_custom_names)
var/savefile_slot_name = custom_name_id + "_name" //TODO remove this
Expand Down Expand Up @@ -520,6 +523,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
exowear = sanitize_inlist(exowear, GLOB.exowearlist, initial(exowear))
uplink_spawn_loc = sanitize_inlist(uplink_spawn_loc, GLOB.uplink_spawn_loc_list, initial(uplink_spawn_loc))
fbp = sanitize_integer(fbp, FALSE, TRUE, FALSE)
guestbook_names = SANITIZE_LIST(guestbook_names)
features["grad_style"] = sanitize_inlist(features["grad_style"], GLOB.hair_gradients_list)
features["grad_color"] = sanitize_hexcolor(features["grad_color"])
features["body_size"] = sanitize_inlist(features["body_size"], GLOB.body_sizes, "Normal")
Expand Down Expand Up @@ -633,6 +637,8 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
WRITE_FILE(S["feature_elzu_horns"] , features["elzu_horns"])
WRITE_FILE(S["feature_tail_elzu"] , features["tail_elzu"])
WRITE_FILE(S["fbp"] , fbp)
// guestbook names
WRITE_FILE(S["guestbook_names"] , guestbook_names)

//Flavor text
WRITE_FILE(S["feature_flavor_text"] , features["flavor_text"])
Expand Down
2 changes: 2 additions & 0 deletions code/modules/mob/dead/new_player/new_player.dm
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@
is_antag = TRUE

client.prefs.copy_to(H, antagonist = is_antag)
if(client.prefs.guestbook_names)
mind.guestbook.known_names += client.prefs.guestbook_names
update_names_joined_list(H.real_name)
H.dna.update_dna_identity()
if(mind)
Expand Down

0 comments on commit c8f23db

Please sign in to comment.