mirror of
https://github.com/libretro/RetroArch
synced 2025-03-30 07:20:36 +00:00
(Netplay) Cleanups
This commit is contained in:
parent
c4e04a6d09
commit
fa328c1590
@ -1328,15 +1328,13 @@ static void netplay_core_reset(netplay_t *netplay)
|
||||
*
|
||||
* Get the preferred share mode
|
||||
*/
|
||||
uint8_t netplay_settings_share_mode(void)
|
||||
uint8_t netplay_settings_share_mode(unsigned share_digital, unsigned share_analog)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
uint8_t share_mode = 0;
|
||||
uint8_t share_mode = 0;
|
||||
|
||||
if (settings->uints.netplay_share_digital
|
||||
|| settings->uints.netplay_share_analog)
|
||||
if (share_digital || share_analog)
|
||||
{
|
||||
switch (settings->uints.netplay_share_digital)
|
||||
switch (share_digital)
|
||||
{
|
||||
case RARCH_NETPLAY_SHARE_DIGITAL_OR:
|
||||
share_mode |= NETPLAY_SHARE_DIGITAL_OR;
|
||||
@ -1350,7 +1348,7 @@ uint8_t netplay_settings_share_mode(void)
|
||||
default:
|
||||
share_mode |= NETPLAY_SHARE_NO_PREFERENCE;
|
||||
}
|
||||
switch (settings->uints.netplay_share_analog)
|
||||
switch (share_analog)
|
||||
{
|
||||
case RARCH_NETPLAY_SHARE_ANALOG_MAX:
|
||||
share_mode |= NETPLAY_SHARE_ANALOG_MAX;
|
||||
|
@ -202,6 +202,7 @@ bool netplay_handshake_init_send(netplay_t *netplay,
|
||||
struct netplay_connection *connection)
|
||||
{
|
||||
uint32_t header[6];
|
||||
unsigned conn_salt = 0;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
header[0] = htonl(netplay_magic);
|
||||
@ -221,13 +222,11 @@ bool netplay_handshake_init_send(netplay_t *netplay,
|
||||
connection->salt = simple_rand_uint32();
|
||||
if (connection->salt == 0)
|
||||
connection->salt = 1;
|
||||
header[3] = htonl(connection->salt);
|
||||
}
|
||||
else
|
||||
{
|
||||
header[3] = htonl(0);
|
||||
conn_salt = connection->salt;
|
||||
}
|
||||
|
||||
header[3] = htonl(conn_salt);
|
||||
|
||||
if (!netplay_send(&connection->send_packet_buffer, connection->fd, header,
|
||||
sizeof(header)) ||
|
||||
!netplay_send_flush(&connection->send_packet_buffer, connection->fd, false))
|
||||
@ -273,7 +272,7 @@ static void handshake_password(void *ignore, const char *line)
|
||||
struct password_buf_s password_buf;
|
||||
char password[8+NETPLAY_PASS_LEN]; /* 8 for salt, 128 for password */
|
||||
char hash[NETPLAY_PASS_HASH_LEN+1]; /* + NULL terminator */
|
||||
netplay_t *netplay = handshake_password_netplay;
|
||||
netplay_t *netplay = handshake_password_netplay;
|
||||
struct netplay_connection *connection = &netplay->connections[0];
|
||||
|
||||
snprintf(password, sizeof(password), "%08X", connection->salt);
|
||||
@ -738,7 +737,6 @@ bool netplay_handshake_pre_nick(netplay_t *netplay,
|
||||
return false;
|
||||
connection->mode = NETPLAY_CONNECTION_PRE_INFO;
|
||||
}
|
||||
|
||||
}
|
||||
/* Client needs to wait for INFO */
|
||||
else
|
||||
@ -800,7 +798,7 @@ bool netplay_handshake_pre_password(netplay_t *netplay,
|
||||
|
||||
if (!memcmp(password_buf.password, hash, NETPLAY_PASS_HASH_LEN))
|
||||
{
|
||||
correct = true;
|
||||
correct = true;
|
||||
connection->can_play = true;
|
||||
}
|
||||
}
|
||||
@ -920,7 +918,6 @@ bool netplay_handshake_pre_info(netplay_t *netplay,
|
||||
{
|
||||
if (!netplay_handshake_sync(netplay, connection))
|
||||
return false;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -952,7 +949,6 @@ bool netplay_handshake_pre_sync(netplay_t *netplay,
|
||||
retro_ctx_controller_info_t pad;
|
||||
char new_nick[NETPLAY_NICK_LEN];
|
||||
retro_ctx_memory_info_t mem_info;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
RECV(cmd, sizeof(cmd))
|
||||
{
|
||||
@ -1134,8 +1130,11 @@ bool netplay_handshake_pre_sync(netplay_t *netplay,
|
||||
netplay_recv_flush(&connection->recv_packet_buffer);
|
||||
|
||||
/* Ask to switch to playing mode if we should */
|
||||
if (!settings->bools.netplay_start_as_spectator)
|
||||
return netplay_cmd_mode(netplay, NETPLAY_CONNECTION_PLAYING);
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
if (!settings->bools.netplay_start_as_spectator)
|
||||
return netplay_cmd_mode(netplay, NETPLAY_CONNECTION_PLAYING);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -487,9 +487,8 @@ bool netplay_cmd_mode(netplay_t *netplay,
|
||||
enum rarch_netplay_connection_mode mode)
|
||||
{
|
||||
uint32_t cmd, device;
|
||||
uint32_t payloadBuf = 0, *payload = NULL;
|
||||
uint8_t share_mode;
|
||||
settings_t *settings = config_get_ptr();
|
||||
uint32_t payload_buf = 0, *payload = NULL;
|
||||
uint8_t share_mode = 0;
|
||||
struct netplay_connection *connection = NULL;
|
||||
|
||||
if (!netplay->is_server)
|
||||
@ -502,25 +501,31 @@ bool netplay_cmd_mode(netplay_t *netplay,
|
||||
break;
|
||||
|
||||
case NETPLAY_CONNECTION_SLAVE:
|
||||
payloadBuf = NETPLAY_CMD_PLAY_BIT_SLAVE;
|
||||
payload_buf = NETPLAY_CMD_PLAY_BIT_SLAVE;
|
||||
/* no break */
|
||||
|
||||
case NETPLAY_CONNECTION_PLAYING:
|
||||
payload = &payloadBuf;
|
||||
|
||||
/* Add a share mode if requested */
|
||||
share_mode = netplay_settings_share_mode();
|
||||
payloadBuf |= ((uint32_t) share_mode) << 16;
|
||||
|
||||
/* Request devices */
|
||||
for (device = 0; device < MAX_INPUT_DEVICES; device++)
|
||||
{
|
||||
if (settings->bools.netplay_request_devices[device])
|
||||
payloadBuf |= 1<<device;
|
||||
}
|
||||
settings_t *settings = config_get_ptr();
|
||||
payload = &payload_buf;
|
||||
|
||||
payloadBuf = htonl(payloadBuf);
|
||||
cmd = NETPLAY_CMD_PLAY;
|
||||
/* Add a share mode if requested */
|
||||
share_mode = netplay_settings_share_mode(
|
||||
settings->uints.netplay_share_digital,
|
||||
settings->uints.netplay_share_analog
|
||||
);
|
||||
payload_buf |= ((uint32_t) share_mode) << 16;
|
||||
|
||||
/* Request devices */
|
||||
for (device = 0; device < MAX_INPUT_DEVICES; device++)
|
||||
{
|
||||
if (settings->bools.netplay_request_devices[device])
|
||||
payload_buf |= 1<<device;
|
||||
}
|
||||
|
||||
payload_buf = htonl(payload_buf);
|
||||
cmd = NETPLAY_CMD_PLAY;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -716,7 +716,7 @@ void netplay_load_savestate(netplay_t *netplay,
|
||||
*
|
||||
* Get the preferred share mode
|
||||
*/
|
||||
uint8_t netplay_settings_share_mode(void);
|
||||
uint8_t netplay_settings_share_mode(unsigned share_digital, unsigned share_analog);
|
||||
|
||||
/**
|
||||
* input_poll_net
|
||||
|
@ -109,12 +109,10 @@ static JSON_Parser_HandlerResult JSON_CALL StringHandler(
|
||||
{
|
||||
if (pCtx->cur_field)
|
||||
{
|
||||
/* CRC comes in as a string but it is stored
|
||||
* as an unsigned casted to int. */
|
||||
if (string_is_equal(pCtx->cur_field, "game_crc"))
|
||||
{
|
||||
/* CRC comes in as a string but it is stored
|
||||
* as an unsigned casted to int. */
|
||||
*((int*)pCtx->cur_member) = (int)strtoul(pValue, NULL, 16);
|
||||
}
|
||||
else
|
||||
strlcpy((char*)pCtx->cur_member, pValue, PATH_MAX_LENGTH);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user