mirror of
https://github.com/libretro/RetroArch
synced 2025-04-01 13:20:43 +00:00
further refinement of the netplay workflow
This commit is contained in:
parent
ea0202a39d
commit
1de95c6413
@ -3464,15 +3464,9 @@ finish:
|
|||||||
sizeof(struct netplay_room));
|
sizeof(struct netplay_room));
|
||||||
|
|
||||||
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, file_list);
|
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, file_list);
|
||||||
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
|
|
||||||
{
|
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) &&
|
||||||
menu_entries_append_enum(file_list,
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER, NULL))
|
||||||
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);
|
|
||||||
}
|
|
||||||
else if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER_ENABLED, NULL))
|
|
||||||
{
|
{
|
||||||
menu_entries_append_enum(file_list,
|
menu_entries_append_enum(file_list,
|
||||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST),
|
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST),
|
||||||
@ -3480,7 +3474,9 @@ finish:
|
|||||||
MENU_ENUM_LABEL_NETPLAY_DISCONNECT,
|
MENU_ENUM_LABEL_NETPLAY_DISCONNECT,
|
||||||
MENU_SETTING_ACTION, 0, 0);
|
MENU_SETTING_ACTION, 0, 0);
|
||||||
}
|
}
|
||||||
else
|
else if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) &&
|
||||||
|
!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER, NULL) &&
|
||||||
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_CONNECTED, NULL))
|
||||||
{
|
{
|
||||||
menu_entries_append_enum(file_list,
|
menu_entries_append_enum(file_list,
|
||||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_DISCONNECT),
|
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_DISCONNECT),
|
||||||
@ -3488,6 +3484,14 @@ finish:
|
|||||||
MENU_ENUM_LABEL_NETPLAY_DISCONNECT,
|
MENU_ENUM_LABEL_NETPLAY_DISCONNECT,
|
||||||
MENU_SETTING_ACTION, 0, 0);
|
MENU_SETTING_ACTION, 0, 0);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
menu_entries_append_enum(file_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);
|
||||||
|
}
|
||||||
|
|
||||||
menu_entries_append_enum(file_list,
|
menu_entries_append_enum(file_list,
|
||||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS),
|
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS),
|
||||||
|
@ -3128,15 +3128,8 @@ static int menu_displaylist_parse_netplay_room_list(
|
|||||||
|
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
|
|
||||||
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
|
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) &&
|
||||||
{
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER, NULL))
|
||||||
menu_entries_append_enum(info->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);
|
|
||||||
}
|
|
||||||
else if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER_ENABLED, NULL))
|
|
||||||
{
|
{
|
||||||
menu_entries_append_enum(info->list,
|
menu_entries_append_enum(info->list,
|
||||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST),
|
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST),
|
||||||
@ -3144,7 +3137,9 @@ static int menu_displaylist_parse_netplay_room_list(
|
|||||||
MENU_ENUM_LABEL_NETPLAY_DISCONNECT,
|
MENU_ENUM_LABEL_NETPLAY_DISCONNECT,
|
||||||
MENU_SETTING_ACTION, 0, 0);
|
MENU_SETTING_ACTION, 0, 0);
|
||||||
}
|
}
|
||||||
else
|
else if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) &&
|
||||||
|
!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER, NULL) &&
|
||||||
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_CONNECTED, NULL))
|
||||||
{
|
{
|
||||||
menu_entries_append_enum(info->list,
|
menu_entries_append_enum(info->list,
|
||||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_DISCONNECT),
|
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_DISCONNECT),
|
||||||
@ -3152,6 +3147,14 @@ static int menu_displaylist_parse_netplay_room_list(
|
|||||||
MENU_ENUM_LABEL_NETPLAY_DISCONNECT,
|
MENU_ENUM_LABEL_NETPLAY_DISCONNECT,
|
||||||
MENU_SETTING_ACTION, 0, 0);
|
MENU_SETTING_ACTION, 0, 0);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
menu_entries_append_enum(info->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);
|
||||||
|
}
|
||||||
|
|
||||||
menu_entries_append_enum(info->list,
|
menu_entries_append_enum(info->list,
|
||||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS),
|
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS),
|
||||||
|
@ -40,7 +40,8 @@ enum rarch_netplay_ctl_state
|
|||||||
RARCH_NETPLAY_CTL_ENABLE_CLIENT,
|
RARCH_NETPLAY_CTL_ENABLE_CLIENT,
|
||||||
RARCH_NETPLAY_CTL_DISABLE,
|
RARCH_NETPLAY_CTL_DISABLE,
|
||||||
RARCH_NETPLAY_CTL_IS_ENABLED,
|
RARCH_NETPLAY_CTL_IS_ENABLED,
|
||||||
RARCH_NETPLAY_CTL_IS_SERVER_ENABLED,
|
RARCH_NETPLAY_CTL_IS_SERVER,
|
||||||
|
RARCH_NETPLAY_CTL_IS_CONNECTED,
|
||||||
RARCH_NETPLAY_CTL_IS_DATA_INITED,
|
RARCH_NETPLAY_CTL_IS_DATA_INITED,
|
||||||
RARCH_NETPLAY_CTL_PAUSE,
|
RARCH_NETPLAY_CTL_PAUSE,
|
||||||
RARCH_NETPLAY_CTL_UNPAUSE,
|
RARCH_NETPLAY_CTL_UNPAUSE,
|
||||||
|
@ -1124,10 +1124,13 @@ static void netplay_toggle_play_spectate(netplay_t *netplay)
|
|||||||
bool netplay_disconnect(netplay_t *netplay)
|
bool netplay_disconnect(netplay_t *netplay)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (!netplay)
|
if (!netplay)
|
||||||
return true;
|
return true;
|
||||||
for (i = 0; i < netplay->connections_size; i++)
|
for (i = 0; i < netplay->connections_size; i++)
|
||||||
netplay_hangup(netplay, &netplay->connections[i]);
|
netplay_hangup(netplay, &netplay->connections[i]);
|
||||||
|
|
||||||
|
deinit_netplay();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1137,6 +1140,7 @@ void deinit_netplay(void)
|
|||||||
{
|
{
|
||||||
netplay_free(netplay_data);
|
netplay_free(netplay_data);
|
||||||
netplay_enabled = false;
|
netplay_enabled = false;
|
||||||
|
netplay_is_client = false;
|
||||||
is_mitm = false;
|
is_mitm = false;
|
||||||
}
|
}
|
||||||
netplay_data = NULL;
|
netplay_data = NULL;
|
||||||
@ -1271,11 +1275,13 @@ bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data)
|
|||||||
ret = false;
|
ret = false;
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
case RARCH_NETPLAY_CTL_IS_SERVER_ENABLED:
|
case RARCH_NETPLAY_CTL_IS_SERVER:
|
||||||
ret = netplay_enabled && !netplay_is_client;
|
ret = netplay_enabled && !netplay_is_client;
|
||||||
RARCH_LOG("TEST: %d = %d && %d", ret, netplay_enabled, netplay_is_client);
|
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
case RARCH_NETPLAY_CTL_IS_CONNECTED:
|
||||||
|
ret = false;
|
||||||
|
goto done;
|
||||||
default:
|
default:
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -1292,9 +1298,11 @@ bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data)
|
|||||||
goto done;
|
goto done;
|
||||||
case RARCH_NETPLAY_CTL_IS_ENABLED:
|
case RARCH_NETPLAY_CTL_IS_ENABLED:
|
||||||
goto done;
|
goto done;
|
||||||
case RARCH_NETPLAY_CTL_IS_SERVER_ENABLED:
|
case RARCH_NETPLAY_CTL_IS_SERVER:
|
||||||
ret = netplay_enabled && !netplay_is_client;
|
ret = netplay_enabled && !netplay_is_client;
|
||||||
RARCH_LOG("TEST: %d = %d && %d", ret, netplay_enabled, netplay_is_client);
|
goto done;
|
||||||
|
case RARCH_NETPLAY_CTL_IS_CONNECTED:
|
||||||
|
ret = netplay_data->is_connected;
|
||||||
goto done;
|
goto done;
|
||||||
case RARCH_NETPLAY_CTL_POST_FRAME:
|
case RARCH_NETPLAY_CTL_POST_FRAME:
|
||||||
netplay_post_frame(netplay_data);
|
netplay_post_frame(netplay_data);
|
||||||
|
@ -450,6 +450,7 @@ static void netplay_handshake_ready(netplay_t *netplay, struct netplay_connectio
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
netplay->is_connected = true;
|
||||||
snprintf(msg, sizeof(msg), "%s: \"%s\"",
|
snprintf(msg, sizeof(msg), "%s: \"%s\"",
|
||||||
msg_hash_to_str(MSG_CONNECTED_TO),
|
msg_hash_to_str(MSG_CONNECTED_TO),
|
||||||
connection->nick);
|
connection->nick);
|
||||||
|
@ -423,6 +423,7 @@ netplay_t *netplay_new(void *direct_host, const char *server, uint16_t port,
|
|||||||
netplay->connected_players = 0;
|
netplay->connected_players = 0;
|
||||||
netplay->player_max = 1;
|
netplay->player_max = 1;
|
||||||
netplay->is_server = (direct_host == NULL && server == NULL);
|
netplay->is_server = (direct_host == NULL && server == NULL);
|
||||||
|
netplay->is_connected = false;;
|
||||||
netplay->nat_traversal = netplay->is_server ? nat_traversal : false;
|
netplay->nat_traversal = netplay->is_server ? nat_traversal : false;
|
||||||
netplay->stateless_mode = stateless_mode;
|
netplay->stateless_mode = stateless_mode;
|
||||||
netplay->check_frames = check_frames;
|
netplay->check_frames = check_frames;
|
||||||
|
@ -111,6 +111,7 @@ void netplay_hangup(netplay_t *netplay, struct netplay_connection *connection)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
dmsg = msg_hash_to_str(MSG_NETPLAY_CLIENT_HANGUP);
|
dmsg = msg_hash_to_str(MSG_NETPLAY_CLIENT_HANGUP);
|
||||||
|
netplay->is_connected = false;
|
||||||
}
|
}
|
||||||
RARCH_LOG("%s\n", dmsg);
|
RARCH_LOG("%s\n", dmsg);
|
||||||
runloop_msg_queue_push(dmsg, 1, 180, false);
|
runloop_msg_queue_push(dmsg, 1, 180, false);
|
||||||
|
@ -330,6 +330,9 @@ struct netplay
|
|||||||
/* Are we the server? */
|
/* Are we the server? */
|
||||||
bool is_server;
|
bool is_server;
|
||||||
|
|
||||||
|
/* Are we the connected? */
|
||||||
|
bool is_connected;
|
||||||
|
|
||||||
/* Our nickname */
|
/* Our nickname */
|
||||||
char nick[NETPLAY_NICK_LEN];
|
char nick[NETPLAY_NICK_LEN];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user