[netplay] support subsystem type netplay lobbies

This commit is contained in:
radius 2019-01-12 22:26:44 -05:00
parent c7054a36f2
commit f0b8d2d12e
6 changed files with 92 additions and 15 deletions

View File

@ -4263,6 +4263,9 @@ static void netplay_refresh_rooms_cb(void *task_data, void *user_data, const cha
strlcpy(netplay_room_list[i].frontend,
host->frontend,
sizeof(netplay_room_list[i].frontend));
strlcpy(netplay_room_list[i].subsystem_name,
host->subsystem_name,
sizeof(netplay_room_list[i].subsystem_name));
netplay_room_list[i].port = host->port;
netplay_room_list[i].gamecrc = host->content_crc;

View File

@ -692,6 +692,7 @@ static int action_bind_sublabel_netplay_room(
const char *core_ver = NULL;
const char *frontend = NULL;
const char *na = NULL;
const char *subsystem = NULL;
/* This offset may cause issues if any entries are added to this menu */
unsigned offset = i - 3;
@ -705,15 +706,53 @@ static int action_bind_sublabel_netplay_room(
core_ver = netplay_room_list[offset].coreversion;
gamecrc = netplay_room_list[offset].gamecrc;
frontend = netplay_room_list[offset].frontend;
subsystem = netplay_room_list[offset].subsystem_name;
na = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE);
snprintf(s, len,
"RetroArch: %s (%s)\nCore: %s (%s)\nGame: %s (%08x)",
string_is_empty(ra_version) ? na : ra_version,
string_is_empty(frontend) ? na : frontend,
corename, core_ver,
!string_is_equal(gamename, na) ? gamename : na,
gamecrc);
if (string_is_empty(subsystem) || string_is_equal(subsystem, "N/A"))
{
snprintf(s, len,
"RetroArch: %s (%s)\nCore: %s (%s)\nGame: %s (%08x)",
string_is_empty(ra_version) ? na : ra_version,
string_is_empty(frontend) ? na : frontend,
corename, core_ver,
!string_is_equal(gamename, na) ? gamename : na,
gamecrc);
}
else
{
if (strstr(gamename, "|"))
{
char buf[4096];
unsigned i = 0;
struct string_list *list = string_split(gamename, "|");
buf[0] = '\0';
for (i = 0; i < list->size; i++)
{
strlcat(buf, " ", sizeof(buf));
strlcat(buf, list->elems[i].data, sizeof(buf));
strlcat(buf, "\n", sizeof(buf));
}
snprintf(s, len,
"RetroArch: %s (%s)\nCore: %s (%s)\nSubsystem: %s\nGames:\n%s",
string_is_empty(ra_version) ? na : ra_version,
string_is_empty(frontend) ? na : frontend,
corename, core_ver, subsystem,
!string_is_equal(gamename, na) ? buf : na
);
}
else
{
snprintf(s, len,
"RetroArch: %s (%s)\nCore: %s (%s)\nSubsystem: %s\nGame: %s (%08x)",
string_is_empty(ra_version) ? na : ra_version,
string_is_empty(frontend) ? na : frontend,
corename, core_ver, subsystem,
!string_is_equal(gamename, na) ? gamename : na,
gamecrc);
}
}
#if 0
strlcpy(s, corename, len);
#endif

View File

@ -68,6 +68,7 @@ struct ad_packet
char core_version[NETPLAY_HOST_STR_LEN];
char content[NETPLAY_HOST_LONGSTR_LEN];
char content_crc[NETPLAY_HOST_STR_LEN];
char subsystem_name[NETPLAY_HOST_STR_LEN];
};
static bool netplay_lan_ad_client(void);
@ -247,6 +248,8 @@ bool netplay_lan_ad_server(netplay_t *netplay)
unsigned k = 0;
char reply_addr[NETPLAY_HOST_STR_LEN], port_str[6];
struct addrinfo *our_addr, hints = {0};
struct string_list *subsystem = path_get_subsystem_list();
char buf[4096];
net_ifinfo_t interfaces;
@ -313,11 +316,37 @@ bool netplay_lan_ad_server(netplay_t *netplay)
reply_addr, interfaces.entries[k].host);
/* Now build our response */
buf[0] = '\0';
content_crc = content_get_crc();
memset(&ad_packet_buffer, 0, sizeof(struct ad_packet));
memcpy(&ad_packet_buffer, "RANS", 4);
if (subsystem)
{
unsigned i;
for (i = 0; i < subsystem->size; i++)
{
strlcat(buf, path_basename(subsystem->elems[i].data), NETPLAY_HOST_LONGSTR_LEN);
if (i < subsystem->size - 1)
strlcat(buf, "|", NETPLAY_HOST_LONGSTR_LEN);
}
RARCH_LOG("%s\n", buf);
strlcpy(ad_packet_buffer.content, buf,
NETPLAY_HOST_LONGSTR_LEN);
strlcpy(ad_packet_buffer.subsystem_name, path_get(RARCH_PATH_SUBSYSTEM),
NETPLAY_HOST_STR_LEN);
}
else
{
strlcpy(ad_packet_buffer.content, !string_is_empty(
path_basename(path_get(RARCH_PATH_BASENAME)))
? path_basename(path_get(RARCH_PATH_BASENAME)) : "N/A",
NETPLAY_HOST_LONGSTR_LEN);
strlcpy(ad_packet_buffer.subsystem_name, "N/A", NETPLAY_HOST_STR_LEN);
}
strlcpy(ad_packet_buffer.address, interfaces.entries[k].host,
NETPLAY_HOST_STR_LEN);
ad_packet_buffer.protocol_version =
@ -325,10 +354,6 @@ bool netplay_lan_ad_server(netplay_t *netplay)
ad_packet_buffer.port = htonl(netplay->tcp_port);
strlcpy(ad_packet_buffer.retroarch_version, PACKAGE_VERSION,
NETPLAY_HOST_STR_LEN);
strlcpy(ad_packet_buffer.content, !string_is_empty(
path_basename(path_get(RARCH_PATH_BASENAME)))
? path_basename(path_get(RARCH_PATH_BASENAME)) : "N/A",
NETPLAY_HOST_LONGSTR_LEN);
strlcpy(ad_packet_buffer.nick, netplay->nick, NETPLAY_HOST_STR_LEN);
strlcpy(ad_packet_buffer.frontend, frontend, NETPLAY_HOST_STR_LEN);
@ -393,7 +418,7 @@ static bool netplay_lan_ad_client(void)
struct timeval tmp_tv = {0};
if (lan_ad_client_fd < 0)
return false;
return false;
/* Check for any ad queries */
while (1)
@ -492,6 +517,8 @@ static bool netplay_lan_ad_client(void)
NETPLAY_HOST_STR_LEN);
strlcpy(host->content, ad_packet_buffer.content,
NETPLAY_HOST_LONGSTR_LEN);
strlcpy(host->subsystem_name, ad_packet_buffer.subsystem_name,
NETPLAY_HOST_LONGSTR_LEN);
strlcpy(host->frontend, ad_packet_buffer.frontend,
NETPLAY_HOST_STR_LEN);

