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++) 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,11 +3683,11 @@ 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); */
@ -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));

View File

@ -364,7 +364,7 @@ static int action_bind_sublabel_netplay_room(
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

View File

@ -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;
}; };

View File

@ -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;
@ -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;
} }
} }
} }