diff --git a/frontend/drivers/platform_switch.c b/frontend/drivers/platform_switch.c index dc9efb3f42..fed60fe5d5 100644 --- a/frontend/drivers/platform_switch.c +++ b/frontend/drivers/platform_switch.c @@ -44,6 +44,10 @@ #ifdef HAVE_MENU #include "../../menu/menu_driver.h" #endif + +#if defined(HAVE_LIBNX) && defined(HAVE_NETWORKING) +#include "../../network/netplay/netplay.h" +#endif #endif #ifdef HAVE_LIBNX @@ -301,41 +305,54 @@ static void frontend_switch_deinit(void *data) #ifdef HAVE_LIBNX static void frontend_switch_exec(const char *path, bool should_load_game) { - char game_path[PATH_MAX-4]; - game_path[0] = '\0'; + if (!string_is_empty(path)) + { + char args[PATH_MAX]; + + strlcpy(args, path, sizeof(args)); #ifndef IS_SALAMANDER - if (should_load_game && !path_is_empty(RARCH_PATH_CONTENT)) - strlcpy(game_path, path_get(RARCH_PATH_CONTENT), sizeof(game_path)); -#endif - - if (path && path[0]) - { -#ifdef IS_SALAMANDER - struct stat sbuff; - bool file_exists = stat(path, &sbuff) == 0; - - if (!file_exists) - { - char core_path[PATH_MAX]; - - /* find first valid core and load it if the target core doesnt exist */ - get_first_valid_core(&core_path[0], PATH_MAX); - - if (core_path[0] == '\0') - svcExitProcess(); - } -#endif - char *arg_buffer = (char *)malloc(PATH_MAX); if (should_load_game) - snprintf(arg_buffer, PATH_MAX, "%s \"%s\"", path, game_path); - else { - arg_buffer[0] = '\0'; - strlcpy(arg_buffer, path, PATH_MAX); - } + const char *content = path_get(RARCH_PATH_CONTENT); +#ifdef HAVE_NETWORKING + char *arg_data[NETPLAY_FORK_MAX_ARGS]; - envSetNextLoad(path, arg_buffer); + if (netplay_driver_ctl(RARCH_NETPLAY_CTL_GET_FORK_ARGS, + (void*)arg_data)) + { + char buf[PATH_MAX]; + const char **arg = arg_data; + + do + { + snprintf(buf, sizeof(buf), " \"%s\"", *arg); + strlcat(args, buf, sizeof(args)); + } + while (*(++arg)); + } + else +#endif + if (!string_is_empty(content)) + snprintf(args, sizeof(args), "%s \"%s\"", path, content); + } +#else + { + struct stat sbuff; + + if (stat(path, &sbuff)) + { + char core_path[PATH_MAX]; + + get_first_valid_core(core_path, sizeof(core_path)); + + if (string_is_empty(core_path)) + svcExitProcess(); + } + } +#endif + + envSetNextLoad(path, args); } }