diff --git a/configuration.c b/configuration.c index 6eee97756a..30ed007428 100644 --- a/configuration.c +++ b/configuration.c @@ -1651,12 +1651,13 @@ bool config_load_override(void) core_path[PATH_MAX_LENGTH], /* final path for core-specific configuration (prefix+suffix) */ game_path[PATH_MAX_LENGTH]; /* final path for game-specific configuration (prefix+suffix) */ const char *core_name, *game_name; /* suffix */ + global_t *global = global_get_ptr(); /* global pointer */ settings_t *settings = config_get_ptr(); /* config pointer */ //early return in case a library isn't loaded if(!global->system.info.library_name || !strcmp(global->system.info.library_name,"No Core")) - return true; + return false; RARCH_LOG("Game name: %s\n",global->basename); RARCH_LOG("Core name: %s\n",global->system.info.library_name); @@ -1675,17 +1676,15 @@ bool config_load_override(void) else { RARCH_WARN("No config directory set under Settings > Path and retroarch.cfg not found.\n"); - return true; + return false; } RARCH_LOG("Config directory: %s\n", config_directory); - /* Core name: core_name - * i.e. Mupen64plus */ + // core name: core_name core_name = global->system.info.library_name; game_name = path_basename(global->basename); - /* ROM basename: game_name - * no extension or leading directory i.e. "Super Mario 64 (USA)" */ + // content basename: game_name game_name = path_basename(global->basename); /* Concat strings into full paths: core_path, game_path */ @@ -1705,12 +1704,12 @@ bool config_load_override(void) /* Append core-specific */ if (new_conf) { - RARCH_LOG("Core-specific configuration found at %s. Appending.\n", core_path); + RARCH_LOG("Core-specific overrides found at %s. Appending.\n", core_path); strlcpy(global->append_config_path, core_path, sizeof(global->append_config_path)); should_append = true; } else - RARCH_LOG("No core-specific configuration found at %s.\n", core_path); + RARCH_LOG("No core-specific overrides found at %s.\n", core_path); new_conf = NULL; @@ -1720,6 +1719,7 @@ bool config_load_override(void) /* Append game-specific */ if (new_conf) { + RARCH_LOG("Game-specific overrides found at %s. Appending.\n", game_path); if(should_append) { strlcat(global->append_config_path, "|", sizeof(global->append_config_path)); @@ -1727,20 +1727,34 @@ bool config_load_override(void) } else strlcpy(global->append_config_path, game_path, sizeof(global->append_config_path)); - RARCH_LOG("Game-specific configuration found at %s. Appending.\n", game_path); - + should_append = true; } else - RARCH_LOG("No game-specific configuration found at %s.\n", game_path); + RARCH_LOG("No game-specific overrides found at %s.\n", game_path); if(should_append) { - if(!config_load_file(global->config_path, false)) - return false; + if(config_load_file(global->config_path, false)) + return true; } - return true; /* only means no errors were caught */ + return false; +} + +bool core_unload_override(void) +{ + global_t *global = global_get_ptr(); + settings_t *settings = config_get_ptr(); + + *global->append_config_path = NULL; + if(config_load_file(global->config_path, false)) + { + RARCH_LOG("Configuration overrides unloaded, original configuration reset\n"); + return true; + } + else + return false; } /** diff --git a/configuration.h b/configuration.h index 2cda21494c..5a87f107d8 100644 --- a/configuration.h +++ b/configuration.h @@ -412,6 +412,8 @@ void config_load(void); */ bool config_load_override(void); +bool config_unload_override(void); + /** * config_load_remap: * diff --git a/retroarch.c b/retroarch.c index 96949622f5..db79751d10 100644 --- a/retroarch.c +++ b/retroarch.c @@ -415,6 +415,8 @@ static void parse_input(int argc, char *argv[]) *global->bps_name = '\0'; *global->ips_name = '\0'; *global->subsystem = '\0'; + + global->overrides_active = false; if (argc < 2) { @@ -1842,12 +1844,23 @@ static void init_system_av_info(void) static void deinit_core(bool reinit) { + + global_t *global = global_get_ptr(); + pretro_unload_game(); pretro_deinit(); if (reinit) rarch_main_command(RARCH_CMD_DRIVERS_DEINIT); + + + if(global->overrides_active) + { + core_unload_override(); + pretro_set_environment(rarch_environment_cb); + } + uninit_libretro_sym(); } @@ -1884,13 +1897,15 @@ static bool init_content(void) static bool init_core(void) { driver_t *driver = driver_get_ptr(); - global_t *global = global_get_ptr(); - - //needs testing for regressions - pretro_set_environment(rarch_environment_cb); + global_t *global = global_get_ptr(); - if (!config_load_override()) - RARCH_ERR("Error loading override files\n"); + if (config_load_override()) + global->overrides_active = true; + else + global->overrides_active = false; + + pretro_set_environment(rarch_environment_cb); + if (!config_load_remap()) RARCH_ERR("Error loading remap files\n"); diff --git a/runloop.h b/runloop.h index acccac7c5c..f094430b91 100644 --- a/runloop.h +++ b/runloop.h @@ -143,6 +143,8 @@ typedef struct global bool has_set_ups_pref; bool has_set_bps_pref; bool has_set_ips_pref; + + bool overrides_active; /* Config associated with global "default" config. */ char config_path[PATH_MAX_LENGTH];