From 8d4a64ab962d06cedff980447f7f3a1dbfaa2e22 Mon Sep 17 00:00:00 2001 From: Cthulhu-throwaway <96153783+Cthulhu-throwaway@users.noreply.github.com> Date: Tue, 26 Jul 2022 02:21:57 -0300 Subject: [PATCH] (Netplay) Disallow netplay start when content is not loaded for static core platforms (#14220) --- intl/msg_hash_us.h | 4 +++ menu/cbs/menu_cbs_ok.c | 17 ++++++++++--- msg_hash.h | 1 + retroarch.c | 7 ++++++ tasks/task_netplay_find_content.c | 41 +++++++++++++++++++++++-------- 5 files changed, 57 insertions(+), 13 deletions(-) diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 456d0185f7..6664ddba81 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -11487,6 +11487,10 @@ MSG_HASH( /* FIXME Should be MSG_ */ MENU_ENUM_LABEL_VALUE_NETPLAY_START_WHEN_LOADED, "Netplay will start when content is loaded." ) +MSG_HASH( + MSG_NETPLAY_NEED_CONTENT_LOADED, + "Content must be loaded before starting netplay." + ) MSG_HASH( /* FIXME Should be MSG_ */ MENU_ENUM_LABEL_VALUE_NETPLAY_LOAD_CONTENT_MANUALLY, "Couldn't find a suitable core or content file, load manually." diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index b558cd2cfa..cf78593afe 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -7367,6 +7367,7 @@ static void action_ok_netplay_enable_client_hostname_cb(void *userdata, { if (!task_push_netplay_content_reload(line)) { +#ifdef HAVE_DYNAMIC command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL); command_event(CMD_EVENT_NETPLAY_INIT_DIRECT_DEFERRED, (void*)line); @@ -7375,10 +7376,20 @@ static void action_ok_netplay_enable_client_hostname_cb(void *userdata, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_START_WHEN_LOADED), 1, 480, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); - } +#else + runloop_msg_queue_push( + msg_hash_to_str(MSG_NETPLAY_NEED_CONTENT_LOADED), + 1, 480, true, NULL, + MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); +#endif - menu_input_dialog_end(); - retroarch_menu_running_finished(false); + menu_input_dialog_end(); + } + else + { + menu_input_dialog_end(); + retroarch_menu_running_finished(false); + } } else menu_input_dialog_end(); diff --git a/msg_hash.h b/msg_hash.h index 5ae8523aef..3c0c1a1307 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -179,6 +179,7 @@ enum msg_hash_enums MSG_SETTING_DISK_IN_TRAY, MSG_FAILED_TO_SET_DISK, MSG_FAILED_TO_SET_INITIAL_DISK, + MSG_NETPLAY_NEED_CONTENT_LOADED, MSG_FAILED_TO_CONNECT_TO_CLIENT, MSG_FAILED_TO_CONNECT_TO_HOST, MSG_NETPLAY_HOST_FULL, diff --git a/retroarch.c b/retroarch.c index 3e34e0032c..7c4e48ea2d 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2876,6 +2876,7 @@ bool command_event(enum event_command cmd, void *data) { if (!task_push_netplay_content_reload(NULL)) { +#ifdef HAVE_DYNAMIC command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_SERVER, NULL); @@ -2883,6 +2884,12 @@ bool command_event(enum event_command cmd, void *data) msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_START_WHEN_LOADED), 1, 480, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); +#else + runloop_msg_queue_push( + msg_hash_to_str(MSG_NETPLAY_NEED_CONTENT_LOADED), + 1, 480, true, NULL, + MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); +#endif return false; } diff --git a/tasks/task_netplay_find_content.c b/tasks/task_netplay_find_content.c index e29ff23a93..4df90b58e1 100644 --- a/tasks/task_netplay_find_content.c +++ b/tasks/task_netplay_find_content.c @@ -471,15 +471,16 @@ static bool static_load(const char *core, const char *subsystem, if (!string_is_empty(subsystem)) { + const struct string_list *subsystem_content = + (const struct string_list*)content; + if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_ADD_FORK_ARG, ARG("--subsystem")) || !netplay_driver_ctl(RARCH_NETPLAY_CTL_ADD_FORK_ARG, ARG(subsystem))) goto failure; - if (content) + if (subsystem_content && subsystem_content->size > 0) { size_t i; - const struct string_list *subsystem_content = - (const struct string_list*)content; for (i = 0; i < subsystem_content->size; i++) { @@ -488,11 +489,28 @@ static bool static_load(const char *core, const char *subsystem, goto failure; } } +#ifdef HAVE_MENU + else + { + if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_ADD_FORK_ARG, ARG("--menu"))) + goto failure; + } +#endif } - else if (content) + else { - if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_ADD_FORK_ARG, ARG(content))) - goto failure; + if (content) + { + if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_ADD_FORK_ARG, ARG(content))) + goto failure; + } +#ifdef HAVE_MENU + else + { + if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_ADD_FORK_ARG, ARG("--menu"))) + goto failure; + } +#endif } if (!frontend_driver_set_fork(FRONTEND_FORK_CORE_WITH_ARGS)) @@ -688,14 +706,17 @@ static void task_netplay_crc_scan_callback(retro_task_t *task, content_clear_subsystem(); content_set_subsystem_by_name(data->current.subsystem); } -#else - if (static_load(data->core, data->current.subsystem, NULL, - data->hostname)) -#endif + runloop_msg_queue_push( msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_START_WHEN_LOADED), 1, 480, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); +#else + runloop_msg_queue_push( + msg_hash_to_str(MSG_NETPLAY_NEED_CONTENT_LOADED), + 1, 480, true, NULL, + MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); +#endif } else RARCH_WARN("[Lobby] Nothing to load.\n");