From cde482bb248def2c16c22e28b915ef9d529d2b04 Mon Sep 17 00:00:00 2001 From: Mothblocks <35135081+Mothblocks@users.noreply.github.com> Date: Sun, 19 Sep 2021 12:15:47 -0700 Subject: [PATCH] Fix FPS and other preferences not properly applying after reconnect (#61542) Fixes #61515. Preferences were only applied on load_preferences(), which only fires when the preferences datum is created. Preferences datums are cached, and so load_preferences is only called the once. --- code/modules/client/client_procs.dm | 1 + code/modules/client/preferences.dm | 9 +++++++++ code/modules/client/preferences_savefile.dm | 7 +------ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index b7497ae8fff..dc817c81cb3 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -238,6 +238,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( prefs = GLOB.preferences_datums[ckey] if(prefs) prefs.parent = src + prefs.apply_all_client_preferences() else prefs = new /datum/preferences(src) GLOB.preferences_datums[ckey] = prefs diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 32670c5b4c7..592c614e4c3 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -329,6 +329,15 @@ GLOBAL_LIST_EMPTY(preferences_datums) return preferences +/// Applies all PREFERENCE_PLAYER preferences +/datum/preferences/proc/apply_all_client_preferences() + for (var/datum/preference/preference as anything in get_preferences_in_priority_order()) + if (preference.savefile_identifier != PREFERENCE_PLAYER) + continue + + value_cache -= preference.type + preference.apply_to_client(parent, read_preference(preference.type)) + // This is necessary because you can open the set preferences menu before // the atoms SS is done loading. INITIALIZE_IMMEDIATE(/atom/movable/screen/character_preview_view) diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index f1ff9b316ab..a9f97d90efa 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -163,12 +163,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car fcopy(S, bacpath) //byond helpfully lets you use a savefile for the first arg. return FALSE - for (var/datum/preference/preference as anything in get_preferences_in_priority_order()) - if (preference.savefile_identifier != PREFERENCE_PLAYER) - continue - - value_cache -= preference.type - preference.apply_to_client(parent, read_preference(preference.type)) + apply_all_client_preferences() //general preferences READ_FILE(S["lastchangelog"], lastchangelog)