From 24abb2ebf961d0360102a7745dee3b749b77a7b0 Mon Sep 17 00:00:00 2001 From: AnturK Date: Mon, 15 Jun 2020 14:54:18 +0200 Subject: [PATCH] Adds keybindings sanity. (#51627) * Adds keybindings sanity. * Whoops * clears the key if it's unsed --- code/modules/client/preferences_savefile.dm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index af31ec76454..9c0ee2584fc 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -244,7 +244,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car be_special = SANITIZE_LIST(be_special) pda_style = sanitize_inlist(pda_style, GLOB.pda_styles, initial(pda_style)) pda_color = sanitize_hexcolor(pda_color, 6, 1, initial(pda_color)) - key_bindings = sanitize_islist(key_bindings, list()) + key_bindings = sanitize_keybindings(key_bindings) return TRUE @@ -555,6 +555,14 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car return TRUE +/proc/sanitize_keybindings(value) + var/list/base_bindings = sanitize_islist(value,list()) + for(var/key in base_bindings) + base_bindings[key] = base_bindings[key] & GLOB.keybindings_by_name + if(!length(base_bindings[key])) + base_bindings -= key + return base_bindings + #undef SAVEFILE_VERSION_MAX #undef SAVEFILE_VERSION_MIN