Preference updating

This commit is contained in:
Waterpig
2025-03-05 13:23:05 +01:00
parent 7600837c59
commit cbdd4fcf83
@@ -3,7 +3,7 @@
* You can't really use the non-modular version, least you eventually want asinine merge
* conflicts and/or potentially disastrous issues to arise, so here's your own.
*/
#define MODULAR_SAVEFILE_VERSION_MAX 7
#define MODULAR_SAVEFILE_VERSION_MAX 8
#define MODULAR_SAVEFILE_UP_TO_DATE -1
@@ -14,6 +14,7 @@
#define VERSION_CHRONOLOGICAL_AGE 5
#define VERSION_LANGUAGES 6
#define VERSION_LOADOUT_PRESETS 7
#define VERSION_INTERNAL_EXTERNAL_ORGANS 8
#define INDEX_UNDERWEAR 1
#define INDEX_BRA 2
@@ -36,18 +37,7 @@
if(!save_data)
save_data = list()
var/list/save_augments = SANITIZE_LIST(save_data["augments"])
for(var/aug_slot in save_augments)
var/aug_entry = save_augments[aug_slot]
save_augments -= aug_slot
if(istext(aug_entry))
aug_entry = _text2path(aug_entry)
var/datum/augment_item/aug = GLOB.augment_items[aug_entry]
if(aug)
save_augments[aug_slot] = aug_entry
augments = save_augments
load_augments(SANITIZE_LIST(save_data["augments"]))
augment_limb_styles = SANITIZE_LIST(save_data["augment_limb_styles"])
for(var/key in augment_limb_styles)
@@ -264,6 +254,17 @@
if(current_version < VERSION_LOADOUT_PRESETS)
write_preference(GLOB.preference_entries[/datum/preference/loadout], list("Default" = save_data["loadout_list"])) // So easy. I wish the synth refactor was this easy.
if(current_version < VERSION_INTERNAL_EXTERNAL_ORGANS)
var/list/save_augments = SANITIZE_LIST(save_data["augments"])
var/prefix_length = length("/obj/item/organ/internal") // Shouldn't be any external augments, but if there are, it's the same length
for(var/augment_name in save_augments)
var/augment_path_string = save_augments[augment_name]
if(!(findtext(augment_path_string, "/obj/item/organ/internal") || findtext(augment_path_string, "/obj/item/organ/external")))
continue // Make sure we don't strip something that isn't there
var/augment_path_string_stripped = copytext(save_augments[augment_name], prefix_length + 1)
save_augments[augment_name] = "/obj/item/organ[augment_path_string_stripped]"
load_augments(save_augments)
to_chat(parent, custom_boxed_message("green_box", span_greentext("Updated preferences!")))
/datum/preferences/proc/check_migration()
@@ -324,6 +325,18 @@
markings[marking][title] = list(sanitize_hexcolor(markings[marking][title]), FALSE)
return markings
/datum/preferences/proc/load_augments(list/augments_prefs)
var/list/augments_sanitized = list()
for(var/aug_slot in augments_prefs)
var/aug_entry = augments_prefs[aug_slot]
if(istext(aug_entry))
aug_entry = _text2path(aug_entry)
var/datum/augment_item/aug = GLOB.augment_items[aug_entry]
if(aug)
augments_sanitized[aug_slot] = aug_entry
augments = augments_sanitized
#undef MODULAR_SAVEFILE_VERSION_MAX
#undef MODULAR_SAVEFILE_UP_TO_DATE
@@ -335,3 +348,4 @@
#undef VERSION_CHRONOLOGICAL_AGE
#undef VERSION_LANGUAGES
#undef VERSION_LOADOUT_PRESETS
#undef VERSION_INTERNAL_EXTERNAL_ORGANS