From 1f17dea0d83af2aa6efde52eac6c46d49e2346da Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 4 Jul 2019 17:29:29 +0200 Subject: [PATCH] (configuration.c) Cleanups --- configuration.c | 33 +++++++++++++++++---------------- configuration.h | 4 ++-- retroarch.c | 14 +++++++++++--- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/configuration.c b/configuration.c index 68913cbe16..81ccf70a2c 100644 --- a/configuration.c +++ b/configuration.c @@ -3523,21 +3523,29 @@ success: return true; } -static void parse_config_file(void) +/** + * config_parse_file: + * + * Loads a config file and reads all the values into memory. + * + */ +void config_parse_file(void) { - const char *config_path = path_get(RARCH_PATH_CONFIG); if (path_is_empty(RARCH_PATH_CONFIG)) { RARCH_LOG("[config] Loading default config.\n"); } - RARCH_LOG("[config] loading config from: %s.\n", config_path); + { + const char *config_path = path_get(RARCH_PATH_CONFIG); + RARCH_LOG("[config] loading config from: %s.\n", config_path); - if (config_load_file(config_path, config_get_ptr())) - return; - - RARCH_ERR("[config] couldn't find config at path: \"%s\"\n", - config_path); + if (!config_load_file(config_path, config_get_ptr())) + { + RARCH_ERR("[config] couldn't find config at path: \"%s\"\n", + config_path); + } + } } /** @@ -3548,15 +3556,8 @@ static void parse_config_file(void) */ void config_load(void) { - /* Flush out some states that could have been - * set by core environment variables */ - core_unset_input_descriptors(); - - if (rarch_ctl(RARCH_CTL_IS_BLOCK_CONFIG_READ, NULL)) - return; - config_set_defaults(); - parse_config_file(); + config_parse_file(); } /** diff --git a/configuration.h b/configuration.h index 93df64069e..80e7df6fc7 100644 --- a/configuration.h +++ b/configuration.h @@ -746,12 +746,12 @@ const char *config_get_midi_driver_options(void); const char *config_get_default_record(void); /** - * config_load: + * config_parse_file: * * Loads a config file and reads all the values into memory. * */ -void config_load(void); +void config_parse_file(void); /** * config_load_override: diff --git a/retroarch.c b/retroarch.c index 4f9662bc9b..906bb61c0e 100644 --- a/retroarch.c +++ b/retroarch.c @@ -260,8 +260,9 @@ static retro_bits_t has_set_libretro_device; static bool has_set_core = false; #ifdef HAVE_DISCORD -bool discord_is_inited = false; +bool discord_is_inited = false; #endif +static bool rarch_block_config_read = false; static bool rarch_is_inited = false; static bool rarch_error_on_init = false; static bool rarch_force_fullscreen = false; @@ -13677,8 +13678,16 @@ static void retroarch_parse_input_and_config(int argc, char *argv[]) } } + /* Flush out some states that could have been set + * by core environment variables. */ + core_unset_input_descriptors(); + /* Load the config file now that we know what it is */ - config_load(); + if (!rarch_block_config_read) + { + config_set_defaults(); + config_parse_file(); + } /* Second pass: All other arguments override the config file */ optind = 1; @@ -14484,7 +14493,6 @@ static void runloop_task_msg_queue_push( bool rarch_ctl(enum rarch_ctl_state state, void *data) { static bool has_set_username = false; - static bool rarch_block_config_read = false; static bool rarch_patch_blocked = false; static bool runloop_missing_bios = false; /* TODO/FIXME - not used right now? */