mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-30 06:43:53 +00:00
integrate the rest of the lan scan parameters
This commit is contained in:
parent
5ca55aa533
commit
e50ea80dfa
@ -3389,6 +3389,7 @@ static int action_ok_push_scan_file(const char *path,
|
||||
static void netplay_refresh_rooms_cb(void *task_data, void *user_data, const char *err)
|
||||
{
|
||||
char buf[PATH_MAX_LENGTH];
|
||||
int lan_room_count = 0;
|
||||
|
||||
http_transfer_data_t *data = (http_transfer_data_t*)task_data;
|
||||
|
||||
@ -3424,6 +3425,8 @@ finish:
|
||||
|
||||
if (!netplay_discovery_driver_ctl(RARCH_NETPLAY_DISCOVERY_CTL_LAN_GET_RESPONSES, &lan_hosts))
|
||||
lan_hosts = NULL;
|
||||
if (lan_hosts)
|
||||
lan_room_count = lan_hosts->size;
|
||||
|
||||
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, file_list);
|
||||
|
||||
@ -3435,7 +3438,7 @@ finish:
|
||||
netplay_room_count = (int)(room_data->size / 8);
|
||||
netplay_room_list = (struct netplay_room*)
|
||||
malloc(sizeof(struct netplay_room) * netplay_room_count +
|
||||
lan_hosts->size);
|
||||
lan_room_count);
|
||||
|
||||
#if 0
|
||||
for (int i = 0; i < room_data->size; i++)
|
||||
@ -3512,63 +3515,42 @@ finish:
|
||||
MENU_ROOM, 0, 0);
|
||||
}
|
||||
|
||||
struct netplay_host *host = &lan_hosts->hosts[k];
|
||||
for (; i < netplay_room_count + lan_hosts->size; i++)
|
||||
if (lan_hosts && lan_room_count > 0)
|
||||
{
|
||||
strlcpy(netplay_room_list[i].nickname,
|
||||
host->nick,
|
||||
sizeof(netplay_room_list[i].nickname));
|
||||
/* to-do: get address fron host-> addr */
|
||||
struct sockaddr* address = &host->addr;
|
||||
strlcpy(netplay_room_list[i].address,
|
||||
inet_ntoa(((struct sockaddr_in*)(address))->sin_addr),
|
||||
sizeof(netplay_room_list[i].address));
|
||||
strlcpy(netplay_room_list[i].corename,
|
||||
host->core,
|
||||
sizeof(netplay_room_list[i].corename));
|
||||
strlcpy(netplay_room_list[i].coreversion,
|
||||
host->core_version,
|
||||
sizeof(netplay_room_list[i].coreversion));
|
||||
strlcpy(netplay_room_list[i].gamename,
|
||||
host->content,
|
||||
sizeof(netplay_room_list[i].coreversion));
|
||||
/* to-do: this will only work with default port os
|
||||
we should have a start LAN game entry that always
|
||||
uses that port
|
||||
*/
|
||||
netplay_room_list[i].port = 55435;
|
||||
/* to-do: lan announce doesn't announce CRC */
|
||||
netplay_room_list[i].gamecrc = 0;
|
||||
netplay_room_list[i].timestamp = 0;
|
||||
/* Uncomment this to debug mismatched room parameters*/
|
||||
#if 1
|
||||
RARCH_LOG("Room Data: %d\n"
|
||||
"Nickname: %s\n"
|
||||
"Address: %s\n"
|
||||
"Port: %d\n"
|
||||
"Core: %s\n"
|
||||
"Core Version: %s\n"
|
||||
"Game: %s\n"
|
||||
"Game CRC: %08x\n"
|
||||
"Timestamp: %d\n", room_data->elems[j + 6].data,
|
||||
netplay_room_list[i].nickname,
|
||||
netplay_room_list[i].address,
|
||||
netplay_room_list[i].port,
|
||||
netplay_room_list[i].corename,
|
||||
netplay_room_list[i].coreversion,
|
||||
netplay_room_list[i].gamename,
|
||||
netplay_room_list[i].gamecrc,
|
||||
netplay_room_list[i].timestamp);
|
||||
#endif
|
||||
snprintf(s, sizeof(s), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME),
|
||||
netplay_room_list[i].nickname);
|
||||
struct netplay_host *host = &lan_hosts->hosts[k];
|
||||
for (; i < netplay_room_count + lan_room_count; i++)
|
||||
{
|
||||
strlcpy(netplay_room_list[i].nickname,
|
||||
host->nick,
|
||||
sizeof(netplay_room_list[i].nickname));
|
||||
struct sockaddr* address = &host->addr;
|
||||
strlcpy(netplay_room_list[i].address,
|
||||
inet_ntoa(((struct sockaddr_in*)(address))->sin_addr),
|
||||
sizeof(netplay_room_list[i].address));
|
||||
strlcpy(netplay_room_list[i].corename,
|
||||
host->core,
|
||||
sizeof(netplay_room_list[i].corename));
|
||||
strlcpy(netplay_room_list[i].coreversion,
|
||||
host->core_version,
|
||||
sizeof(netplay_room_list[i].coreversion));
|
||||
strlcpy(netplay_room_list[i].gamename,
|
||||
host->content,
|
||||
sizeof(netplay_room_list[i].coreversion));
|
||||
|
||||
menu_entries_append_enum(file_list,
|
||||
s,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM),
|
||||
MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM,
|
||||
MENU_ROOM, 0, 0);
|
||||
k++;
|
||||
netplay_room_list[i].port = 55435;
|
||||
netplay_room_list[i].gamecrc = host->content_crc;
|
||||
netplay_room_list[i].timestamp = 0;
|
||||
|
||||
snprintf(s, sizeof(s), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME),
|
||||
netplay_room_list[i].nickname);
|
||||
|
||||
menu_entries_append_enum(file_list,
|
||||
s,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM),
|
||||
MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM,
|
||||
MENU_ROOM, 0, 0);
|
||||
k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string/stdstring.h>
|
||||
#include <file/file_path.h>
|
||||
#include "../../file_path_special.h"
|
||||
#include "../paths.h"
|
||||
#include "../content.h"
|
||||
|
||||
#include <compat/strl.h>
|
||||
#include <net/net_compat.h>
|
||||
@ -58,6 +63,7 @@ struct ad_packet
|
||||
char core[NETPLAY_HOST_STR_LEN];
|
||||
char core_version[NETPLAY_HOST_STR_LEN];
|
||||
char content[NETPLAY_HOST_STR_LEN];
|
||||
char content_crc[NETPLAY_HOST_STR_LEN];
|
||||
};
|
||||
|
||||
bool netplay_lan_ad_client(void);
|
||||
@ -240,6 +246,8 @@ bool netplay_lan_ad_server(netplay_t *netplay)
|
||||
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
|
||||
|
||||
/* Now build our response */
|
||||
uint32_t *content_crc_ptr = NULL;
|
||||
content_get_crc(&content_crc_ptr);
|
||||
memset(&ad_packet_buffer, 0, sizeof(struct ad_packet));
|
||||
memcpy(&ad_packet_buffer, "RANS", 4);
|
||||
ad_packet_buffer.protocol_version =
|
||||
@ -247,6 +255,8 @@ 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_STR_LEN);
|
||||
strlcpy(ad_packet_buffer.nick, netplay->nick, NETPLAY_HOST_STR_LEN);
|
||||
if (info)
|
||||
{
|
||||
@ -255,6 +265,10 @@ bool netplay_lan_ad_server(netplay_t *netplay)
|
||||
strlcpy(ad_packet_buffer.core_version, info->info.library_version,
|
||||
NETPLAY_HOST_STR_LEN);
|
||||
}
|
||||
char s[NETPLAY_HOST_STR_LEN];
|
||||
snprintf(s, sizeof(s), "%d", *content_crc_ptr);
|
||||
strlcpy(ad_packet_buffer.content_crc, s,
|
||||
NETPLAY_HOST_STR_LEN);
|
||||
|
||||
/* And send it */
|
||||
sendto(lan_ad_server_fd, (const char*)&ad_packet_buffer,
|
||||
@ -372,6 +386,7 @@ bool netplay_lan_ad_client(void)
|
||||
NETPLAY_HOST_STR_LEN);
|
||||
strlcpy(host->content, ad_packet_buffer.content,
|
||||
NETPLAY_HOST_STR_LEN);
|
||||
host->content_crc = atoi(ad_packet_buffer.content_crc);
|
||||
host->nick[NETPLAY_HOST_STR_LEN-1] =
|
||||
host->core[NETPLAY_HOST_STR_LEN-1] =
|
||||
host->core_version[NETPLAY_HOST_STR_LEN-1] =
|
||||
|
@ -39,6 +39,7 @@ struct netplay_host
|
||||
char core[NETPLAY_HOST_STR_LEN];
|
||||
char core_version[NETPLAY_HOST_STR_LEN];
|
||||
char content[NETPLAY_HOST_STR_LEN];
|
||||
int content_crc;
|
||||
};
|
||||
|
||||
struct netplay_host_list
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include <lists/file_list.h>
|
||||
#include <string/stdstring.h>
|
||||
#include "../paths.h"
|
||||
|
||||
#include "tasks_internal.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user