This commit is contained in:
twinaphex 2017-05-21 09:16:45 +02:00
parent f653cf4e7c
commit 0bb1de9561

View File

@ -152,8 +152,8 @@ static bool init_tcp_socket(netplay_t *netplay, void *direct_host,
}
else
{
/* I'll build my own addrinfo! With blackjack and hookers! */
struct netplay_host *host = (struct netplay_host *) direct_host;
/* I'll build my own addrinfo! */
struct netplay_host *host = (struct netplay_host *)direct_host;
hints.ai_family = host->addr.sa_family;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = 0;
@ -214,7 +214,8 @@ static bool init_tcp_socket(netplay_t *netplay, void *direct_host,
return ret;
}
static bool init_socket(netplay_t *netplay, void *direct_host, const char *server, uint16_t port)
static bool init_socket(netplay_t *netplay, void *direct_host,
const char *server, uint16_t port)
{
if (!network_init())
return false;
@ -368,8 +369,7 @@ bool netplay_wait_and_init_serialization(netplay_t *netplay)
static bool netplay_init_buffers(netplay_t *netplay)
{
if (!netplay)
return false;
struct delta_frame *delta_frames = NULL;
/* Enough to get ahead or behind by MAX_STALL_FRAMES frames */
netplay->buffer_size = NETPLAY_MAX_STALL_FRAMES + 1;
@ -379,12 +379,14 @@ static bool netplay_init_buffers(netplay_t *netplay)
if (netplay->is_server)
netplay->buffer_size *= 2;
netplay->buffer = (struct delta_frame*)calloc(netplay->buffer_size,
sizeof(*netplay->buffer));
delta_frames = (struct delta_frame*)calloc(netplay->buffer_size,
sizeof(*delta_frames));
if (!netplay->buffer)
if (!delta_frames)
return false;
netplay->buffer = delta_frames;
if (!(netplay->quirks & (NETPLAY_QUIRK_NO_SAVESTATES|NETPLAY_QUIRK_INITIALIZATION)))
netplay_init_serialization(netplay);
@ -446,7 +448,9 @@ netplay_t *netplay_new(void *direct_host, const char *server, uint16_t port,
netplay->connections[0].fd = -1;
}
strlcpy(netplay->nick, nick[0] ? nick : RARCH_DEFAULT_NICK, sizeof(netplay->nick));
strlcpy(netplay->nick, nick[0]
? nick : RARCH_DEFAULT_NICK,
sizeof(netplay->nick));
if (!init_socket(netplay, direct_host, server, port))
{
@ -463,11 +467,13 @@ netplay_t *netplay_new(void *direct_host, const char *server, uint16_t port,
if (!netplay->is_server)
{
netplay_handshake_init_send(netplay, &netplay->connections[0]);
netplay->connections[0].mode = netplay->self_mode = NETPLAY_CONNECTION_INIT;
netplay->connections[0].mode = NETPLAY_CONNECTION_INIT;
netplay->self_mode = NETPLAY_CONNECTION_INIT;
}
/* FIXME: Not really the right place to do this, socket initialization needs
* to be fixed in general */
/* FIXME: Not really the right place to do this,
* socket initialization needs to be fixed in general. */
if (netplay->is_server)
{
if (!socket_nonblock(netplay->listen_fd))