Buildfixes as suggested by forum member - should hopefully fix

console builds as well as other issues
This commit is contained in:
twinaphex 2021-11-05 19:04:52 +01:00
parent 3bc6dd97d9
commit aadedf39f2
3 changed files with 42 additions and 30 deletions

View File

@ -34,6 +34,9 @@
#include "../../core.h" #include "../../core.h"
#define NETPLAY_HOST_STR_LEN 32
#define NETPLAY_HOST_LONGSTR_LEN 256
enum rarch_netplay_ctl_state enum rarch_netplay_ctl_state
{ {
RARCH_NETPLAY_CTL_NONE = 0, RARCH_NETPLAY_CTL_NONE = 0,
@ -137,6 +140,29 @@ struct netplay_room
bool fixed; bool fixed;
}; };
struct netplay_host
{
struct sockaddr addr;
socklen_t addrlen;
int content_crc;
int port;
char address[NETPLAY_HOST_STR_LEN];
char nick[NETPLAY_HOST_STR_LEN];
char frontend[NETPLAY_HOST_STR_LEN];
char core[NETPLAY_HOST_STR_LEN];
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];
};
struct netplay_host_list
{
struct netplay_host *hosts;
size_t size;
};
typedef struct typedef struct
{ {
netplay_t *data; /* Used while Netplay is running */ netplay_t *data; /* Used while Netplay is running */

View File

@ -20,31 +20,6 @@
#include <net/net_ifinfo.h> #include <net/net_ifinfo.h>
#include <retro_miscellaneous.h> #include <retro_miscellaneous.h>
#define NETPLAY_HOST_STR_LEN 32
#define NETPLAY_HOST_LONGSTR_LEN 256
struct netplay_host
{
struct sockaddr addr;
socklen_t addrlen;
int content_crc;
int port;
char address[NETPLAY_HOST_STR_LEN];
char nick[NETPLAY_HOST_STR_LEN];
char frontend[NETPLAY_HOST_STR_LEN];
char core[NETPLAY_HOST_STR_LEN];
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];
};
struct netplay_host_list
{
struct netplay_host *hosts;
size_t size;
};
/* Keep these in order, they coincide with a server-side enum and must match. */ /* Keep these in order, they coincide with a server-side enum and must match. */
enum netplay_host_method enum netplay_host_method
{ {

View File

@ -4096,14 +4096,18 @@ static void announce_play_spectate(netplay_t *netplay,
pdevice_str = device_str; pdevice_str = device_str;
for (device = 0; device < MAX_INPUT_DEVICES; device++) for (device = 0; device < MAX_INPUT_DEVICES; device++)
{
if (devices & (1<<device)) if (devices & (1<<device))
pdevice_str += snprintf(pdevice_str, pdevice_str += snprintf(pdevice_str,
sizeof(device_str) - (size_t) sizeof(device_str) - (size_t)
(pdevice_str - device_str), (pdevice_str - device_str),
"%u, ", "%u, ",
(unsigned) (device+1)); (unsigned) (device+1));
}
if (pdevice_str > device_str) if (pdevice_str > device_str)
pdevice_str -= 2; pdevice_str -= 2;
*pdevice_str = '\0';
/* Then we make the final string */ /* Then we make the final string */
if (nick) if (nick)
@ -5489,7 +5493,7 @@ void netplay_announce_nat_traversal(netplay_t *netplay)
&netplay->nat_traversal_state.ext_inet4_addr, &netplay->nat_traversal_state.ext_inet4_addr,
sizeof(netplay->nat_traversal_state.ext_inet4_addr), sizeof(netplay->nat_traversal_state.ext_inet4_addr),
host, sizeof(host), port, sizeof(port), host, sizeof(host), port, sizeof(port),
NI_NUMERICHOST|NI_NUMERICSERV)) NI_NUMERICHOST | NI_NUMERICSERV))
{ {
snprintf(msg, sizeof(msg), "%s: %s:%s", snprintf(msg, sizeof(msg), "%s: %s:%s",
msg_hash_to_str(MSG_PUBLIC_ADDRESS), msg_hash_to_str(MSG_PUBLIC_ADDRESS),
@ -5507,7 +5511,7 @@ void netplay_announce_nat_traversal(netplay_t *netplay)
&netplay->nat_traversal_state.ext_inet6_addr, &netplay->nat_traversal_state.ext_inet6_addr,
sizeof(netplay->nat_traversal_state.ext_inet6_addr), sizeof(netplay->nat_traversal_state.ext_inet6_addr),
host, sizeof(host), port, sizeof(port), host, sizeof(host), port, sizeof(port),
NI_NUMERICHOST|NI_NUMERICSERV)) NI_NUMERICHOST | NI_NUMERICSERV))
{ {
snprintf(msg, sizeof(msg), "%s: %s|%s", snprintf(msg, sizeof(msg), "%s: %s|%s",
msg_hash_to_str(MSG_PUBLIC_ADDRESS), msg_hash_to_str(MSG_PUBLIC_ADDRESS),
@ -5572,15 +5576,19 @@ static int init_tcp_connection(const struct addrinfo *res,
if (!socket_connect(fd, (void*)res, false)) if (!socket_connect(fd, (void*)res, false))
return fd; return fd;
#ifndef HAVE_SOCKET_LEGACY
if (!getnameinfo(res->ai_addr, res->ai_addrlen, if (!getnameinfo(res->ai_addr, res->ai_addrlen,
host, sizeof(host), port, sizeof(port), host, sizeof(host), port, sizeof(port),
NI_NUMERICHOST|NI_NUMERICSERV)) NI_NUMERICHOST | NI_NUMERICSERV))
{ {
snprintf(msg, sizeof(msg), snprintf(msg, sizeof(msg),
"Failed to connect to host %s on port %s.", "Failed to connect to host %s on port %s.",
host, port); host, port);
dmsg = msg; dmsg = msg;
} }
#else
dmsg = "Failed to connect to host.";
#endif
} }
else else
{ {
@ -5601,12 +5609,16 @@ static int init_tcp_connection(const struct addrinfo *res,
} }
else else
{ {
#ifndef HAVE_SOCKET_LEGACY
if (!getnameinfo(res->ai_addr, res->ai_addrlen, if (!getnameinfo(res->ai_addr, res->ai_addrlen,
NULL, 0, port, sizeof(port), NI_NUMERICSERV)) NULL, 0, port, sizeof(port), NI_NUMERICSERV))
{ {
snprintf(msg, sizeof(msg), "Failed to bind port %s.", port); snprintf(msg, sizeof(msg), "Failed to bind port %s.", port);
dmsg = msg; dmsg = msg;
} }
#else
dmsg = "Failed to bind port.";
#endif
} }
} }
@ -5629,10 +5641,9 @@ static bool init_tcp_socket(netplay_t *netplay, void *direct_host,
if (!direct_host) if (!direct_host)
{ {
#ifdef HAVE_INET6
char port_buf[6]; char port_buf[6];
snprintf(port_buf, sizeof(port_buf), "%hu", port); snprintf(port_buf, sizeof(port_buf), "%hu", port);
#ifdef HAVE_INET6
if (!server) if (!server)
{ {
hints.ai_flags = AI_PASSIVE; hints.ai_flags = AI_PASSIVE;