From 5676d0b848f08a3a94aaef4727d90d20bf027c9a Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Fri, 30 Sep 2016 13:39:00 -0400 Subject: [PATCH] Adding Netplay quirk for untransmittable savestates --- network/netplay/netplay.c | 4 ++++ network/netplay/netplay_net.c | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index 6675aa22d7..0c306b3a4c 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -1280,6 +1280,10 @@ void netplay_load_savestate(netplay_t *netplay, retro_ctx_serialize_info_t *seri netplay->other_frame_count = netplay->self_frame_count; } + /* If we can't send it to the peer, loading a state was a bad idea */ + if (netplay->quirks & (NETPLAY_QUIRK_NO_SAVESTATES|NETPLAY_QUIRK_NO_TRANSMISSION)) + return; + /* And send it to the peer (FIXME: this is an ugly way to do this) */ header[0] = htonl(NETPLAY_CMD_LOAD_SAVESTATE); header[1] = htonl(serial_info->size + sizeof(uint32_t)); diff --git a/network/netplay/netplay_net.c b/network/netplay/netplay_net.c index e1a2ab7fbd..a4fffb0a70 100644 --- a/network/netplay/netplay_net.c +++ b/network/netplay/netplay_net.c @@ -85,9 +85,12 @@ static bool netplay_net_pre_frame(netplay_t *netplay) * remote input on EVERY frame, because we can't recover */ netplay->quirks |= NETPLAY_QUIRK_NO_SAVESTATES; netplay->stall_frames = 0; - if (!netplay->has_connection) - netplay->stall = RARCH_NETPLAY_STALL_NO_CONNECTION; } + + /* If we can't transmit savestates, we must stall until the client is ready */ + if (!netplay->has_connection && + (netplay->quirks & (NETPLAY_QUIRK_NO_SAVESTATES|NETPLAY_QUIRK_NO_TRANSMISSION))) + netplay->stall = RARCH_NETPLAY_STALL_NO_CONNECTION; } if (netplay->is_server && !netplay->has_connection) @@ -135,10 +138,8 @@ static bool netplay_net_pre_frame(netplay_t *netplay) netplay->has_connection = true; /* Send them the savestate */ - if (!(netplay->quirks & NETPLAY_QUIRK_NO_SAVESTATES) && !(netplay->quirks & NETPLAY_QUIRK_NO_TRANSMISSION)) - { + if (!(netplay->quirks & (NETPLAY_QUIRK_NO_SAVESTATES|NETPLAY_QUIRK_NO_TRANSMISSION))) netplay_load_savestate(netplay, NULL, true); - } /* And expect the current frame from the other side */ netplay->read_frame_count = netplay->other_frame_count = netplay->self_frame_count;