mirror of
https://github.com/libretro/RetroArch
synced 2025-03-17 10:21:26 +00:00
commit
0f91cf67fc
@ -3348,6 +3348,42 @@ void netplay_refresh_rooms_menu(file_list_t *list)
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
|
||||
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, list);
|
||||
|
||||
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) &&
|
||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER, NULL))
|
||||
{
|
||||
menu_entries_append_enum(list,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_DISCONNECT),
|
||||
MENU_ENUM_LABEL_NETPLAY_DISCONNECT,
|
||||
MENU_SETTING_ACTION, 0, 0);
|
||||
}
|
||||
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(list,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_DISCONNECT),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_DISCONNECT),
|
||||
MENU_ENUM_LABEL_NETPLAY_DISCONNECT,
|
||||
MENU_SETTING_ACTION, 0, 0);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
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),
|
||||
MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS,
|
||||
MENU_SETTING_ACTION, 0, 0);
|
||||
|
||||
if (netplay_room_count != 0)
|
||||
{
|
||||
RARCH_LOG ("Found %d rooms...\n", netplay_room_count);
|
||||
@ -3463,38 +3499,6 @@ finish:
|
||||
calloc(netplay_room_count + lan_room_count,
|
||||
sizeof(struct netplay_room));
|
||||
|
||||
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, file_list);
|
||||
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
|
||||
{
|
||||
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);
|
||||
}
|
||||
else if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER_ENABLED, NULL))
|
||||
{
|
||||
menu_entries_append_enum(file_list,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_DISCONNECT),
|
||||
MENU_ENUM_LABEL_NETPLAY_DISCONNECT,
|
||||
MENU_SETTING_ACTION, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu_entries_append_enum(file_list,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_DISCONNECT),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_DISCONNECT),
|
||||
MENU_ENUM_LABEL_NETPLAY_DISCONNECT,
|
||||
MENU_SETTING_ACTION, 0, 0);
|
||||
}
|
||||
|
||||
menu_entries_append_enum(file_list,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS),
|
||||
MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS,
|
||||
MENU_SETTING_ACTION, 0, 0);
|
||||
|
||||
for (i = 0; i < netplay_room_count; i++)
|
||||
memcpy(&netplay_room_list[i], netplay_room_get(i), sizeof(netplay_room_list[i]));
|
||||
|
||||
@ -3510,10 +3514,19 @@ finish:
|
||||
sizeof(netplay_room_list[i].nickname));
|
||||
|
||||
address = &host->addr;
|
||||
if (address->sa_family == AF_INET)
|
||||
{
|
||||
struct sockaddr_in *sin = (struct sockaddr_in *) address;
|
||||
inet_ntop(AF_INET, &sin->sin_addr,
|
||||
netplay_room_list[i].address, INET6_ADDRSTRLEN);
|
||||
}
|
||||
else if (address->sa_family == AF_INET6)
|
||||
{
|
||||
struct sockaddr_in6 *sin = (struct sockaddr_in6 *) address;
|
||||
inet_ntop(AF_INET6, &sin->sin6_addr,
|
||||
netplay_room_list[i].address, INET6_ADDRSTRLEN);
|
||||
}
|
||||
|
||||
strlcpy(netplay_room_list[i].address,
|
||||
inet_ntoa(((struct sockaddr_in*)(address))->sin_addr),
|
||||
sizeof(netplay_room_list[i].address));
|
||||
strlcpy(netplay_room_list[i].corename,
|
||||
host->core,
|
||||
sizeof(netplay_room_list[i].corename));
|
||||
|
@ -353,9 +353,13 @@ static int action_bind_sublabel_netplay_room(
|
||||
if (i < 1)
|
||||
return 0;
|
||||
|
||||
snprintf(s,len, "%s (%s)\n%s (%08x)",
|
||||
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].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);
|
||||
|
||||
#if 0
|
||||
strlcpy(s, netplay_room_list[i - 2].corename, len);
|
||||
#endif
|
||||
|
@ -3127,40 +3127,7 @@ static int menu_displaylist_parse_netplay_room_list(
|
||||
{
|
||||
|
||||
#ifdef HAVE_NETWORKING
|
||||
|
||||
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, 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,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_DISABLE_HOST),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_DISCONNECT),
|
||||
MENU_ENUM_LABEL_NETPLAY_DISCONNECT,
|
||||
MENU_SETTING_ACTION, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu_entries_append_enum(info->list,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_DISCONNECT),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_DISCONNECT),
|
||||
MENU_ENUM_LABEL_NETPLAY_DISCONNECT,
|
||||
MENU_SETTING_ACTION, 0, 0);
|
||||
}
|
||||
|
||||
menu_entries_append_enum(info->list,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS),
|
||||
MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS,
|
||||
MENU_SETTING_ACTION, 0, 0);
|
||||
|
||||
netplay_refresh_rooms_menu(info->list);
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
@ -40,7 +40,8 @@ enum rarch_netplay_ctl_state
|
||||
RARCH_NETPLAY_CTL_ENABLE_CLIENT,
|
||||
RARCH_NETPLAY_CTL_DISABLE,
|
||||
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_PAUSE,
|
||||
RARCH_NETPLAY_CTL_UNPAUSE,
|
||||
|
@ -1124,10 +1124,13 @@ static void netplay_toggle_play_spectate(netplay_t *netplay)
|
||||
bool netplay_disconnect(netplay_t *netplay)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (!netplay)
|
||||
return true;
|
||||
for (i = 0; i < netplay->connections_size; i++)
|
||||
netplay_hangup(netplay, &netplay->connections[i]);
|
||||
|
||||
deinit_netplay();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1137,6 +1140,7 @@ void deinit_netplay(void)
|
||||
{
|
||||
netplay_free(netplay_data);
|
||||
netplay_enabled = false;
|
||||
netplay_is_client = false;
|
||||
is_mitm = false;
|
||||
}
|
||||
netplay_data = NULL;
|
||||
@ -1271,11 +1275,13 @@ bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data)
|
||||
ret = false;
|
||||
goto done;
|
||||
|
||||
case RARCH_NETPLAY_CTL_IS_SERVER_ENABLED:
|
||||
case RARCH_NETPLAY_CTL_IS_SERVER:
|
||||
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 = false;
|
||||
goto done;
|
||||
default:
|
||||
goto done;
|
||||
}
|
||||
@ -1292,9 +1298,11 @@ bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data)
|
||||
goto done;
|
||||
case RARCH_NETPLAY_CTL_IS_ENABLED:
|
||||
goto done;
|
||||
case RARCH_NETPLAY_CTL_IS_SERVER_ENABLED:
|
||||
case RARCH_NETPLAY_CTL_IS_SERVER:
|
||||
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;
|
||||
case RARCH_NETPLAY_CTL_POST_FRAME:
|
||||
netplay_post_frame(netplay_data);
|
||||
|
@ -450,6 +450,7 @@ static void netplay_handshake_ready(netplay_t *netplay, struct netplay_connectio
|
||||
}
|
||||
else
|
||||
{
|
||||
netplay->is_connected = true;
|
||||
snprintf(msg, sizeof(msg), "%s: \"%s\"",
|
||||
msg_hash_to_str(MSG_CONNECTED_TO),
|
||||
connection->nick);
|
||||
|
@ -423,6 +423,7 @@ netplay_t *netplay_new(void *direct_host, const char *server, uint16_t port,
|
||||
netplay->connected_players = 0;
|
||||
netplay->player_max = 1;
|
||||
netplay->is_server = (direct_host == NULL && server == NULL);
|
||||
netplay->is_connected = false;;
|
||||
netplay->nat_traversal = netplay->is_server ? nat_traversal : false;
|
||||
netplay->stateless_mode = stateless_mode;
|
||||
netplay->check_frames = check_frames;
|
||||
|
@ -111,6 +111,7 @@ void netplay_hangup(netplay_t *netplay, struct netplay_connection *connection)
|
||||
else
|
||||
{
|
||||
dmsg = msg_hash_to_str(MSG_NETPLAY_CLIENT_HANGUP);
|
||||
netplay->is_connected = false;
|
||||
}
|
||||
RARCH_LOG("%s\n", dmsg);
|
||||
runloop_msg_queue_push(dmsg, 1, 180, false);
|
||||
|
@ -330,6 +330,9 @@ struct netplay
|
||||
/* Are we the server? */
|
||||
bool is_server;
|
||||
|
||||
/* Are we the connected? */
|
||||
bool is_connected;
|
||||
|
||||
/* Our nickname */
|
||||
char nick[NETPLAY_NICK_LEN];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user