From 5574e00ae37357b8e47b965a3eb1d04b07683cb1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 3 Sep 2014 05:59:16 +0200 Subject: [PATCH] (Menu/General) Refactor rarch_defer_core --- frontend/menu/backend/menu_common_backend.c | 13 +++++++++++-- frontend/menu/menu_common.c | 16 ++-------------- frontend/menu/menu_common.h | 5 +++-- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/frontend/menu/backend/menu_common_backend.c b/frontend/menu/backend/menu_common_backend.c index 617704de81..a23e71aef9 100644 --- a/frontend/menu/backend/menu_common_backend.c +++ b/frontend/menu/backend/menu_common_backend.c @@ -1947,12 +1947,21 @@ static int menu_action_ok(const char *dir, { if (driver.menu->defer_core) { - int ret = menu_defer_core(driver.menu->core_info, dir, path, - driver.menu->deferred_path, + const core_info_t *info = NULL; + int ret = rarch_defer_core(info, driver.menu->core_info, + dir, path, driver.menu->deferred_path, sizeof(driver.menu->deferred_path)); if (ret == -1) { + strlcpy(g_extern.fullpath, driver.menu->deferred_path, + sizeof(g_extern.fullpath)); + + if (path_file_exists(info->path)) + strlcpy(g_settings.libretro, info->path, + sizeof(g_settings.libretro)); + + rarch_main_command(RARCH_CMD_LOAD_CONTENT); rarch_main_command(RARCH_CMD_LOAD_CORE); menu_flush_stack_type(driver.menu->menu_stack,MENU_SETTINGS); driver.menu->msg_force = true; diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index dd3f76b9d0..1831114498 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -57,10 +57,10 @@ void menu_update_system_info(menu_handle_t *menu, bool *load_no_content) /* When selection is presented back, returns 0. * If it can make a decision right now, returns -1. */ -int menu_defer_core(core_info_list_t *core_info, const char *dir, +int rarch_defer_core(const core_info_t *info, + core_info_list_t *core_info, const char *dir, const char *path, char *deferred_path, size_t sizeof_deferred_path) { - const core_info_t *info = NULL; size_t supported = 0; fill_pathname_join(deferred_path, dir, path, sizeof_deferred_path); @@ -71,19 +71,7 @@ int menu_defer_core(core_info_list_t *core_info, const char *dir, /* Can make a decision right now. */ if (supported == 1) - { - strlcpy(g_extern.fullpath, deferred_path, sizeof(g_extern.fullpath)); - - if (path_file_exists(info->path)) - strlcpy(g_settings.libretro, info->path, sizeof(g_settings.libretro)); - -#ifdef HAVE_DYNAMIC - g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME); -#else - rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)g_extern.fullpath); -#endif return -1; - } return 0; } diff --git a/frontend/menu/menu_common.h b/frontend/menu/menu_common.h index 5775840f43..b465869d94 100644 --- a/frontend/menu/menu_common.h +++ b/frontend/menu/menu_common.h @@ -184,8 +184,9 @@ bool menu_replace_config(const char *path); bool menu_save_new_config(void); -int menu_defer_core(core_info_list_t *data, const char *dir, - const char *path, char *deferred_path, size_t sizeof_deferred_path); +int rarch_defer_core(const core_info_t *info, core_info_list_t *data, + const char *dir, const char *path, char *deferred_path, + size_t sizeof_deferred_path); void menu_update_system_info(menu_handle_t *menu, bool *load_no_content);