netplay: show country next to lobby nickname

This commit is contained in:
Brad Parker 2017-07-29 02:24:11 +00:00
parent 29d26f29a6
commit c072894a93
4 changed files with 30 additions and 24 deletions

View File

@ -3653,6 +3653,15 @@ void netplay_refresh_rooms_menu(file_list_t *list)
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*/
#if 0
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);
#endif
j+=8;
snprintf(s, sizeof(s), "%s: %s",
netplay_room_list[i].lan ? "Local" :
(netplay_room_list[i].host_method == NETPLAY_HOST_METHOD_MITM ?
snprintf(s, sizeof(s), "%s: %s%s",
netplay_room_list[i].lan ? "Local" :
(netplay_room_list[i].host_method == NETPLAY_HOST_METHOD_MITM ?
"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); */
menu_entries_append_enum(list,
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)
{
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);
}
#if defined(AF_INET6) && !defined(HAVE_SOCKET_LEGACY)
else if (address->sa_family == AF_INET6)
{
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);
}
#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,
host->core,
sizeof(netplay_room_list[i].corename));
strlcpy(netplay_room_list[i].retroarchversion,
strlcpy(netplay_room_list[i].retroarch_version,
host->retroarch_version,
sizeof(netplay_room_list[i].retroarchversion));
sizeof(netplay_room_list[i].retroarch_version));
strlcpy(netplay_room_list[i].coreversion,
host->core_version,
sizeof(netplay_room_list[i].coreversion));

View File

@ -363,9 +363,9 @@ static int action_bind_sublabel_netplay_room(
if (i < 1)
return 0;
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,
netplay_room_list[i - 3].corename, netplay_room_list[i - 3].coreversion,
snprintf(s,len, "RetroArch: %s\nCore: %s (%s)\nGame: %s (%08x)",
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,
!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
strlcpy(s, netplay_room_list[i - 3].corename, len);

View File

@ -58,8 +58,6 @@ enum netplay_host_method
NETPLAY_HOST_METHOD_MITM
};
/* data is ordered like this on the server, I left it in this ordered
for reference */
struct netplay_room
{
char nickname [PATH_MAX_LENGTH];
@ -77,7 +75,8 @@ struct netplay_room
bool has_spectate_password;
bool lan;
bool fixed;
char retroarchversion [PATH_MAX_LENGTH];
char retroarch_version[PATH_MAX_LENGTH];
char country[PATH_MAX_LENGTH];
struct netplay_room *next;
};

View File

@ -47,7 +47,6 @@ typedef struct tag_Context
enum parse_state state;
char *cur_field;
void *cur_member;
size_t cur_member_size;
} Context;
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"))
{
/* 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. */
*((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_member = &rooms->cur->nickname;
pCtx->cur_member_size = sizeof(rooms->cur->nickname);
}
else if (string_is_equal_fast(pValue, "game_name", 9))
{
pCtx->cur_field = strdup(pValue);
pCtx->cur_member = &rooms->cur->gamename;
pCtx->cur_member_size = sizeof(rooms->cur->gamename);
}
else if (string_is_equal_fast(pValue, "core_name", 9))
{
pCtx->cur_field = strdup(pValue);
pCtx->cur_member = &rooms->cur->corename;
pCtx->cur_member_size = sizeof(rooms->cur->corename);
}
else if (string_is_equal_fast(pValue, "ip", 2))
{
pCtx->cur_field = strdup(pValue);
pCtx->cur_member = &rooms->cur->address;
pCtx->cur_member_size = sizeof(rooms->cur->address);
}
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_member = &rooms->cur->coreversion;
pCtx->cur_member_size = sizeof(rooms->cur->coreversion);
}
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))
{
pCtx->cur_field = strdup(pValue);
pCtx->cur_member = &rooms->cur->retroarchversion;
pCtx->cur_member_size = sizeof(rooms->cur->retroarchversion);
pCtx->cur_member = &rooms->cur->retroarch_version;
}
else if (string_is_equal_fast(pValue, "country", 7))
{
pCtx->cur_field = strdup(pValue);
pCtx->cur_member = &rooms->cur->country;
}
}
}