Skip to content

Commit

Permalink
Fix Some Preferences Not Saving (#3975)
Browse files Browse the repository at this point in the history
# About the pull request

This PR increases the size of some settings (namely toggle_prefs) from
16 bits to 24 bits so preferences like TOGGLE_LATE_JOIN_CURRENT_SLOT and
TOGGLE_ABILITY_DEACTIVATION_OFF will now actually stick.

# Explain why it's good for the game

Fixes at least two preferences not saving/loading correctly.

# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl: Drathek
fix: Fixed ability deactivation and late join current slot toggles not
persisting.
fix: Toggle the Ability to Hurt Yourself now says On when you can hurt
yourself.
/:cl:
  • Loading branch information
Drulikar committed Jul 24, 2023
1 parent 1b1171a commit 6565f67
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ var/const/MAX_SAVE_SLOTS = 10
dat += "<div id='column3'>"
dat += "<h2><b><u>Gameplay Toggles:</u></b></h2>"
dat += "<b>Toggle Being Able to Hurt Yourself: \
</b> <a href='?_src_=prefs;preference=toggle_prefs;flag=[TOGGLE_IGNORE_SELF]'><b>[toggle_prefs & TOGGLE_IGNORE_SELF ? "On" : "Off"]</b></a><br>"
</b> <a href='?_src_=prefs;preference=toggle_prefs;flag=[TOGGLE_IGNORE_SELF]'><b>[toggle_prefs & TOGGLE_IGNORE_SELF ? "Off" : "On"]</b></a><br>"
dat += "<b>Toggle Help Intent Safety: \
</b> <a href='?_src_=prefs;preference=toggle_prefs;flag=[TOGGLE_HELP_INTENT_SAFETY]'><b>[toggle_prefs & TOGGLE_HELP_INTENT_SAFETY ? "On" : "Off"]</b></a><br>"
dat += "<b>Toggle Middle Mouse Ability Activation: \
Expand Down
22 changes: 11 additions & 11 deletions code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -199,22 +199,22 @@
lastchangelog = sanitize_text(lastchangelog, initial(lastchangelog))
UI_style = sanitize_inlist(UI_style, list("white", "dark", "midnight", "orange", "old"), initial(UI_style))
tgui_say = sanitize_integer(tgui_say, FALSE, TRUE, TRUE)
be_special = sanitize_integer(be_special, 0, 65535, initial(be_special))
be_special = sanitize_integer(be_special, 0, SHORT_REAL_LIMIT, initial(be_special))
default_slot = sanitize_integer(default_slot, 1, MAX_SAVE_SLOTS, initial(default_slot))
toggles_chat = sanitize_integer(toggles_chat, 0, 65535, initial(toggles_chat))
chat_display_preferences = sanitize_integer(chat_display_preferences, 0, 65535, initial(chat_display_preferences))
toggles_ghost = sanitize_integer(toggles_ghost, 0, 65535, initial(toggles_ghost))
toggles_langchat = sanitize_integer(toggles_langchat, 0, 65535, initial(toggles_langchat))
toggles_sound = sanitize_integer(toggles_sound, 0, 65535, initial(toggles_sound))
toggle_prefs = sanitize_integer(toggle_prefs, 0, 65535, initial(toggle_prefs))
toggles_flashing= sanitize_integer(toggles_flashing, 0, 65535, initial(toggles_flashing))
toggles_ert = sanitize_integer(toggles_ert, 0, 65535, initial(toggles_ert))
toggles_admin = sanitize_integer(toggles_admin, 0, 65535, initial(toggles_admin))
toggles_chat = sanitize_integer(toggles_chat, 0, SHORT_REAL_LIMIT, initial(toggles_chat))
chat_display_preferences = sanitize_integer(chat_display_preferences, 0, SHORT_REAL_LIMIT, initial(chat_display_preferences))
toggles_ghost = sanitize_integer(toggles_ghost, 0, SHORT_REAL_LIMIT, initial(toggles_ghost))
toggles_langchat = sanitize_integer(toggles_langchat, 0, SHORT_REAL_LIMIT, initial(toggles_langchat))
toggles_sound = sanitize_integer(toggles_sound, 0, SHORT_REAL_LIMIT, initial(toggles_sound))
toggle_prefs = sanitize_integer(toggle_prefs, 0, SHORT_REAL_LIMIT, initial(toggle_prefs))
toggles_flashing= sanitize_integer(toggles_flashing, 0, SHORT_REAL_LIMIT, initial(toggles_flashing))
toggles_ert = sanitize_integer(toggles_ert, 0, SHORT_REAL_LIMIT, initial(toggles_ert))
toggles_admin = sanitize_integer(toggles_admin, 0, SHORT_REAL_LIMIT, initial(toggles_admin))
UI_style_color = sanitize_hexcolor(UI_style_color, initial(UI_style_color))
UI_style_alpha = sanitize_integer(UI_style_alpha, 0, 255, initial(UI_style_alpha))
item_animation_pref_level = sanitize_integer(item_animation_pref_level, SHOW_ITEM_ANIMATIONS_NONE, SHOW_ITEM_ANIMATIONS_ALL, SHOW_ITEM_ANIMATIONS_ALL)
pain_overlay_pref_level = sanitize_integer(pain_overlay_pref_level, PAIN_OVERLAY_BLURRY, PAIN_OVERLAY_LEGACY, PAIN_OVERLAY_BLURRY)
window_skin = sanitize_integer(window_skin, 0, 65535, initial(window_skin))
window_skin = sanitize_integer(window_skin, 0, SHORT_REAL_LIMIT, initial(window_skin))
ghost_vision_pref = sanitize_inlist(ghost_vision_pref, list(GHOST_VISION_LEVEL_NO_NVG, GHOST_VISION_LEVEL_MID_NVG, GHOST_VISION_LEVEL_FULL_NVG), GHOST_VISION_LEVEL_MID_NVG)
ghost_orbit = sanitize_inlist(ghost_orbit, GLOB.ghost_orbits, initial(ghost_orbit))
playtime_perks = sanitize_integer(playtime_perks, 0, 1, 1)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/tgui/tgui_number_input.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
qdel(number_input)

///A clone of tgui_input_number that defaults to accepting negative inputs too.
/proc/tgui_input_real_number(mob/user, message, title = "Number Input", default = 0, max_value = 16777216, min_value = -16777216, timeout = 0, integer_only = FALSE)
/proc/tgui_input_real_number(mob/user, message, title = "Number Input", default = 0, max_value = SHORT_REAL_LIMIT, min_value = -SHORT_REAL_LIMIT, timeout = 0, integer_only = FALSE)
return tgui_input_number(user, message, title, default, max_value, min_value, timeout, integer_only)
/**
* Creates an asynchronous TGUI number input window with an associated callback.
Expand Down

0 comments on commit 6565f67

Please sign in to comment.