From c81b022a7d0b4358437802a8d66ed498b060e0b7 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Fri, 23 Sep 2016 22:18:10 -0400 Subject: [PATCH 1/4] Fix conflation of delay_frames and check_frames in configuration.c --- configuration.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration.c b/configuration.c index 9994b02d32..5a52a7ae00 100644 --- a/configuration.c +++ b/configuration.c @@ -1839,7 +1839,7 @@ static bool config_load_file(const char *path, bool set_defaults, if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_NETPLAY_DELAY_FRAMES)) CONFIG_GET_INT_BASE(conf, global, netplay.sync_frames, "netplay_delay_frames"); if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_NETPLAY_CHECK_FRAMES)) - CONFIG_GET_INT_BASE(conf, global, netplay.sync_frames, "netplay_check_frames"); + CONFIG_GET_INT_BASE(conf, global, netplay.check_frames, "netplay_check_frames"); if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_NETPLAY_IP_PORT)) CONFIG_GET_INT_BASE(conf, global, netplay.port, "netplay_ip_port"); #endif From ae92cfeac2dda3b5b0ecf4f94a194c2ddc9616eb Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Fri, 23 Sep 2016 22:18:56 -0400 Subject: [PATCH 2/4] More care in check_frames code so we don't check CRCs from a previous connection --- network/netplay/netplay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index 6134b19331..d7f5ca551c 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -380,7 +380,7 @@ static bool netplay_get_cmd(netplay_t *netplay) * arithmetic. */ do { - if (netplay->buffer[tmp_ptr].frame == buffer[0]) + if (netplay->buffer[tmp_ptr].used && netplay->buffer[tmp_ptr].frame == buffer[0]) { found = true; break; From 236839e22fa87d8e97efcdd1ad42ace4b90034f9 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Fri, 23 Sep 2016 22:20:47 -0400 Subject: [PATCH 3/4] Reset netplay stall state upon disconnection --- network/netplay/netplay.c | 1 + 1 file changed, 1 insertion(+) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index d7f5ca551c..e43e753ae7 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -82,6 +82,7 @@ static void hangup(netplay_t *netplay) netplay->remote_paused = false; netplay->flip = false; netplay->flip_frame = 0; + netplay->stall = 0; } } From fa5b75b63589f814c917a3d1f58e054bf1fd2b54 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Fri, 23 Sep 2016 22:21:53 -0400 Subject: [PATCH 4/4] Bugfixes in how we reset state on a late Netplay connection --- network/netplay/netplay_common.c | 3 ++- network/netplay/netplay_net.c | 10 ++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/network/netplay/netplay_common.c b/network/netplay/netplay_common.c index 7384771b79..7bb5b09789 100644 --- a/network/netplay/netplay_common.c +++ b/network/netplay/netplay_common.c @@ -280,9 +280,10 @@ bool netplay_get_info(netplay_t *netplay) netplay->self_frame_count = netplay->read_frame_count = netplay->other_frame_count = 0; for (i = 0; i < netplay->buffer_size; i++) { + netplay->buffer[i].used = false; if (i == netplay->self_ptr) { - netplay->buffer[i].frame = 0; + netplay_delta_frame_ready(netplay, &netplay->buffer[i], 0); } else { diff --git a/network/netplay/netplay_net.c b/network/netplay/netplay_net.c index 6724b39aa5..e31f52beb0 100644 --- a/network/netplay/netplay_net.c +++ b/network/netplay/netplay_net.c @@ -124,17 +124,15 @@ static bool netplay_net_pre_frame(netplay_t *netplay) { netplay->has_connection = true; - /* If we're not at frame 0, send them the savestate */ - if (netplay->self_frame_count != 0 && netplay->savestates_work) + /* Send them the savestate */ + if (netplay->savestates_work) { - serial_info.size = netplay->state_size; - serial_info.data_const = netplay->buffer[netplay->self_ptr].state; - netplay_load_savestate(netplay, &serial_info, false); + 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; - netplay->read_ptr = netplay->other_ptr = netplay->read_ptr; + netplay->read_ptr = netplay->other_ptr = netplay->self_ptr; /* Unstall if we were waiting for this */ if (netplay->stall == RARCH_NETPLAY_STALL_NO_CONNECTION)