| "
@@ -3240,6 +3245,14 @@ GLOBAL_LIST_EMPTY(preferences_datums)
preferences_tab = text2num(href_list["tab"])
if(href_list["preference"] == "gear")
+ if(href_list["select_slot"])
+ var/chosen = text2num(href_list["select_slot"])
+ if(!chosen)
+ return
+ chosen = floor(chosen)
+ if(chosen > MAXIMUM_LOADOUT_SAVES || chosen < 1)
+ return
+ loadout_slot = chosen
if(href_list["clear_loadout"])
loadout_data["SAVE_[loadout_slot]"] = list()
save_preferences()
diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm
index 6c65cc0720..d457f85e07 100644
--- a/code/modules/client/preferences_savefile.dm
+++ b/code/modules/client/preferences_savefile.dm
@@ -911,10 +911,13 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
belly_prefs = json_from_file["belly_prefs"]
//gear loadout
- if(S["loadout"])
+ if(istext(S["loadout"]))
loadout_data = safe_json_decode(S["loadout"])
else
- loadout_data = list()
+ var/list/make_new[MAXIMUM_LOADOUT_SAVES]
+ loadout_data = make_new
+ //let's remember their last used slot, i'm sure "oops i brought the wrong stuff" will be an issue now
+ S["loadout_slot"] >> loadout_slot
//try to fix any outdated data if necessary
//preference updating will handle saving the updated data for us.
@@ -1094,6 +1097,8 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
vore_smell = copytext(vore_smell, 1, MAX_TASTE_LEN)
belly_prefs = SANITIZE_LIST(belly_prefs)
+ loadout_slot = sanitize_num_clamp(loadout_slot, 1, MAXIMUM_LOADOUT_SAVES, 1, TRUE)
+
cit_character_pref_load(S)
return TRUE
@@ -1278,10 +1283,12 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
//gear loadout
- if(length(loadout_data))
+ if(islist(loadout_data))
S["loadout"] << safe_json_encode(loadout_data)
else
- S["loadout"] << safe_json_encode(list())
+ var/list/make_new[MAXIMUM_LOADOUT_SAVES]
+ S["loadout"] << safe_json_encode(make_new)
+ WRITE_FILE(S["loadout_slot"], loadout_slot)
if(length(tcg_cards))
S["tcg_cards"] << safe_json_encode(tcg_cards)
|