diff --git a/code/__HELPERS/sanitize_values.dm b/code/__HELPERS/sanitize_values.dm index faa8c22f38..e494468fe7 100644 --- a/code/__HELPERS/sanitize_values.dm +++ b/code/__HELPERS/sanitize_values.dm @@ -6,6 +6,13 @@ return number return default +/proc/sanitize_num_clamp(number, min=0, max=1, default=0, quantize=0) + if(!isnum(number)) + return default + . = CLAMP(number, min, max) + if(quantize) + . = round(number, quantize) + /proc/sanitize_text(text, default="") if(istext(text)) return text diff --git a/code/controllers/configuration/entries/game_options.dm b/code/controllers/configuration/entries/game_options.dm index cb18d37f21..60eda61802 100644 --- a/code/controllers/configuration/entries/game_options.dm +++ b/code/controllers/configuration/entries/game_options.dm @@ -455,10 +455,12 @@ config_entry_value = RESIZE_DEFAULT_SIZE min_val = 0.1 //to avoid issues with zeros and negative values. max_val = RESIZE_DEFAULT_SIZE + integer = FALSE /datum/config_entry/number/body_size_max config_entry_value = RESIZE_DEFAULT_SIZE min_val = RESIZE_DEFAULT_SIZE + integer = FALSE //Pun-Pun movement slowdown given to characters with a body size smaller than this value, //to compensate for their smaller hitbox. @@ -467,12 +469,14 @@ config_entry_value = RESIZE_DEFAULT_SIZE * 0.85 min_val = 0 max_val = RESIZE_DEFAULT_SIZE + integer = FALSE //multiplicative slowdown multiplier. See 'dna.update_body_size' for the operation. //doesn't apply to floating or crawling mobs /datum/config_entry/number/body_size_slowdown_multiplier config_entry_value = 0.25 min_val = 0.1 //To encourage folks to disable the slowdown through the above config instead. + integer = FALSE //Allows players to set a hexadecimal color of their choice as skin tone, on top of the standard ones. /datum/config_entry/number/allow_custom_skintones diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index a64d3e057d..4bf55c9837 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -599,7 +599,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car var/static/size_max if(!size_max) size_max = CONFIG_GET(number/body_size_max) - features["body_size"] = sanitize_integer(features["body_size"], size_min, size_max, RESIZE_DEFAULT_SIZE) + features["body_size"] = sanitize_num_clamp(features["body_size"], size_min, size_max, RESIZE_DEFAULT_SIZE, 0.01) var/static/list/B_sizes if(!B_sizes)