View File

@ -43,6 +43,7 @@ struct netplay_host
char core_version[NETPLAY_HOST_STR_LEN];
char retroarch_version[NETPLAY_HOST_STR_LEN];
char content[NETPLAY_HOST_LONGSTR_LEN];
char subsystem_name[NETPLAY_HOST_LONGSTR_LEN];
int content_crc;
int port;
};
@ -82,6 +83,7 @@ struct netplay_room
bool lan;
bool fixed;
char retroarch_version[PATH_MAX_LENGTH];
char subsystem_name[PATH_MAX_LENGTH];
char country[PATH_MAX_LENGTH];
struct netplay_room *next;
};

View File

@ -851,9 +851,9 @@ void netplay_get_architecture(char *frontend_architecture, size_t size)
static void netplay_announce(void)
{
char buf [4600];
char buf[4600];
char frontend_architecture[PATH_MAX_LENGTH];
char url [2048] = "http://lobby.libretro.com/add/";
char url[2048] = "http://lobby.libretro.com/add/";
char *username = NULL;
char *corename = NULL;
char *gamename = NULL;
@ -865,6 +865,8 @@ static void netplay_announce(void)
uint32_t content_crc = content_get_crc();
struct string_list *subsystem = path_get_subsystem_list();
buf[0] = '\0';
if (subsystem)
{
unsigned i;
@ -875,7 +877,6 @@ static void netplay_announce(void)
if (i < subsystem->size - 1)
strlcat(buf, "|", sizeof(buf));
}
RARCH_LOG("%s\n", buf);
net_http_urlencode(&gamename, buf);
net_http_urlencode(&subsystemname, path_get(RARCH_PATH_SUBSYSTEM));
}

View File

@ -288,6 +288,11 @@ static JSON_Parser_HandlerResult JSON_CALL ObjectMemberHandler(JSON_Parser parse
pCtx->cur_field = strdup(pValue);
pCtx->cur_member = &rooms->cur->frontend;
}
else if (string_is_equal(pValue, "subsystem_name"))
{
pCtx->cur_field = strdup(pValue);
pCtx->cur_member = &rooms->cur->subsystem_name;
}
}
}