mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
[MIRROR] Fixes savefile corruption bug and allows character swapping (#11406)
Co-authored-by: Cameron Lennox <killer65311@gmail.com>
This commit is contained in:
committed by
GitHub
parent
c58ead6223
commit
4d3de029e3
@@ -319,6 +319,7 @@ var/const/preview_icons = 'icons/mob/human_races/preview.dmi'
|
||||
|
||||
data["b_type"] = pref.b_type
|
||||
data["digitigrade"] = pref.digitigrade
|
||||
data["tail_layering"] = pref.read_preference(/datum/preference/choiced/human/tail_layering)
|
||||
|
||||
data["synth_color_toggle"] = pref.synth_color
|
||||
data["synth_color"] = pref.read_preference(/datum/preference/color/human/synth_color)
|
||||
@@ -996,6 +997,13 @@ var/const/preview_icons = 'icons/mob/human_races/preview.dmi'
|
||||
pref.digitigrade = !pref.digitigrade
|
||||
return TOPIC_REFRESH_UPDATE_PREVIEW
|
||||
|
||||
if("set_tail_layering")
|
||||
var/new_tail_layering = tgui_input_list(user, "Select a tail layer.", "Set Tail Layer", GLOB.tail_layer_options,
|
||||
pref.read_preference(/datum/preference/choiced/human/tail_layering))
|
||||
if(new_tail_layering)
|
||||
pref.update_preference_by_type(/datum/preference/choiced/human/tail_layering, new_tail_layering)
|
||||
return TOPIC_REFRESH_UPDATE_PREVIEW
|
||||
|
||||
if("synth_color_toggle")
|
||||
pref.synth_color = !pref.synth_color
|
||||
return TOPIC_REFRESH_UPDATE_PREVIEW
|
||||
|
||||
@@ -318,10 +318,17 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
|
||||
|
||||
/// Write a /datum/preference type and return its value directly to the json.
|
||||
/// Please use SScharacter_setup.queue_preferences_save(prefs) when you edit multiple at once and set direct_write to WRITE_PREF_MANUAL
|
||||
/mob/proc/write_preference_directly(preference_type, preference_value, write_mode = WRITE_PREF_INSTANT)
|
||||
/// Additionally, if you want something to be changed IN ROUND and change a pref for THAT CHARACTER'S SAVESLOT, ensure save_to_played_slot = TRUE!
|
||||
/mob/proc/write_preference_directly(preference_type, preference_value, write_mode = WRITE_PREF_INSTANT, save_to_played_slot)
|
||||
var/remembered_default
|
||||
if(save_to_played_slot && (mind.loaded_from_slot != client?.prefs?.default_slot))
|
||||
remembered_default = client?.prefs?.default_slot
|
||||
client?.prefs?.load_character(mind.loaded_from_slot)
|
||||
var/success = client?.prefs?.write_preference_by_type(preference_type, preference_value, write_mode)
|
||||
if(success)
|
||||
client?.prefs?.value_cache[preference_type] = preference_value
|
||||
if(remembered_default)
|
||||
client?.prefs?.return_to_character_slot(src, remembered_default)
|
||||
return success
|
||||
|
||||
/// Set a /datum/preference entry.
|
||||
|
||||
@@ -136,9 +136,6 @@
|
||||
switch(action)
|
||||
// Basic actions
|
||||
if("load")
|
||||
if(!isnewplayer(ui.user))
|
||||
to_chat(ui.user, span_userdanger("You can't change your character slot while being in round."))
|
||||
return FALSE
|
||||
if(!IsGuestKey(ui.user.key))
|
||||
open_load_dialog(ui.user)
|
||||
. = TRUE
|
||||
|
||||
@@ -76,6 +76,14 @@ var/global/client_record_update_lock = FALSE
|
||||
playsound(COM, 'sound/machines/deniedbeep.ogg', 50, 0)
|
||||
return "Update syncronization failed (OOC: Record's owner is offline)"
|
||||
|
||||
var/datum/preferences/P = C.prefs
|
||||
if(P.default_slot != M.mind.loaded_from_slot)
|
||||
if(COM && !QDELETED(COM))
|
||||
COM.visible_message(span_notice("\The [COM] buzzes!"))
|
||||
playsound(COM, 'sound/machines/deniedbeep.ogg', 50, 0)
|
||||
to_chat(M, span_warning("[user] attempted to update your [record_string] record, but your current character slot does not match your played slot. Please ensure your currently played character is selected in your Character Setup."))
|
||||
return "Update syncronization failed (OOC: Player's current character slot does not match their played slot. They have been informed.)"
|
||||
|
||||
var/choice = tgui_alert(M, "Your [record_string] record has been updated from the a records console by [user]. Please review the changes made to your [record_string] record. Accepting these changes will SAVE your CURRENT character slot! If your new [record_string] record has errors, it is recomended to have it corrected IC instead of editing it yourself.", "Record Updated", list("Review Changes","DENY"))
|
||||
if(!choice || choice == "DENY")
|
||||
message_admins("[active.fields["name"]] refused [record_string] record update from [user] without review.")
|
||||
@@ -84,7 +92,6 @@ var/global/client_record_update_lock = FALSE
|
||||
playsound(COM, 'sound/machines/deniedbeep.ogg', 50, 0)
|
||||
return "Update syncronization failed (OOC: Player refused without review)"
|
||||
|
||||
var/datum/preferences/P = C.prefs
|
||||
var/new_data = strip_html_simple(tgui_input_text(M,"Please review [user]'s changes to your [record_string] record before confirming. Confirming will SAVE your CURRENT character slot! If your new [record_string] record major errors, it is recomended to have it corrected IC instead of editing it yourself.","Character Preference", html_decode(active.fields["notes"]), MAX_RECORD_LENGTH, TRUE, prevent_enter = TRUE), MAX_RECORD_LENGTH)
|
||||
if(!new_data)
|
||||
message_admins("[active.fields["name"]] refused [record_string] record update from [user] with review.")
|
||||
|
||||
Reference in New Issue
Block a user