diff --git a/command.c b/command.c index 2d6c8deda6..6407f5072e 100644 --- a/command.c +++ b/command.c @@ -2263,56 +2263,47 @@ bool command_event(enum event_command cmd, void *data) break; /* init netplay via lobby when content is loaded */ case CMD_EVENT_NETPLAY_INIT_DIRECT: - { - char *buf = (char *)data; - settings_t *settings = config_get_ptr(); - - command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); - - /* new codepath, uses the same logic as init_deferred, expects - buf to be addres|port */ - RARCH_LOG("%s\n", buf); - if (strstr(buf, "|")) - { - static struct string_list *hostname = NULL; - hostname = string_split(buf, "|"); - RARCH_LOG("[netplay] connecting to %s:%d\n", - hostname->elems[0].data, atoi(hostname->elems[1].data)); - - if (!init_netplay(NULL, hostname->elems[0].data, - atoi(hostname->elems[1].data))) - { - command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); - string_list_free(hostname); - return false; - } - - string_list_free(hostname); - } - /* old codepath accessed via, netplay/scan local network - not sure how/if it works, it seems it doesn't */ - else if (!init_netplay(data, NULL, - settings->uints.netplay_port)) - { - command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); - return false; - } - } - break; - /* init netplay via lobby when content is notloaded */ - case CMD_EVENT_NETPLAY_INIT_DIRECT_DEFERRED: { /* buf is expected to be address|port */ - char *buf = (char *)data; + char *buf = (char *)data; static struct string_list *hostname = NULL; hostname = string_split(buf, "|"); command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); - RARCH_LOG("[netplay] connecting to %s:%d\n", - hostname->elems[0].data, atoi(hostname->elems[1].data)); - if (!init_netplay_deferred( - hostname->elems[0].data, atoi(hostname->elems[1].data))) + RARCH_LOG("[netplay] connecting to %s:%d\n", + hostname->elems[0].data, !string_is_empty(hostname->elems[1].data) + ? atoi(hostname->elems[1].data) : 55435); + + if (!init_netplay(NULL, hostname->elems[0].data, + !string_is_empty(hostname->elems[1].data) + ? atoi(hostname->elems[1].data) : 55435)) + { + command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); + string_list_free(hostname); + return false; + } + + string_list_free(hostname); + } + break; + /* init netplay via lobby when content is not loaded */ + case CMD_EVENT_NETPLAY_INIT_DIRECT_DEFERRED: + { + /* buf is expected to be address|port */ + char *buf = (char *)data; + static struct string_list *hostname = NULL; + hostname = string_split(buf, "|"); + + command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); + + RARCH_LOG("[netplay] connecting to %s:%d\n", + hostname->elems[0].data, !string_is_empty(hostname->elems[1].data) + ? atoi(hostname->elems[1].data) : 55435); + + if (!init_netplay_deferred(hostname->elems[0].data, + !string_is_empty(hostname->elems[1].data) + ? atoi(hostname->elems[1].data) : 55435)) { command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); string_list_free(hostname); diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 86af23eb4a..f80b10775f 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -2437,7 +2437,7 @@ MSG_HASH( MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_BOKEH, "Bokeh") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS, - "Refresh") + "Refresh Room List") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME, "Nickname: %s") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME_LAN, diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index b2600517f2..5ce11c18d0 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3273,31 +3273,31 @@ static int action_ok_netplay_connect_room(const char *path, command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL); - if (netplay_room_list[idx - 2].host_method == NETPLAY_HOST_METHOD_MITM) + if (netplay_room_list[idx - 3].host_method == NETPLAY_HOST_METHOD_MITM) { snprintf(tmp_hostname, sizeof(tmp_hostname), "%s|%d", - netplay_room_list[idx - 2].mitm_address, - netplay_room_list[idx - 2].mitm_port); + netplay_room_list[idx - 3].mitm_address, + netplay_room_list[idx - 3].mitm_port); } else { snprintf(tmp_hostname, sizeof(tmp_hostname), "%s|%d", - netplay_room_list[idx - 2].address, - netplay_room_list[idx - 2].port); + netplay_room_list[idx - 3].address, + netplay_room_list[idx - 3].port); } RARCH_LOG("Connecting to: %s with game: %s/%08x\n", tmp_hostname, - netplay_room_list[idx - 2].gamename, - netplay_room_list[idx - 2].gamecrc); + netplay_room_list[idx - 3].gamename, + netplay_room_list[idx - 3].gamecrc); - task_push_netplay_crc_scan(netplay_room_list[idx - 2].gamecrc, - netplay_room_list[idx - 2].gamename, - tmp_hostname, netplay_room_list[idx - 2].corename); + task_push_netplay_crc_scan(netplay_room_list[idx - 3].gamecrc, + netplay_room_list[idx - 3].gamename, + tmp_hostname, netplay_room_list[idx - 3].corename); #else return -1; @@ -3497,12 +3497,18 @@ void netplay_refresh_rooms_menu(file_list_t *list) else { menu_entries_append_enum(list, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST), - msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_ENABLE_HOST), - MENU_ENUM_LABEL_NETPLAY_ENABLE_HOST, - MENU_SETTING_ACTION, 0, 0); + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_HOST), + msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_ENABLE_HOST), + MENU_ENUM_LABEL_NETPLAY_ENABLE_HOST, + MENU_SETTING_ACTION, 0, 0); } + menu_entries_append_enum(list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_CLIENT), + msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_ENABLE_CLIENT), + MENU_ENUM_LABEL_NETPLAY_ENABLE_CLIENT, + MENU_SETTING_ACTION, 0, 0); + menu_entries_append_enum(list, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS), msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS), @@ -4171,11 +4177,26 @@ static void action_ok_netplay_enable_client_hostname_cb( void *ignore, const char *hostname) { char tmp_hostname[512]; + bool contentless = false; + bool is_inited = false; + + content_get_status(&contentless, &is_inited); if (hostname && hostname[0]) { strlcpy(tmp_hostname, hostname, sizeof(tmp_hostname)); - command_event(CMD_EVENT_NETPLAY_INIT, (void *) tmp_hostname); + if (!is_inited) + { + command_event(CMD_EVENT_NETPLAY_INIT_DIRECT_DEFERRED, (void *) tmp_hostname); + runloop_msg_queue_push( + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_START_WHEN_LOADED), + 1, 480, true); + } + else + { + command_event(CMD_EVENT_NETPLAY_INIT_DIRECT, (void *) tmp_hostname); + generic_action_ok_command(CMD_EVENT_RESUME); + } } else { @@ -4193,46 +4214,23 @@ static int action_ok_netplay_enable_client(const char *path, { #ifdef HAVE_NETWORKING settings_t *settings = config_get_ptr(); - bool contentless = false; - bool is_inited = false; - - content_get_status(&contentless, &is_inited); if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL); - /* If we haven't yet started, this will load on its own */ - if (!is_inited) - { - runloop_msg_queue_push( - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_START_WHEN_LOADED), - 1, 480, true); - return 0; - } - /* If no host was specified in the config, ask for one */ - if (!settings->paths.netplay_server[0]) - { - menu_input_ctx_line_t line; - memset(&line, 0, sizeof(line)); - line.label = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS); - line.label_setting = "no_setting"; - line.cb = action_ok_netplay_enable_client_hostname_cb; - if (!menu_input_dialog_start(&line)) - return -1; - return 0; - } - - /* Enable Netplay itself */ - if (!command_event(CMD_EVENT_NETPLAY_INIT, NULL)) + menu_input_ctx_line_t line; + memset(&line, 0, sizeof(line)); + line.label = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS); + line.label_setting = "no_setting"; + line.cb = action_ok_netplay_enable_client_hostname_cb; + if (!menu_input_dialog_start(&line)) return -1; - - return generic_action_ok_command(CMD_EVENT_RESUME); + return 0; #else return -1; - #endif } diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 2a9d754631..ced52beb67 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -354,14 +354,14 @@ static int action_bind_sublabel_netplay_room( return 0; snprintf(s,len, "%s (%s)\n%s (%08x)\nType: %s (%s)", - netplay_room_list[i - 2].corename, netplay_room_list[i - 2].coreversion, - netplay_room_list[i - 2].gamename, netplay_room_list[i - 2].gamecrc, - netplay_room_list[i - 2].lan ? "LAN game" : - (netplay_room_list[i - 2].host_method == NETPLAY_HOST_METHOD_MITM ? - "MITM game" : "Lobby game"), netplay_room_list[i - 2].address); + netplay_room_list[i - 3].corename, netplay_room_list[i - 3].coreversion, + netplay_room_list[i - 3].gamename, netplay_room_list[i - 3].gamecrc, + netplay_room_list[i - 3].lan ? "LAN game" : + (netplay_room_list[i - 3].host_method == NETPLAY_HOST_METHOD_MITM ? + "MITM game" : "Lobby game"), netplay_room_list[i - 3].address); #if 0 - strlcpy(s, netplay_room_list[i - 2].corename, len); + strlcpy(s, netplay_room_list[i - 3].corename, len); #endif return 0; }