(Netplay/3DS) Launch compatibility patch (#14203)

This commit is contained in:
Cthulhu-throwaway 2022-07-25 02:08:06 -03:00 committed by GitHub
parent 153f77d764
commit 262b0601e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,6 +56,10 @@
#ifdef HAVE_MENU
#include "../../menu/menu_driver.h"
#endif
#ifdef HAVE_NETWORKING
#include "../../network/netplay/netplay.h"
#endif
#endif
static enum frontend_fork ctr_fork_mode = FRONTEND_FORK_NONE;
@ -199,59 +203,63 @@ static void frontend_ctr_deinit(void* data)
#endif
}
static void frontend_ctr_exec(const char* path, bool should_load_game)
static void frontend_ctr_exec(const char *path, bool should_load_game)
{
#ifndef IS_SALAMANDER
#ifdef HAVE_NETWORKING
const char *arg_data[NETPLAY_FORK_MAX_ARGS + 1];
#else
const char *arg_data[3];
#endif
char game_path[PATH_MAX];
const char* arg_data[3];
errorConf error_dialog;
char error_string[200 + PATH_MAX];
int args = 0;
int error = 0;
#else
const char *arg_data[2];
#endif
DEBUG_VAR(path);
DEBUG_STR(path);
game_path[0] = '\0';
arg_data[0] = NULL;
arg_data[args] = elf_path_cst;
arg_data[args + 1] = NULL;
args++;
arg_data[0] = elf_path_cst;
arg_data[1] = NULL;
#ifndef IS_SALAMANDER
if (should_load_game && !path_is_empty(RARCH_PATH_CONTENT))
if (should_load_game)
{
strlcpy(game_path, path_get(RARCH_PATH_CONTENT), sizeof(game_path));
arg_data[args] = game_path;
arg_data[args + 1] = NULL;
args++;
const char *content = path_get(RARCH_PATH_CONTENT);
#ifdef HAVE_NETWORKING
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_GET_FORK_ARGS,
(void*)&arg_data[1]))
#endif
if (!string_is_empty(content))
{
strlcpy(game_path, content, sizeof(game_path));
arg_data[1] = game_path;
arg_data[2] = NULL;
}
}
#endif
if (path && path[0])
if (!string_is_empty(path))
{
#ifdef IS_SALAMANDER
struct stat sbuff;
bool file_exists = stat(path, &sbuff) == 0;
if (!file_exists)
if (stat(path, &sbuff))
{
char core_path[PATH_MAX];
core_path[0] = '\0';
get_first_valid_core(core_path, sizeof(core_path));
/* find first valid core and load it if the target core doesnt exist */
get_first_valid_core(&core_path[0], sizeof(core_path));
if (core_path[0] == '\0')
{
if (string_is_empty(core_path))
error_and_quit("There are no cores installed, install a core to continue.");
}
}
#endif
if (envIsHomebrew())
{
exec_3dsx_no_path_in_args(path, arg_data);
}
else
{
RARCH_WARN("\n");
@ -267,10 +275,13 @@ static void frontend_ctr_exec(const char* path, bool should_load_game)
}
/* couldnt launch new core, but context
is corrupt so we have to quit */
snprintf(error_string, sizeof(error_string),
"Can't launch core:%s", path);
error_and_quit(error_string);
is corrupt so we have to quit */
{
char error[PATH_MAX + 32];
snprintf(error, sizeof(error), "Can't launch core: %s", path);
error_and_quit(error);
}
}
}