When using the new core netpacket interface for netplay, don't synchronize the host SRAM to a joining client (#15797)

Fix netplay connection not getting marked as reusable while the new core netpacket interface is enabled
This commit is contained in:
Bernhard Schelling 2023-10-14 02:53:22 +09:00 committed by GitHub
parent a8e6e5db29
commit d096effe7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1268,6 +1268,9 @@ static bool netplay_handshake_sync(netplay_t *netplay,
if (netplay->local_paused || netplay->remote_paused)
client_num |= NETPLAY_CMD_SYNC_BIT_PAUSED;
/* send sram unless running with netpacket interface */
if (netplay->modus != NETPLAY_MODUS_CORE_PACKET_INTERFACE)
{
mem_info.id = RETRO_MEMORY_SAVE_RAM;
#ifdef HAVE_THREADS
autosave_lock();
@ -1277,6 +1280,7 @@ static bool netplay_handshake_sync(netplay_t *netplay,
#ifdef HAVE_THREADS
autosave_unlock();
#endif
}
/* Send basic sync info */
cmd[0] = htonl(NETPLAY_CMD_SYNC);
@ -1700,7 +1704,7 @@ static bool netplay_handshake_pre_sync(netplay_t *netplay,
uint32_t cmd[2];
uint32_t cmd_size;
uint32_t new_frame_count, client_num;
uint32_t local_sram_size, remote_sram_size;
uint32_t local_sram_size = 0, remote_sram_size;
size_t i, j;
ssize_t recvd;
char new_nick[NETPLAY_NICK_LEN];
@ -1825,7 +1829,9 @@ static bool netplay_handshake_pre_sync(netplay_t *netplay,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
}
/* Now check the SRAM */
/* Now check the SRAM, but ignore it when using netpacket interface */
if (netplay->modus != NETPLAY_MODUS_CORE_PACKET_INTERFACE)
{
mem_info.id = RETRO_MEMORY_SAVE_RAM;
#ifdef HAVE_THREADS
autosave_lock();
@ -1835,6 +1841,8 @@ static bool netplay_handshake_pre_sync(netplay_t *netplay,
#ifdef HAVE_THREADS
autosave_unlock();
#endif
}
remote_sram_size = cmd_size - (2*sizeof(uint32_t)
/* Controller devices */
+ MAX_INPUT_DEVICES*sizeof(uint32_t)
@ -4161,11 +4169,29 @@ static void netplay_hangup(netplay_t *netplay,
uint32_t client_num = (uint32_t)
(connection - netplay->connections + 1);
if (netplay->modus != NETPLAY_MODUS_CORE_PACKET_INTERFACE)
{
/* This special mode keeps the connection object
alive long enough to send the disconnection
message at the correct time */
connection->mode = NETPLAY_CONNECTION_DELAYED_DISCONNECT;
connection->delay_frame = netplay->read_frame_count[client_num];
}
else
{
/* With netpacket interface we can send the mode change now */
struct mode_payload payload;
payload.frame = htonl(netplay->self_frame_count);
payload.mode = htonl(client_num);
payload.devices = 0;
memcpy(payload.share_modes, netplay->device_share_modes,
sizeof(payload.share_modes));
memcpy(payload.nick, connection->nick, sizeof(payload.nick));
netplay_send_raw_cmd_all(netplay, connection,
NETPLAY_CMD_MODE, &payload, sizeof(payload));
connection->mode = NETPLAY_CONNECTION_NONE;
}
/* Mark them as not playing anymore */
netplay->connected_players &= ~(1L<<client_num);
@ -4191,6 +4217,7 @@ static void netplay_delayed_state_change(netplay_t *netplay)
{
size_t i;
struct mode_payload payload;
NETPLAY_ASSERT_MODUS(NETPLAY_MODUS_INPUT_FRAME_SYNC);
payload.devices = 0;
memcpy(payload.share_modes, netplay->device_share_modes,
@ -7769,10 +7796,6 @@ static bool netplay_poll(netplay_t *netplay, bool block_libretro_input)
/* Read netplay input. */
netplay_poll_net_input(netplay);
/* Handle any delayed state changes */
if (netplay->is_server)
netplay_delayed_state_change(netplay);
if (networking_driver_st.core_netpacket_interface
&& networking_driver_st.core_netpacket_interface->poll
&& netplay->self_mode == NETPLAY_CONNECTION_PLAYING)