netplay: always use configured port instead of hardcoding, and don't ask for IP address if one is already set. fixes #6626

This commit is contained in:
Brad Parker 2018-06-27 23:03:27 -04:00
parent 15924e5d9b
commit 04311695aa
2 changed files with 22 additions and 11 deletions

View File

@ -2516,17 +2516,18 @@ TODO: Add a setting for these tweaks */
/* buf is expected to be address|port */ /* buf is expected to be address|port */
char *buf = (char *)data; char *buf = (char *)data;
static struct string_list *hostname = NULL; static struct string_list *hostname = NULL;
settings_t *settings = config_get_ptr();
hostname = string_split(buf, "|"); hostname = string_split(buf, "|");
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
RARCH_LOG("[netplay] connecting to %s:%d\n", RARCH_LOG("[netplay] connecting to %s:%d\n",
hostname->elems[0].data, !string_is_empty(hostname->elems[1].data) hostname->elems[0].data, !string_is_empty(hostname->elems[1].data)
? atoi(hostname->elems[1].data) : 55435); ? atoi(hostname->elems[1].data) : settings->uints.netplay_port);
if (!init_netplay(NULL, hostname->elems[0].data, if (!init_netplay(NULL, hostname->elems[0].data,
!string_is_empty(hostname->elems[1].data) !string_is_empty(hostname->elems[1].data)
? atoi(hostname->elems[1].data) : 55435)) ? atoi(hostname->elems[1].data) : settings->uints.netplay_port))
{ {
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
string_list_free(hostname); string_list_free(hostname);
@ -2549,17 +2550,18 @@ TODO: Add a setting for these tweaks */
/* buf is expected to be address|port */ /* buf is expected to be address|port */
char *buf = (char *)data; char *buf = (char *)data;
static struct string_list *hostname = NULL; static struct string_list *hostname = NULL;
settings_t *settings = config_get_ptr();
hostname = string_split(buf, "|"); hostname = string_split(buf, "|");
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
RARCH_LOG("[netplay] connecting to %s:%d\n", RARCH_LOG("[netplay] connecting to %s:%d\n",
hostname->elems[0].data, !string_is_empty(hostname->elems[1].data) hostname->elems[0].data, !string_is_empty(hostname->elems[1].data)
? atoi(hostname->elems[1].data) : 55435); ? atoi(hostname->elems[1].data) : settings->uints.netplay_port);
if (!init_netplay_deferred(hostname->elems[0].data, if (!init_netplay_deferred(hostname->elems[0].data,
!string_is_empty(hostname->elems[1].data) !string_is_empty(hostname->elems[1].data)
? atoi(hostname->elems[1].data) : 55435)) ? atoi(hostname->elems[1].data) : settings->uints.netplay_port))
{ {
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
string_list_free(hostname); string_list_free(hostname);

View File

@ -4148,19 +4148,28 @@ static int action_ok_netplay_enable_client(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx) const char *label, unsigned type, size_t idx, size_t entry_idx)
{ {
#ifdef HAVE_NETWORKING #ifdef HAVE_NETWORKING
settings_t *settings = config_get_ptr();
menu_input_ctx_line_t line; menu_input_ctx_line_t line;
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL))
generic_action_ok_command(CMD_EVENT_NETPLAY_DEINIT); generic_action_ok_command(CMD_EVENT_NETPLAY_DEINIT);
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL); netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL);
line.label = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS); if (!string_is_empty(settings->paths.netplay_server))
line.label_setting = "no_setting"; {
line.type = 0; action_ok_netplay_enable_client_hostname_cb(NULL, settings->paths.netplay_server);
line.idx = 0;
line.cb = action_ok_netplay_enable_client_hostname_cb;
if (menu_input_dialog_start(&line))
return 0; return 0;
}
else
{
line.label = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS);
line.label_setting = "no_setting";
line.type = 0;
line.idx = 0;
line.cb = action_ok_netplay_enable_client_hostname_cb;
if (menu_input_dialog_start(&line))
return 0;
}
#endif #endif
return -1; return -1;
} }