mirror of
https://github.com/libretro/RetroArch
synced 2025-04-17 20:43:10 +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) */
|
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) */
|
game_path[PATH_MAX_LENGTH]; /* final path for game-specific configuration (prefix+suffix) */
|
||||||
const char *core_name, *game_name; /* suffix */
|
const char *core_name, *game_name; /* suffix */
|
||||||
|
|
||||||
global_t *global = global_get_ptr(); /* global pointer */
|
global_t *global = global_get_ptr(); /* global pointer */
|
||||||
settings_t *settings = config_get_ptr(); /* config pointer */
|
settings_t *settings = config_get_ptr(); /* config pointer */
|
||||||
|
|
||||||
//early return in case a library isn't loaded
|
//early return in case a library isn't loaded
|
||||||
if(!global->system.info.library_name || !strcmp(global->system.info.library_name,"No Core"))
|
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("Game name: %s\n",global->basename);
|
||||||
RARCH_LOG("Core name: %s\n",global->system.info.library_name);
|
RARCH_LOG("Core name: %s\n",global->system.info.library_name);
|
||||||
@ -1675,17 +1676,15 @@ bool config_load_override(void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
RARCH_WARN("No config directory set under Settings > Path and retroarch.cfg not found.\n");
|
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);
|
RARCH_LOG("Config directory: %s\n", config_directory);
|
||||||
|
|
||||||
/* Core name: core_name
|
// core name: core_name
|
||||||
* i.e. Mupen64plus */
|
|
||||||
core_name = global->system.info.library_name;
|
core_name = global->system.info.library_name;
|
||||||
game_name = path_basename(global->basename);
|
game_name = path_basename(global->basename);
|
||||||
|
|
||||||
/* ROM basename: game_name
|
// content basename: game_name
|
||||||
* no extension or leading directory i.e. "Super Mario 64 (USA)" */
|
|
||||||
game_name = path_basename(global->basename);
|
game_name = path_basename(global->basename);
|
||||||
|
|
||||||
/* Concat strings into full paths: core_path, game_path */
|
/* Concat strings into full paths: core_path, game_path */
|
||||||
@ -1705,12 +1704,12 @@ bool config_load_override(void)
|
|||||||
/* Append core-specific */
|
/* Append core-specific */
|
||||||
if (new_conf)
|
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));
|
strlcpy(global->append_config_path, core_path, sizeof(global->append_config_path));
|
||||||
should_append = true;
|
should_append = true;
|
||||||
}
|
}
|
||||||
else
|
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;
|
new_conf = NULL;
|
||||||
|
|
||||||
@ -1720,6 +1719,7 @@ bool config_load_override(void)
|
|||||||
/* Append game-specific */
|
/* Append game-specific */
|
||||||
if (new_conf)
|
if (new_conf)
|
||||||
{
|
{
|
||||||
|
RARCH_LOG("Game-specific overrides found at %s. Appending.\n", game_path);
|
||||||
if(should_append)
|
if(should_append)
|
||||||
{
|
{
|
||||||
strlcat(global->append_config_path, "|", sizeof(global->append_config_path));
|
strlcat(global->append_config_path, "|", sizeof(global->append_config_path));
|
||||||
@ -1727,20 +1727,34 @@ bool config_load_override(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
strlcpy(global->append_config_path, game_path, sizeof(global->append_config_path));
|
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;
|
should_append = true;
|
||||||
}
|
}
|
||||||
else
|
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(should_append)
|
||||||
{
|
{
|
||||||
if(!config_load_file(global->config_path, false))
|
if(config_load_file(global->config_path, false))
|
||||||
return 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_load_override(void);
|
||||||
|
|
||||||
|
bool config_unload_override(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* config_load_remap:
|
* config_load_remap:
|
||||||
*
|
*
|
||||||
|
21
retroarch.c
21
retroarch.c
@ -416,6 +416,8 @@ static void parse_input(int argc, char *argv[])
|
|||||||
*global->ips_name = '\0';
|
*global->ips_name = '\0';
|
||||||
*global->subsystem = '\0';
|
*global->subsystem = '\0';
|
||||||
|
|
||||||
|
global->overrides_active = false;
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
global->libretro_dummy = true;
|
global->libretro_dummy = true;
|
||||||
@ -1842,12 +1844,23 @@ static void init_system_av_info(void)
|
|||||||
|
|
||||||
static void deinit_core(bool reinit)
|
static void deinit_core(bool reinit)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
global_t *global = global_get_ptr();
|
||||||
|
|
||||||
pretro_unload_game();
|
pretro_unload_game();
|
||||||
pretro_deinit();
|
pretro_deinit();
|
||||||
|
|
||||||
if (reinit)
|
if (reinit)
|
||||||
rarch_main_command(RARCH_CMD_DRIVERS_DEINIT);
|
rarch_main_command(RARCH_CMD_DRIVERS_DEINIT);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(global->overrides_active)
|
||||||
|
{
|
||||||
|
core_unload_override();
|
||||||
|
pretro_set_environment(rarch_environment_cb);
|
||||||
|
}
|
||||||
|
|
||||||
uninit_libretro_sym();
|
uninit_libretro_sym();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1886,11 +1899,13 @@ static bool init_core(void)
|
|||||||
driver_t *driver = driver_get_ptr();
|
driver_t *driver = driver_get_ptr();
|
||||||
global_t *global = global_get_ptr();
|
global_t *global = global_get_ptr();
|
||||||
|
|
||||||
//needs testing for regressions
|
if (config_load_override())
|
||||||
|
global->overrides_active = true;
|
||||||
|
else
|
||||||
|
global->overrides_active = false;
|
||||||
|
|
||||||
pretro_set_environment(rarch_environment_cb);
|
pretro_set_environment(rarch_environment_cb);
|
||||||
|
|
||||||
if (!config_load_override())
|
|
||||||
RARCH_ERR("Error loading override files\n");
|
|
||||||
if (!config_load_remap())
|
if (!config_load_remap())
|
||||||
RARCH_ERR("Error loading remap files\n");
|
RARCH_ERR("Error loading remap files\n");
|
||||||
|
|
||||||
|
@ -144,6 +144,8 @@ typedef struct global
|
|||||||
bool has_set_bps_pref;
|
bool has_set_bps_pref;
|
||||||
bool has_set_ips_pref;
|
bool has_set_ips_pref;
|
||||||
|
|
||||||
|
bool overrides_active;
|
||||||
|
|
||||||
/* Config associated with global "default" config. */
|
/* Config associated with global "default" config. */
|
||||||
char config_path[PATH_MAX_LENGTH];
|
char config_path[PATH_MAX_LENGTH];
|
||||||
char append_config_path[PATH_MAX_LENGTH];
|
char append_config_path[PATH_MAX_LENGTH];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user