mirror of
https://github.com/libretro/RetroArch
synced 2025-03-02 19:13:34 +00:00
(Netplay/Lobby) Hide older (incompatible) rooms (#14118)
This commit is contained in:
parent
e9d67f2bbe
commit
58fc77850c
@ -137,7 +137,7 @@
|
||||
#define BYTES_TO_GB(bytes) (((bytes) / 1024) / 1024 / 1024)
|
||||
|
||||
#ifdef HAVE_NETWORKING
|
||||
#if !defined(HAVE_SOCKET_LEGACY) && (!defined(SWITCH) || defined(SWITCH) && defined(HAVE_LIBNX)) || defined(GEKKO)
|
||||
#if !defined(HAVE_SOCKET_LEGACY) || defined(GEKKO)
|
||||
#include <net/net_ifinfo.h>
|
||||
#endif
|
||||
#endif
|
||||
@ -3913,7 +3913,7 @@ static unsigned menu_displaylist_parse_information_list(file_list_t *info_list)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETWORKING
|
||||
#if !defined (HAVE_SOCKET_LEGACY) || defined(GEKKO)
|
||||
#if !defined(HAVE_SOCKET_LEGACY) || defined(GEKKO)
|
||||
if (menu_entries_append_enum(info_list,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETWORK_INFORMATION),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_NETWORK_INFORMATION),
|
||||
@ -7185,32 +7185,34 @@ unsigned menu_displaylist_build_list(
|
||||
count++;
|
||||
break;
|
||||
case DISPLAYLIST_NETWORK_INFO:
|
||||
#if defined(HAVE_NETWORKING) && (!defined(HAVE_SOCKET_LEGACY) && (!defined(SWITCH) || defined(SWITCH) && defined(HAVE_LIBNX)) || defined(GEKKO))
|
||||
network_init();
|
||||
#ifdef HAVE_NETWORKING
|
||||
#if !defined(HAVE_SOCKET_LEGACY) || defined(GEKKO)
|
||||
{
|
||||
net_ifinfo_t netlist;
|
||||
net_ifinfo_t interfaces = {0};
|
||||
|
||||
if (net_ifinfo_new(&netlist))
|
||||
network_init();
|
||||
|
||||
if (net_ifinfo_new(&interfaces))
|
||||
{
|
||||
unsigned k;
|
||||
for (k = 0; k < netlist.size; k++)
|
||||
size_t i;
|
||||
char buf[768];
|
||||
|
||||
for (i = 0; i < interfaces.size; i++)
|
||||
{
|
||||
char tmp[255];
|
||||
struct net_ifinfo_entry *entry = &interfaces.entries[i];
|
||||
|
||||
tmp[0] = '\0';
|
||||
|
||||
snprintf(tmp, sizeof(tmp), "%s (%s) : %s\n",
|
||||
msg_hash_to_str(MSG_INTERFACE),
|
||||
netlist.entries[k].name, netlist.entries[k].host);
|
||||
if (menu_entries_append_enum(list, tmp, "",
|
||||
MENU_ENUM_LABEL_NETWORK_INFO_ENTRY,
|
||||
MENU_SETTINGS_CORE_INFO_NONE, 0, 0))
|
||||
snprintf(buf, sizeof(buf), "%s (%s) : %s\n",
|
||||
msg_hash_to_str(MSG_INTERFACE), entry->name, entry->host);
|
||||
if (menu_entries_append_enum(list, buf, entry->name,
|
||||
MENU_ENUM_LABEL_NETWORK_INFO_ENTRY,
|
||||
MENU_SETTINGS_CORE_INFO_NONE, 0, 0))
|
||||
count++;
|
||||
}
|
||||
|
||||
net_ifinfo_free(&netlist);
|
||||
net_ifinfo_free(&interfaces);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
case DISPLAYLIST_OPTIONS_CHEATS:
|
||||
@ -10488,6 +10490,10 @@ unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list)
|
||||
if (!room->is_retroarch)
|
||||
continue;
|
||||
|
||||
/* Get rid of rooms running older (incompatible) versions. */
|
||||
if (!netplay_compatible_version(room->retroarch_version))
|
||||
continue;
|
||||
|
||||
/* Get rid of any room that is not connectable,
|
||||
if the user opt-in. */
|
||||
if (!room->connectable)
|
||||
|
@ -256,6 +256,7 @@ typedef struct
|
||||
|
||||
net_driver_state_t *networking_state_get_ptr(void);
|
||||
|
||||
bool netplay_compatible_version(const char *version);
|
||||
bool netplay_decode_hostname(const char *hostname,
|
||||
char *address, unsigned *port, char *session, size_t len);
|
||||
bool netplay_is_lan_address(struct sockaddr_in *addr);
|
||||
|
@ -8889,6 +8889,44 @@ bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data)
|
||||
|
||||
/* Netplay Utils */
|
||||
|
||||
bool netplay_compatible_version(const char *version)
|
||||
{
|
||||
static const uint64_t min_version = 0x0001000900010000ULL; /* 1.9.1 */
|
||||
size_t version_parts = 0;
|
||||
uint64_t version_value = 0;
|
||||
char *version_end = NULL;
|
||||
bool loop = true;
|
||||
|
||||
/* Convert the version string to an integer first. */
|
||||
do
|
||||
{
|
||||
uint16_t version_part = (uint16_t)strtoul(version, &version_end, 10);
|
||||
|
||||
if (version_end == version) /* Nothing to convert */
|
||||
return false;
|
||||
|
||||
switch (*version_end)
|
||||
{
|
||||
case '\0': /* End of version string */
|
||||
loop = false;
|
||||
break;
|
||||
case '.':
|
||||
version = (const char*)version_end + 1;
|
||||
break;
|
||||
default: /* Invalid version string */
|
||||
return false;
|
||||
}
|
||||
|
||||
/* We only want enough bits as to fit into version_value. */
|
||||
if (version_parts++ < (sizeof(version_value) / sizeof(version_part)))
|
||||
version_value |= (uint64_t)version_part <<
|
||||
((sizeof(version_value) << 3) -
|
||||
((sizeof(version_part) << 3) * version_parts));
|
||||
} while (loop);
|
||||
|
||||
return version_value >= min_version;
|
||||
}
|
||||
|
||||
bool netplay_decode_hostname(const char *hostname,
|
||||
char *address, unsigned *port, char *session, size_t len)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user