cut down some code duplication

This commit is contained in:
radius 2016-05-20 17:54:29 -05:00
parent dbb8cf7e32
commit 6b0c978acb
2 changed files with 18 additions and 13 deletions

View File

@ -1060,12 +1060,7 @@ static void command_event_deinit_core(bool reinit)
driver_ctl(RARCH_DRIVER_CTL_UNINIT, &flags); driver_ctl(RARCH_DRIVER_CTL_UNINIT, &flags);
} }
/* auto overrides: reload the original config */ command_event(CMD_EVENT_DISABLE_OVERRIDES, NULL);
if (runloop_ctl(RUNLOOP_CTL_IS_OVERRIDES_ACTIVE, NULL))
{
config_unload_override();
runloop_ctl(RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE, NULL);
}
} }
static void command_event_init_cheats(void) static void command_event_init_cheats(void)
@ -1266,6 +1261,16 @@ static bool command_event_init_core(enum rarch_core_type *data)
return true; return true;
} }
static void command_event_disable_overrides(void)
{
/* auto overrides: reload the original config */
if (runloop_ctl(RUNLOOP_CTL_IS_OVERRIDES_ACTIVE, NULL))
{
config_unload_override();
runloop_ctl(RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE, NULL);
}
}
static bool command_event_save_auto_state(void) static bool command_event_save_auto_state(void)
{ {
bool ret; bool ret;
@ -1715,12 +1720,8 @@ bool command_event(enum event_command cmd, void *data)
break; break;
case CMD_EVENT_UNLOAD_CORE: case CMD_EVENT_UNLOAD_CORE:
command_event(CMD_EVENT_AUTOSAVE_STATE, NULL); command_event(CMD_EVENT_AUTOSAVE_STATE, NULL);
/* auto overrides: reload the original config */ command_event(CMD_EVENT_DISABLE_OVERRIDES, NULL);
if (runloop_ctl(RUNLOOP_CTL_IS_OVERRIDES_ACTIVE, NULL))
{
config_unload_override();
runloop_ctl(RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE, NULL);
}
if (!rarch_task_push_content_load_default( if (!rarch_task_push_content_load_default(
NULL, NULL, NULL, NULL,
&content_info, &content_info,
@ -2300,6 +2301,9 @@ bool command_event(enum event_command cmd, void *data)
case CMD_EVENT_SET_FRAME_LIMIT: case CMD_EVENT_SET_FRAME_LIMIT:
runloop_ctl(RUNLOOP_CTL_SET_FRAME_LIMIT, NULL); runloop_ctl(RUNLOOP_CTL_SET_FRAME_LIMIT, NULL);
break; break;
case CMD_EVENT_DISABLE_OVERRIDES:
command_event_disable_overrides();
break;
case CMD_EVENT_NONE: case CMD_EVENT_NONE:
default: default:
return false; return false;

View File

@ -208,7 +208,8 @@ enum event_command
CMD_EVENT_FULLSCREEN_TOGGLE, CMD_EVENT_FULLSCREEN_TOGGLE,
CMD_EVENT_PERFCNT_REPORT_FRONTEND_LOG, CMD_EVENT_PERFCNT_REPORT_FRONTEND_LOG,
CMD_EVENT_VOLUME_UP, CMD_EVENT_VOLUME_UP,
CMD_EVENT_VOLUME_DOWN CMD_EVENT_VOLUME_DOWN,
CMD_EVENT_DISABLE_OVERRIDES
}; };
#ifdef HAVE_COMMAND #ifdef HAVE_COMMAND