diff --git a/frontend/frontend.c b/frontend/frontend.c index f1d3e50d98..80016b7db6 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -295,12 +295,7 @@ returntype main_entry(signature()) char *rarch_argv[MAX_ARGS] = {NULL}; char *argv_copy[MAX_ARGS] = {NULL}; - wrap_args = (struct rarch_main_wrap*)calloc(1, sizeof(*wrap_args)); - rarch_assert(wrap_args); - driver.frontend_ctx = (frontend_ctx_driver_t*)frontend_ctx_init_first(); - rarch_argv_ptr = (char**)argv; - rarch_argc_ptr = (int*)&argc; if (!driver.frontend_ctx) RARCH_WARN("Frontend context could not be initialized.\n"); @@ -311,6 +306,12 @@ returntype main_entry(signature()) rarch_main_clear_state(); rarch_init_msg_queue(); + wrap_args = (struct rarch_main_wrap*)calloc(1, sizeof(*wrap_args)); + rarch_assert(wrap_args); + + rarch_argv_ptr = (char**)argv; + rarch_argc_ptr = (int*)&argc; + if (driver.frontend_ctx && driver.frontend_ctx->environment_get) { driver.frontend_ctx->environment_get(rarch_argc_ptr, rarch_argv_ptr, args, wrap_args); @@ -336,15 +337,15 @@ returntype main_entry(signature()) path_mkdir(g_defaults.sram_dir); if (*g_defaults.system_dir) path_mkdir(g_defaults.system_dir); + } - if (wrap_args->touched) - { - g_extern.verbosity = true; - rarch_main_init_wrap(wrap_args, &rarch_argc, rarch_argv); - memcpy(argv_copy, rarch_argv, sizeof(rarch_argv)); - rarch_argv_ptr = (char**)rarch_argv; - rarch_argc_ptr = (int*)&rarch_argc; - } + if (wrap_args->touched) + { + g_extern.verbosity = true; + rarch_main_init_wrap(wrap_args, &rarch_argc, rarch_argv); + memcpy(argv_copy, rarch_argv, sizeof(rarch_argv)); + rarch_argv_ptr = (char**)rarch_argv; + rarch_argc_ptr = (int*)&rarch_argc; } if (g_extern.main_is_init) diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index 92b47f35d0..c0014f1e2a 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -179,6 +179,20 @@ static void menu_update_libretro_info(menu_handle_t *menu) menu_update_system_info(menu, NULL); } +static void menu_environment_get(int *argc, char *argv[], void *args, void *params_data) +{ + struct rarch_main_wrap *wrap_args = (struct rarch_main_wrap*)params_data; + + wrap_args->no_rom = driver.menu->load_no_rom; + wrap_args->verbose = g_extern.verbosity; + wrap_args->config_path = *g_extern.config_path ? g_extern.config_path : NULL; + wrap_args->sram_path = *g_extern.savefile_dir ? g_extern.savefile_dir : NULL; + wrap_args->state_path = *g_extern.savestate_dir ? g_extern.savestate_dir : NULL; + wrap_args->rom_path = *g_extern.fullpath ? g_extern.fullpath : NULL; + wrap_args->libretro_path = *g_settings.libretro ? g_settings.libretro : NULL; + wrap_args->touched = true; +} + bool load_menu_game(void) { int *rarch_argc_ptr; @@ -194,14 +208,7 @@ bool load_menu_game(void) wrap_args = (struct rarch_main_wrap*)calloc(1, sizeof(*wrap_args)); rarch_assert(wrap_args); - wrap_args->no_rom = driver.menu->load_no_rom; - wrap_args->verbose = g_extern.verbosity; - wrap_args->config_path = *g_extern.config_path ? g_extern.config_path : NULL; - wrap_args->sram_path = *g_extern.savefile_dir ? g_extern.savefile_dir : NULL; - wrap_args->state_path = *g_extern.savestate_dir ? g_extern.savestate_dir : NULL; - wrap_args->rom_path = *g_extern.fullpath ? g_extern.fullpath : NULL; - wrap_args->libretro_path = *g_settings.libretro ? g_settings.libretro : NULL; - wrap_args->touched = true; + menu_environment_get(rarch_argc_ptr, rarch_argv_ptr, NULL, wrap_args); if (wrap_args->touched) {