netplay: show country next to lobby nickname
This commit is contained in:
parent
29d26f29a6
commit
c072894a93
|
@ -3653,6 +3653,15 @@ void netplay_refresh_rooms_menu(file_list_t *list)
|
||||||
|
|
||||||
for (i = 0; i < netplay_room_count; i++)
|
for (i = 0; i < netplay_room_count; i++)
|
||||||
{
|
{
|
||||||
|
char country[PATH_MAX_LENGTH] = {0};
|
||||||
|
|
||||||
|
if (*netplay_room_list[i].country)
|
||||||
|
{
|
||||||
|
strlcat(country, " (", sizeof(country));
|
||||||
|
strlcat(country, netplay_room_list[i].country, sizeof(country));
|
||||||
|
strlcat(country, ")", sizeof(country));
|
||||||
|
}
|
||||||
|
|
||||||
/* Uncomment this to debug mismatched room parameters*/
|
/* Uncomment this to debug mismatched room parameters*/
|
||||||
#if 0
|
#if 0
|
||||||
RARCH_LOG("[lobby] room Data: %d\n"
|
RARCH_LOG("[lobby] room Data: %d\n"
|
||||||
|
@ -3674,13 +3683,13 @@ void netplay_refresh_rooms_menu(file_list_t *list)
|
||||||
netplay_room_list[i].timestamp);
|
netplay_room_list[i].timestamp);
|
||||||
#endif
|
#endif
|
||||||
j+=8;
|
j+=8;
|
||||||
snprintf(s, sizeof(s), "%s: %s",
|
snprintf(s, sizeof(s), "%s: %s%s",
|
||||||
netplay_room_list[i].lan ? "Local" :
|
netplay_room_list[i].lan ? "Local" :
|
||||||
(netplay_room_list[i].host_method == NETPLAY_HOST_METHOD_MITM ?
|
(netplay_room_list[i].host_method == NETPLAY_HOST_METHOD_MITM ?
|
||||||
"Internet (relay)" : "Internet (direct)"),
|
"Internet (relay)" : "Internet (direct)"),
|
||||||
netplay_room_list[i].nickname);
|
netplay_room_list[i].nickname, country);
|
||||||
|
|
||||||
/*int room_type = netplay_room_list[i].lan ? MENU_ROOM_LAN :
|
/*int room_type = netplay_room_list[i].lan ? MENU_ROOM_LAN :
|
||||||
(netplay_room_list[i].host_method == NETPLAY_HOST_METHOD_MITM ? MENU_ROOM_MITM : MENU_ROOM); */
|
(netplay_room_list[i].host_method == NETPLAY_HOST_METHOD_MITM ? MENU_ROOM_MITM : MENU_ROOM); */
|
||||||
menu_entries_append_enum(list,
|
menu_entries_append_enum(list,
|
||||||
s,
|
s,
|
||||||
|
@ -3771,14 +3780,14 @@ static void netplay_refresh_rooms_cb(void *task_data, void *user_data, const cha
|
||||||
if (address->sa_family == AF_INET)
|
if (address->sa_family == AF_INET)
|
||||||
{
|
{
|
||||||
struct sockaddr_in *sin = (struct sockaddr_in *) address;
|
struct sockaddr_in *sin = (struct sockaddr_in *) address;
|
||||||
inet_ntop_compat(AF_INET, &sin->sin_addr,
|
inet_ntop_compat(AF_INET, &sin->sin_addr,
|
||||||
netplay_room_list[i].address, INET6_ADDRSTRLEN);
|
netplay_room_list[i].address, INET6_ADDRSTRLEN);
|
||||||
}
|
}
|
||||||
#if defined(AF_INET6) && !defined(HAVE_SOCKET_LEGACY)
|
#if defined(AF_INET6) && !defined(HAVE_SOCKET_LEGACY)
|
||||||
else if (address->sa_family == AF_INET6)
|
else if (address->sa_family == AF_INET6)
|
||||||
{
|
{
|
||||||
struct sockaddr_in6 *sin = (struct sockaddr_in6 *) address;
|
struct sockaddr_in6 *sin = (struct sockaddr_in6 *) address;
|
||||||
inet_ntop_compat(AF_INET6, &sin->sin6_addr,
|
inet_ntop_compat(AF_INET6, &sin->sin6_addr,
|
||||||
netplay_room_list[i].address, INET6_ADDRSTRLEN);
|
netplay_room_list[i].address, INET6_ADDRSTRLEN);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -3786,9 +3795,9 @@ static void netplay_refresh_rooms_cb(void *task_data, void *user_data, const cha
|
||||||
strlcpy(netplay_room_list[i].corename,
|
strlcpy(netplay_room_list[i].corename,
|
||||||
host->core,
|
host->core,
|
||||||
sizeof(netplay_room_list[i].corename));
|
sizeof(netplay_room_list[i].corename));
|
||||||
strlcpy(netplay_room_list[i].retroarchversion,
|
strlcpy(netplay_room_list[i].retroarch_version,
|
||||||
host->retroarch_version,
|
host->retroarch_version,
|
||||||
sizeof(netplay_room_list[i].retroarchversion));
|
sizeof(netplay_room_list[i].retroarch_version));
|
||||||
strlcpy(netplay_room_list[i].coreversion,
|
strlcpy(netplay_room_list[i].coreversion,
|
||||||
host->core_version,
|
host->core_version,
|
||||||
sizeof(netplay_room_list[i].coreversion));
|
sizeof(netplay_room_list[i].coreversion));
|
||||||
|
|
|
@ -363,9 +363,9 @@ static int action_bind_sublabel_netplay_room(
|
||||||
if (i < 1)
|
if (i < 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
snprintf(s,len, "RetroArch: %s\nCore: %s (%s)\nGame: %s (%08x)",
|
snprintf(s,len, "RetroArch: %s\nCore: %s (%s)\nGame: %s (%08x)",
|
||||||
string_is_empty(netplay_room_list[i - 3].retroarchversion) ? "n/a" : netplay_room_list[i - 3].retroarchversion,
|
string_is_empty(netplay_room_list[i - 3].retroarch_version) ? "n/a" : netplay_room_list[i - 3].retroarch_version,
|
||||||
netplay_room_list[i - 3].corename, netplay_room_list[i - 3].coreversion,
|
netplay_room_list[i - 3].corename, netplay_room_list[i - 3].coreversion,
|
||||||
!string_is_equal(netplay_room_list[i - 3].gamename, "N/A") ? netplay_room_list[i - 3].gamename : "n/a", netplay_room_list[i - 3].gamecrc);
|
!string_is_equal(netplay_room_list[i - 3].gamename, "N/A") ? netplay_room_list[i - 3].gamename : "n/a", netplay_room_list[i - 3].gamecrc);
|
||||||
#if 0
|
#if 0
|
||||||
strlcpy(s, netplay_room_list[i - 3].corename, len);
|
strlcpy(s, netplay_room_list[i - 3].corename, len);
|
||||||
|
|
|
@ -58,8 +58,6 @@ enum netplay_host_method
|
||||||
NETPLAY_HOST_METHOD_MITM
|
NETPLAY_HOST_METHOD_MITM
|
||||||
};
|
};
|
||||||
|
|
||||||
/* data is ordered like this on the server, I left it in this ordered
|
|
||||||
for reference */
|
|
||||||
struct netplay_room
|
struct netplay_room
|
||||||
{
|
{
|
||||||
char nickname [PATH_MAX_LENGTH];
|
char nickname [PATH_MAX_LENGTH];
|
||||||
|
@ -77,7 +75,8 @@ struct netplay_room
|
||||||
bool has_spectate_password;
|
bool has_spectate_password;
|
||||||
bool lan;
|
bool lan;
|
||||||
bool fixed;
|
bool fixed;
|
||||||
char retroarchversion [PATH_MAX_LENGTH];
|
char retroarch_version[PATH_MAX_LENGTH];
|
||||||
|
char country[PATH_MAX_LENGTH];
|
||||||
struct netplay_room *next;
|
struct netplay_room *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,6 @@ typedef struct tag_Context
|
||||||
enum parse_state state;
|
enum parse_state state;
|
||||||
char *cur_field;
|
char *cur_field;
|
||||||
void *cur_member;
|
void *cur_member;
|
||||||
size_t cur_member_size;
|
|
||||||
} Context;
|
} Context;
|
||||||
|
|
||||||
static struct netplay_rooms *rooms;
|
static struct netplay_rooms *rooms;
|
||||||
|
@ -112,7 +111,7 @@ static JSON_Parser_HandlerResult JSON_CALL StringHandler(
|
||||||
{
|
{
|
||||||
if (string_is_equal(pCtx->cur_field, "game_crc"))
|
if (string_is_equal(pCtx->cur_field, "game_crc"))
|
||||||
{
|
{
|
||||||
/* CRC comes in as a string but it is stored
|
/* CRC comes in as a string but it is stored
|
||||||
* as an unsigned casted to int. */
|
* as an unsigned casted to int. */
|
||||||
*((int*)pCtx->cur_member) = (int)strtoul(pValue, NULL, 16);
|
*((int*)pCtx->cur_member) = (int)strtoul(pValue, NULL, 16);
|
||||||
}
|
}
|
||||||
|
@ -213,25 +212,21 @@ static JSON_Parser_HandlerResult JSON_CALL ObjectMemberHandler(JSON_Parser parse
|
||||||
{
|
{
|
||||||
pCtx->cur_field = strdup(pValue);
|
pCtx->cur_field = strdup(pValue);
|
||||||
pCtx->cur_member = &rooms->cur->nickname;
|
pCtx->cur_member = &rooms->cur->nickname;
|
||||||
pCtx->cur_member_size = sizeof(rooms->cur->nickname);
|
|
||||||
}
|
}
|
||||||
else if (string_is_equal_fast(pValue, "game_name", 9))
|
else if (string_is_equal_fast(pValue, "game_name", 9))
|
||||||
{
|
{
|
||||||
pCtx->cur_field = strdup(pValue);
|
pCtx->cur_field = strdup(pValue);
|
||||||
pCtx->cur_member = &rooms->cur->gamename;
|
pCtx->cur_member = &rooms->cur->gamename;
|
||||||
pCtx->cur_member_size = sizeof(rooms->cur->gamename);
|
|
||||||
}
|
}
|
||||||
else if (string_is_equal_fast(pValue, "core_name", 9))
|
else if (string_is_equal_fast(pValue, "core_name", 9))
|
||||||
{
|
{
|
||||||
pCtx->cur_field = strdup(pValue);
|
pCtx->cur_field = strdup(pValue);
|
||||||
pCtx->cur_member = &rooms->cur->corename;
|
pCtx->cur_member = &rooms->cur->corename;
|
||||||
pCtx->cur_member_size = sizeof(rooms->cur->corename);
|
|
||||||
}
|
}
|
||||||
else if (string_is_equal_fast(pValue, "ip", 2))
|
else if (string_is_equal_fast(pValue, "ip", 2))
|
||||||
{
|
{
|
||||||
pCtx->cur_field = strdup(pValue);
|
pCtx->cur_field = strdup(pValue);
|
||||||
pCtx->cur_member = &rooms->cur->address;
|
pCtx->cur_member = &rooms->cur->address;
|
||||||
pCtx->cur_member_size = sizeof(rooms->cur->address);
|
|
||||||
}
|
}
|
||||||
else if (string_is_equal_fast(pValue, "port", 4))
|
else if (string_is_equal_fast(pValue, "port", 4))
|
||||||
{
|
{
|
||||||
|
@ -247,7 +242,6 @@ static JSON_Parser_HandlerResult JSON_CALL ObjectMemberHandler(JSON_Parser parse
|
||||||
{
|
{
|
||||||
pCtx->cur_field = strdup(pValue);
|
pCtx->cur_field = strdup(pValue);
|
||||||
pCtx->cur_member = &rooms->cur->coreversion;
|
pCtx->cur_member = &rooms->cur->coreversion;
|
||||||
pCtx->cur_member_size = sizeof(rooms->cur->coreversion);
|
|
||||||
}
|
}
|
||||||
else if (string_is_equal_fast(pValue, "has_password", 12))
|
else if (string_is_equal_fast(pValue, "has_password", 12))
|
||||||
{
|
{
|
||||||
|
@ -282,8 +276,12 @@ static JSON_Parser_HandlerResult JSON_CALL ObjectMemberHandler(JSON_Parser parse
|
||||||
else if (string_is_equal_fast(pValue, "retroarch_version", 17))
|
else if (string_is_equal_fast(pValue, "retroarch_version", 17))
|
||||||
{
|
{
|
||||||
pCtx->cur_field = strdup(pValue);
|
pCtx->cur_field = strdup(pValue);
|
||||||
pCtx->cur_member = &rooms->cur->retroarchversion;
|
pCtx->cur_member = &rooms->cur->retroarch_version;
|
||||||
pCtx->cur_member_size = sizeof(rooms->cur->retroarchversion);
|
}
|
||||||
|
else if (string_is_equal_fast(pValue, "country", 7))
|
||||||
|
{
|
||||||
|
pCtx->cur_field = strdup(pValue);
|
||||||
|
pCtx->cur_member = &rooms->cur->country;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue