From 8e94ad36a1d22716e0e5ea0f4236ae4ddf9b9e1d Mon Sep 17 00:00:00 2001 From: AnturK Date: Mon, 13 Jan 2020 04:13:00 +0100 Subject: [PATCH] Fix santize_hexcolor (#48716) This whole helper is a mess. Maybe I should just replace it completely instead. --- code/__HELPERS/sanitize_values.dm | 10 ++++++++-- code/modules/client/preferences.dm | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/code/__HELPERS/sanitize_values.dm b/code/__HELPERS/sanitize_values.dm index 5588b0309f1..4a6a9758d2c 100644 --- a/code/__HELPERS/sanitize_values.dm +++ b/code/__HELPERS/sanitize_values.dm @@ -16,7 +16,7 @@ return value if(default) return default - + /proc/sanitize_inlist(value, list/List, default) if(value in List) return value @@ -52,9 +52,12 @@ var/start = 1 + (text2ascii(color, 1) == 35) var/len = length(color) var/char = "" + // RRGGBB -> RGB but awful + var/convert_to_shorthand = desired_format == 3 && length_char(color) > 3 . = "" - for(var/i = start, i <= len, i += length(char)) + var/i = start + while(i <= len) char = color[i] switch(text2ascii(char)) if(48 to 57) //numbers 0 to 9 @@ -65,6 +68,9 @@ . += lowertext(char) else break + i += length(char) + if(convert_to_shorthand && i <= len) //skip next one + i += length(color[i]) if(length_char(.) != desired_format) if(default) diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 374c2153f6b..14509f250cf 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -1299,7 +1299,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) if(new_socks) socks = new_socks - if(BODY_ZONE_PRECISE_EYES) + if("eyes") var/new_eyes = input(user, "Choose your character's eye colour:", "Character Preference","#"+eye_color) as color|null if(new_eyes) eye_color = sanitize_hexcolor(new_eyes)