From 554703cddaf3b85fa080bfd2eb51efdc521db365 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Mon, 8 Nov 2021 22:56:20 +0000 Subject: [PATCH] [MIRROR] Fixes numeric prefs not working with TGUI dropdowns that might return a string instead of a number [MDB IGNORE] (#9317) * Fixes numeric prefs not working with TGUI dropdowns that might return a string instead of a number (#62653) * Fixes numeric prefs not working with TGUI dropdowns that might return a string instead of a number Co-authored-by: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com> --- code/modules/client/preferences/_preference.dm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/modules/client/preferences/_preference.dm b/code/modules/client/preferences/_preference.dm index e5384bc7da1..26867462dfa 100644 --- a/code/modules/client/preferences/_preference.dm +++ b/code/modules/client/preferences/_preference.dm @@ -498,6 +498,8 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key()) abstract_type = /datum/preference/numeric /datum/preference/numeric/deserialize(input, datum/preferences/preferences) + if(istext(input)) // Sometimes TGUI will return a string instead of a number, so we take that into account. + input = text2num(input) // Worst case, it's null, it'll just use create_default_value() return sanitize_float(input, minimum, maximum, step, create_default_value()) /datum/preference/numeric/serialize(input)