diff --git a/network/netplay/netplay_common.c b/network/netplay/netplay_common.c index dc2033978b..98ece3813f 100644 --- a/network/netplay/netplay_common.c +++ b/network/netplay/netplay_common.c @@ -224,14 +224,17 @@ bool netplay_send_info(netplay_t *netplay) } /* Reset our frame count so it's consistent with the server */ - netplay->self_frame_count = netplay->read_frame_count = netplay->other_frame_count = 0; + netplay->self_frame_count = netplay->other_frame_count = 0; + netplay->read_frame_count = 1; for (i = 0; i < netplay->buffer_size; i++) { netplay->buffer[i].used = false; if (i == netplay->self_ptr) { netplay_delta_frame_ready(netplay, &netplay->buffer[i], 0); - netplay->read_ptr = netplay->other_ptr = i; + netplay->buffer[i].have_remote = true; + netplay->other_ptr = i; + netplay->read_ptr = NEXT_PTR(i); } else { @@ -324,14 +327,17 @@ bool netplay_get_info(netplay_t *netplay) } /* Reset our frame count so it's consistent with the client */ - netplay->self_frame_count = netplay->read_frame_count = netplay->other_frame_count = 0; + netplay->self_frame_count = netplay->other_frame_count = 0; + netplay->read_frame_count = 1; for (i = 0; i < netplay->buffer_size; i++) { netplay->buffer[i].used = false; if (i == netplay->self_ptr) { netplay_delta_frame_ready(netplay, &netplay->buffer[i], 0); - netplay->read_ptr = netplay->other_ptr = i; + netplay->buffer[i].have_remote = true; + netplay->other_ptr = i; + netplay->read_ptr = NEXT_PTR(i); } else { diff --git a/network/netplay/netplay_net.c b/network/netplay/netplay_net.c index 10019ba242..93f8e18c29 100644 --- a/network/netplay/netplay_net.c +++ b/network/netplay/netplay_net.c @@ -81,7 +81,7 @@ static bool netplay_net_pre_frame(netplay_t *netplay) serial_info.size = netplay->state_size; memset(serial_info.data, 0, serial_info.size); - if (netplay->quirks & NETPLAY_QUIRK_INITIALIZATION) + if ((netplay->quirks & NETPLAY_QUIRK_INITIALIZATION) || netplay->self_frame_count == 0) { /* Don't serialize until it's safe */ } @@ -105,6 +105,7 @@ static bool netplay_net_pre_frame(netplay_t *netplay) /* If we can't transmit savestates, we must stall until the client is ready */ if (!netplay->has_connection && + netplay->self_frame_count > 0 && (netplay->quirks & (NETPLAY_QUIRK_NO_SAVESTATES|NETPLAY_QUIRK_NO_TRANSMISSION))) netplay->stall = RARCH_NETPLAY_STALL_NO_CONNECTION; } @@ -155,7 +156,16 @@ static bool netplay_net_pre_frame(netplay_t *netplay) /* Send them the savestate */ if (!(netplay->quirks & (NETPLAY_QUIRK_NO_SAVESTATES|NETPLAY_QUIRK_NO_TRANSMISSION))) + { netplay_load_savestate(netplay, NULL, true); + } + else + { + /* Because the first frame isn't serialized, we're actually at + * frame 1 */ + netplay->self_ptr = NEXT_PTR(netplay->self_ptr); + netplay->self_frame_count = 1; + } /* And expect the current frame from the other side */ netplay->read_frame_count = netplay->other_frame_count = netplay->self_frame_count;