mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 20:48:56 +01:00
Allow localhosts to set "dev override preferences" to load a specific preference savefile for guests (#92770)
## About The Pull Request A verb is now available on localhost called `"Export Save as Dev Preferences"` This exports your current savefile to `/config/dev_preferences.json` If you then connect to your localhost as a guest, it will load `dev_preferences.json` as your preference datum This allows for devs testing the game locally to load preferences for guests. (Guests connecting to live servers are completely unaffected.) ## Why It's Good For The Game Initially I only did this because the recent keybinding changes have destroyed my muscle memory when testing w/o logging in. But as I worked on it I thought of a few other usecases, like when implementing preference version migration - the dev preference is never saved which means you can re-compile as much as you want without needing to revert your save manually.
This commit is contained in:
@@ -101,8 +101,13 @@ GLOBAL_LIST_EMPTY(preferences_datums)
|
||||
middleware += new middleware_type(src)
|
||||
|
||||
if(IS_CLIENT_OR_MOCK(parent))
|
||||
load_and_save = !is_guest_key(parent.key)
|
||||
load_path(parent.ckey)
|
||||
if(is_guest_key(parent.key))
|
||||
if(parent.is_localhost())
|
||||
path = DEV_PREFS_PATH // guest + locallost = dev instance, load dev preferences if possible
|
||||
else
|
||||
load_and_save = FALSE // guest + not localhost = guest on live, don't save anything
|
||||
else
|
||||
load_path(parent.ckey) // not guest = load their actual savefile
|
||||
if(load_and_save && !fexists(path))
|
||||
try_savefile_type_migration()
|
||||
|
||||
|
||||
@@ -275,6 +275,10 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
|
||||
/datum/preferences/proc/save_preferences()
|
||||
if(!savefile)
|
||||
CRASH("Attempted to save the preferences of [parent] without a savefile. This should have been handled by load_preferences()")
|
||||
if(path == DEV_PREFS_PATH)
|
||||
// Don't save over dev preferences
|
||||
return TRUE
|
||||
|
||||
savefile.set_entry("version", SAVEFILE_VERSION_MAX) //updates (or failing that the sanity checks) will ensure data is not invalid at load. Assume up-to-date
|
||||
|
||||
for (var/preference_type in GLOB.preference_entries)
|
||||
|
||||
Reference in New Issue
Block a user