mirror of
https://github.com/libretro/RetroArch
synced 2025-03-28 19:20:35 +00:00
make the override function smarter, now it will return true if overrides have loaded and false otherwise (including on error)
move pretro_set_environment(rarch_environment_cb); further down since it wouldn't have achieved the desired effect in that location added a function to restore the original configuration when unloading the core so overrides won't affect the main config
This commit is contained in:
parent
f060811ae8
commit
507ec17261
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -412,6 +412,8 @@ void config_load(void);
|
||||
*/
|
||||
bool config_load_override(void);
|
||||
|
||||
bool config_unload_override(void);
|
||||
|
||||
/**
|
||||
* config_load_remap:
|
||||
*
|
||||
|
27
retroarch.c
27
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");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user