Aggressively simplify netplay_handshake - this function was very

weird - the conditional was never triggered because all instances
of connection->mode being greater than or equal to
NETPLAY_CONNECTION_CONNECTED would already early return anyway
This commit is contained in:
twinaphex 2020-01-28 14:29:30 +01:00
parent f72e127f5f
commit 096f992cc0

View File

@ -37,7 +37,7 @@
#include "../../retroarch.h" #include "../../retroarch.h"
#include "../../version.h" #include "../../version.h"
const uint32_t netplay_magic = 0x52414E50; /* RANP */ #define NETPLAY_MAGIC 0x52414E50 /* RANP */
/* TODO/FIXME - replace netplay_log_connection with calls /* TODO/FIXME - replace netplay_log_connection with calls
* to inet_ntop_compat and move runloop message queue pushing * to inet_ntop_compat and move runloop message queue pushing
@ -205,7 +205,7 @@ bool netplay_handshake_init_send(netplay_t *netplay,
unsigned conn_salt = 0; unsigned conn_salt = 0;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
header[0] = htonl(netplay_magic); header[0] = htonl(NETPLAY_MAGIC);
header[1] = htonl(netplay_platform_magic()); header[1] = htonl(netplay_platform_magic());
header[2] = htonl(NETPLAY_COMPRESSION_SUPPORTED); header[2] = htonl(NETPLAY_COMPRESSION_SUPPORTED);
header[3] = 0; header[3] = 0;
@ -322,7 +322,7 @@ bool netplay_handshake_init(netplay_t *netplay,
goto error; goto error;
} }
if (ntohl(header[0]) != netplay_magic) if (ntohl(header[0]) != NETPLAY_MAGIC)
{ {
dmsg = msg_hash_to_str(MSG_NETPLAY_NOT_RETROARCH); dmsg = msg_hash_to_str(MSG_NETPLAY_NOT_RETROARCH);
goto error; goto error;
@ -388,10 +388,8 @@ bool netplay_handshake_init(netplay_t *netplay,
{ {
ctrans = &netplay->compress_nil; ctrans = &netplay->compress_nil;
if (!ctrans->compression_backend) if (!ctrans->compression_backend)
{
ctrans->compression_backend = ctrans->compression_backend =
trans_stream_get_pipe_backend(); trans_stream_get_pipe_backend();
}
connection->compression_supported = 0; connection->compression_supported = 0;
} }
@ -848,7 +846,6 @@ bool netplay_handshake_pre_info(netplay_t *netplay,
if (recvd < 0 || if (recvd < 0 ||
ntohl(info_buf.cmd[0]) != NETPLAY_CMD_INFO) ntohl(info_buf.cmd[0]) != NETPLAY_CMD_INFO)
{ {
RARCH_ERR("Failed to receive netplay info.\n");
return false; return false;
} }
@ -1147,33 +1144,22 @@ bool netplay_handshake_pre_sync(netplay_t *netplay,
bool netplay_handshake(netplay_t *netplay, bool netplay_handshake(netplay_t *netplay,
struct netplay_connection *connection, bool *had_input) struct netplay_connection *connection, bool *had_input)
{ {
bool ret = false;
switch (connection->mode) switch (connection->mode)
{ {
case NETPLAY_CONNECTION_INIT: case NETPLAY_CONNECTION_INIT:
ret = netplay_handshake_init(netplay, connection, had_input); return netplay_handshake_init(netplay, connection, had_input);
break;
case NETPLAY_CONNECTION_PRE_NICK: case NETPLAY_CONNECTION_PRE_NICK:
ret = netplay_handshake_pre_nick(netplay, connection, had_input); return netplay_handshake_pre_nick(netplay, connection, had_input);
break;
case NETPLAY_CONNECTION_PRE_PASSWORD: case NETPLAY_CONNECTION_PRE_PASSWORD:
ret = netplay_handshake_pre_password(netplay, connection, had_input); return netplay_handshake_pre_password(netplay, connection, had_input);
break;
case NETPLAY_CONNECTION_PRE_INFO: case NETPLAY_CONNECTION_PRE_INFO:
ret = netplay_handshake_pre_info(netplay, connection, had_input); return netplay_handshake_pre_info(netplay, connection, had_input);
break;
case NETPLAY_CONNECTION_PRE_SYNC: case NETPLAY_CONNECTION_PRE_SYNC:
ret = netplay_handshake_pre_sync(netplay, connection, had_input); return netplay_handshake_pre_sync(netplay, connection, had_input);
break;
case NETPLAY_CONNECTION_NONE: case NETPLAY_CONNECTION_NONE:
default: default:
return false; break;
} }
if (connection->mode >= NETPLAY_CONNECTION_CONNECTED && return false;
!netplay_send_cur_input(netplay, connection))
return false;
return ret;
} }