[NO GBP] Fix Languages Being Reset if You Load in Early (#15680)

* Account for the fact GLOB.language_datum_instances doesn't get populated until part way through the load process which I couldn't test because my dumb DD doesn't respond for like 2 minutes and getting to the 30s mark on the UI

* Account for the fact people do indeed use multiple characters, so it would be a good idea to fix languages on characters that are being switched to while avoiding saving more than is necessary to ensure the server isn't lagged to death should some smartass decide to switch between characters really fast to screw with the server

* Commit suggestion!

Co-authored-by: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com>

* Apply recommendations!

* Fix outdated languages being applied by default!

Co-authored-by: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com>
This commit is contained in:
RimiNosha
2022-08-24 17:33:33 -04:00
committed by GitHub
co-authored by GoldenAlpharex
parent e32a5d4886
commit 0b65fd1b66
15 changed files with 28 additions and 39 deletions
+6 -4
View File
@@ -114,10 +114,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
if(loaded_preferences_successfully)
if(load_character())
// SKYRAT EDIT START - Sanitizing languages
for(var/lang_path as anything in languages)
var/datum/language/language = GLOB.language_datum_instances[lang_path]
if(!language || language.secret)
languages.Remove(lang_path)
sanitize_languages()
// SKYRAT EDIT END
return // SKYRAT EDIT - Don't remove this. Just don't. Nothing is worth forced random characters.
//we couldn't load character data so just randomize the character appearance + name
@@ -233,6 +230,11 @@ GLOBAL_LIST_EMPTY(preferences_datums)
randomise_appearance_prefs()
save_character()
// SKYRAT EDIT START - Sanitizing languages
if(sanitize_languages())
save_character()
// SKYRAT EDIT END
for (var/datum/preference_middleware/preference_middleware as anything in middleware)
preference_middleware.on_new_character(usr)