From c8428e38728c346efa68624345463a7d6642eb42 Mon Sep 17 00:00:00 2001 From: carnie Date: Mon, 20 May 2013 04:24:49 +0100 Subject: [PATCH] Resolves an issue with sanitize_hexcolor - It now has an optional default return value again. Fixes some bad arguments in a call to sanitize_hexcolor which was causing admin ooccolor to be set to "000" on load. --- code/__HELPERS/sanitize_values.dm | 9 ++++++--- code/modules/client/preferences_savefile.dm | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/code/__HELPERS/sanitize_values.dm b/code/__HELPERS/sanitize_values.dm index 2ce093e3003..29e6c15d20e 100644 --- a/code/__HELPERS/sanitize_values.dm +++ b/code/__HELPERS/sanitize_values.dm @@ -31,10 +31,11 @@ return default -/proc/sanitize_hexcolor(color, desired_format=3, include_bang=0) +/proc/sanitize_hexcolor(color, desired_format=3, include_bang=0, default) var/bang = include_bang ? "#" : "" if(!istext(color)) - return bang + random_string(desired_format, zero_character_only) + if(default) return default + return bang + repeat_string(desired_format, "0") var/start = 1 + (text2ascii(color,1)==35) var/len = length(color) @@ -47,6 +48,8 @@ if(48 to 57) . += ascii2text(ascii) //numbers 0 to 9 if(97 to 102) . += ascii2text(ascii) //letters a to f if(65 to 70) . += ascii2text(ascii+32) //letters A to F - translates to lowercase - else return bang + random_string(desired_format, zero_character_only) + else + if(default) return default + return bang + repeat_string(desired_format, "0") return . \ No newline at end of file diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index b079a33ece1..7090d3911ab 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -110,7 +110,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car update_preferences(needs_update) //needs_update = savefile_version if we need an update (positive integer) //Sanitize - ooccolor = sanitize_hexcolor(ooccolor, initial(ooccolor)) + ooccolor = sanitize_hexcolor(ooccolor, 6, 1, initial(ooccolor)) lastchangelog = sanitize_text(lastchangelog, initial(lastchangelog)) UI_style = sanitize_inlist(UI_style, list("Midnight", "Plasmafire", "Retro"), initial(UI_style)) be_special = sanitize_integer(be_special, 0, 65535, initial(be_special))