Fixes preferences resetting (#3104)

## About The Pull Request
Fixes https://github.com/Bubberstation/Bubberstation/issues/2879

The reason for the issue seems rooted in skyrat's own port of the
original json configs on tg (or perhaps the loads of changes they've
made to it over the years). This pr patches it so that characters won't
reset between rounds.

original fixes by smartkar
## Why It's Good For The Game
Guess
## Proof Of Testing
<details>
<summary>Screenshots/Videos</summary>


![qe0kfreu8l](https://github.com/user-attachments/assets/c84b20a1-c09b-4905-b682-3c280c7e8ab3)


</details>
It saves the character on creation and works fine after re-accessing the
savefile

## Changelog
🆑
fixes: fixes the issue where characters would reset after a round or on
switching character slots
/🆑
This commit is contained in:
Mosley
2025-02-16 23:29:37 -05:00
committed by GitHub
parent f14c571ec4
commit 65e7c8c6bd
4 changed files with 11 additions and 9 deletions
+1 -1
View File
@@ -136,7 +136,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
if(!loaded_preferences_successfully)
save_preferences()
save_character() //let's save this new random character so it doesn't keep generating new ones.
save_character(TRUE) //let's save this new random character so it doesn't keep generating new ones. // BUBBER EDIT
/datum/preferences/ui_interact(mob/user, datum/tgui/ui)
// There used to be code here that readded the preview view if you "rejoined"
+4 -4
View File
@@ -25,7 +25,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
*/
/datum/preferences/proc/save_data_needs_update(list/save_data)
if(!save_data) // empty list, either savefile isnt loaded or its a new char
return -1
return -3 // BUBBER EDIT
if(save_data["version"] < SAVEFILE_VERSION_MIN)
return -2
if(save_data["version"] < SAVEFILE_VERSION_MAX)
@@ -328,7 +328,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
all_quirks = SSquirks.filter_invalid_quirks(SANITIZE_LIST(all_quirks), augments)// SKYRAT EDIT - AUGMENTS+
validate_quirks()
return TRUE
return needs_update != -3 // BUBBER EDIT
/datum/preferences/proc/save_character(update) // Skyrat edit - Choose when to update (This is stupid)
SHOULD_NOT_SLEEP(TRUE)
@@ -343,7 +343,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
if (preference.savefile_identifier != PREFERENCE_CHARACTER)
continue
if (!(preference.type in recently_updated_keys))
if (!update && !(preference.type in recently_updated_keys)) // BUBBER EDIT
continue
recently_updated_keys -= preference.type
@@ -376,7 +376,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
if (!load_character(new_slot))
tainted_character_profiles = TRUE
randomise_appearance_prefs()
save_character()
save_character(TRUE) // BUBBER EDIT
for (var/datum/preference_middleware/preference_middleware as anything in middleware)
preference_middleware.on_new_character(usr)
@@ -25,7 +25,7 @@
/datum/preferences/proc/savefile_needs_update_skyrat(list/save_data)
var/savefile_version = save_data["modular_version"]
if(save_data.len && savefile_version < MODULAR_SAVEFILE_VERSION_MAX)
if(savefile_version && savefile_version < MODULAR_SAVEFILE_VERSION_MAX) // BUBBER EDIT
return savefile_version
return MODULAR_SAVEFILE_UP_TO_DATE
@@ -79,7 +79,7 @@
languages = save_languages
tgui_prefs_migration = save_data["tgui_prefs_migration"]
if(!tgui_prefs_migration && save_data.len) // If save_data is empty, this is definitely a new character
if(!tgui_prefs_migration && save_data["modular_version"] && save_data["modular_version"] < MODULAR_SAVEFILE_VERSION_MAX) // BUBBER EDIT - if we're missing version from migration, then the char is new. Won't be able to migrate either.
to_chat(parent, examine_block(span_redtext("PREFERENCE MIGRATION BEGINNING.\
\nDO NOT INTERACT WITH YOUR PREFERENCES UNTIL THIS PROCESS HAS BEEN COMPLETED.\
\nDO NOT DISCONNECT UNTIL THIS PROCESS HAS BEEN COMPLETED.\
@@ -284,8 +284,9 @@
save_data["alt_job_titles"] = alt_job_titles
save_data["languages"] = languages
save_data["food_preferences"] = food_preferences
if(updated)
save_data["modular_version"] = MODULAR_SAVEFILE_VERSION_MAX
//if(updated) // BUBBER EDIT - This is bullshit, results in newly created characters getting invalid data. Load character should forcefully migrate it, so we can safely assume its up to date
// save_data["modular_version"] = MODULAR_SAVEFILE_VERSION_MAX
save_data["modular_version"] = MODULAR_SAVEFILE_VERSION_MAX
/datum/preferences/proc/update_body_parts(datum/preference/preference)
@@ -84,6 +84,7 @@ GLOBAL_DATUM(character_directory, /datum/character_directory)
/// Saves us on copypaste code
/datum/preference/choiced/directory_character_prefs
savefile_key = "char_directory_char_prefs" // This is so unit checks don't scream
abstract_type = /datum/preference/choiced/directory_character_prefs
/datum/preference/choiced/directory_character_prefs/init_possible_values()
return list("Yes", "No", "No ERP", "Check OOC", "Unset", "Maybe")