From 5dccb02b8032e6ca98801d09fa1d884a26427dc3 Mon Sep 17 00:00:00 2001 From: chaoskagami Date: Sat, 23 Jul 2016 09:31:32 -0400 Subject: [PATCH] Allow updating the 'accent color' value for old configs (it would cause issues, otherwise) --- source/option.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/source/option.c b/source/option.c index a52e123..0125d49 100644 --- a/source/option.c +++ b/source/option.c @@ -12,7 +12,7 @@ regenerate_config() memset(&config, 0, sizeof(config)); memcpy(&(config.magic), CONFIG_MAGIC, 4); config.config_ver = config_version; - config.options[OPTION_ACCENT_COLOR] = 0x2; + config.options[OPTION_ACCENT_COLOR] = 2; if (!(conf_handle = fopen(PATH_CONFIG, "w"))) abort("Failed to open config for write?\n"); @@ -52,6 +52,22 @@ mk_structure() f_mkdir(PATH_LOCEMU); } +void +update_config() +{ + int updated = 0; + + if (config.options[OPTION_ACCENT_COLOR] == 0) { + fprintf(stderr, "Config update: accent color\n"); + config.options[OPTION_ACCENT_COLOR] = 2; + updated = 1; + } + + if (updated) { + save_config(); // Save the configuration. + } +} + void load_config() { @@ -93,6 +109,8 @@ load_config() if (!config.options[OPTION_SILENCE]) fprintf(BOTTOM_SCREEN, "Config file loaded.\n"); + + update_config(); } void -- 2.39.5