mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-16 18:45:22 +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:
@@ -1031,3 +1031,21 @@ ADMIN_VERB(count_instances, R_DEBUG, "Count Atoms/Datums", "Count how many atom
|
||||
. = list()
|
||||
CRASH("count_datums not supported on OpenDream")
|
||||
#endif
|
||||
|
||||
ADMIN_VERB_VISIBILITY(export_save_to_dev_preference, ADMIN_VERB_VISIBLITY_FLAG_LOCALHOST)
|
||||
ADMIN_VERB(export_save_to_dev_preference, R_DEBUG, "Export Save as Dev Preferences", "Exports your savefile to be used by any guests that connect to your localost.", ADMIN_CATEGORY_SERVER)
|
||||
if(!user.is_localhost())
|
||||
tgui_alert(user, "You shouldn't be using this right now!", "Export Failed", list("OK"))
|
||||
log_admin("[key_name(user)] attempted to export preferences to [DEV_PREFS_PATH] - this is normally locked to localhost only!")
|
||||
stack_trace("Export Save as Dev Preferences was called by a non-localhost user!")
|
||||
return
|
||||
if(is_guest_key(user.key))
|
||||
tgui_alert(user, "Guests don't have preferences to export.", "Export Failed", list("OK"))
|
||||
return
|
||||
var/datum/preferences/user_prefs = user.prefs
|
||||
var/datum/json_savefile/dev_save = new(DEV_PREFS_PATH)
|
||||
user_prefs.save_preferences()
|
||||
user_prefs.savefile.copy_to_savefile(dev_save)
|
||||
dev_save.save()
|
||||
tgui_alert(user, "Exported preferences to [DEV_PREFS_PATH]. \
|
||||
Next time you localhost as a guest it will use this savefile as-is.", "Export Complete", list("OK thanks"))
|
||||
|
||||
Reference in New Issue
Block a user