From 01d379066e1f37c9b3e4c9d6c7f4a045d21e7a53 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Fri, 30 Sep 2016 16:00:49 -0400 Subject: [PATCH] Removing Netplay workarounds in anticipation of quirks API --- network/netplay/netplay.c | 43 +++++++++++++++--------- network/netplay/netplay_net.c | 52 ++---------------------------- network/netplay/netplay_spectate.c | 23 ------------- 3 files changed, 30 insertions(+), 88 deletions(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index 1e9c8dda08..5effedea0c 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -720,20 +720,15 @@ static bool netplay_poll(void) if (netplay_is_server(netplay_data) && netplay_data->spectate.enabled) return true; - /* WORKAROUND: The only reason poll_input is ignored in the first frame is - * that some cores can't report state size until after the first frame. */ - if (netplay_data->self_frame_count > 0 || netplay_data->stall || netplay_data->spectate.enabled) + /* Read Netplay input, block if we're configured to stall for input every + * frame */ + res = poll_input(netplay_data, + (netplay_data->stall_frames == 0) + && (netplay_data->read_frame_count <= netplay_data->self_frame_count)); + if (res == -1) { - /* Read Netplay input, block if we're configured to stall for input every - * frame */ - res = poll_input(netplay_data, - (netplay_data->stall_frames == 0) - && (netplay_data->read_frame_count <= netplay_data->self_frame_count)); - if (res == -1) - { - hangup(netplay_data); - return false; - } + hangup(netplay_data); + return false; } /* Simulate the input if we don't have real input */ @@ -965,9 +960,25 @@ static bool netplay_init_buffers(netplay_t *netplay, unsigned frames) if (!netplay->buffer) return false; - /* WORKAROUND: The code to initialize state buffers really should be here. - * It's been moved to work around cores that can't core_serialize_size - * early. */ + { + unsigned i; + retro_ctx_size_info_t info; + + core_serialize_size(&info); + + netplay->state_size = info.size; + + for (i = 0; i < netplay->buffer_size; i++) + { + netplay->buffer[i].state = calloc(netplay->state_size, 1); + + if (!netplay->buffer[i].state) + { + netplay->savestates_work = false; + netplay->stall_frames = 0; + } + } + } return true; } diff --git a/network/netplay/netplay_net.c b/network/netplay/netplay_net.c index c99664a59d..718b62dbbc 100644 --- a/network/netplay/netplay_net.c +++ b/network/netplay/netplay_net.c @@ -61,18 +61,14 @@ static bool netplay_net_pre_frame(netplay_t *netplay) { retro_ctx_serialize_info_t serial_info; - if (netplay_delta_frame_ready(netplay, &netplay->buffer[netplay->self_ptr], netplay->self_frame_count)) + if (netplay_delta_frame_ready(netplay, &netplay->buffer[netplay->self_ptr], netplay->self_frame_count) && + netplay->self_frame_count > 0) { serial_info.data_const = NULL; serial_info.data = netplay->buffer[netplay->self_ptr].state; serial_info.size = netplay->state_size; - if (!netplay->has_connection && netplay->self_frame_count < TOO_EARLY_TO_SAVE) - { - /* WORKAROUND: Some cores don't like being save/loadstated too early. - * If we're not even connected yet, just don't bother. */ - } - else if (netplay->savestates_work && core_serialize(&serial_info)) + if (netplay->savestates_work && core_serialize(&serial_info)) { if (netplay->force_send_savestate) { @@ -179,30 +175,6 @@ static void netplay_net_post_frame(netplay_t *netplay) netplay->self_ptr = NEXT_PTR(netplay->self_ptr); netplay->self_frame_count++; - /* WORKAROUND: We initialize the buffer states late to work around cores - * that can't even core_serialize_size early. */ - if (netplay->self_frame_count == 1 && netplay->state_size == 0) - { - unsigned i; - retro_ctx_size_info_t info; - - core_serialize_size(&info); - - netplay->state_size = info.size; - - for (i = 0; i < netplay->buffer_size; i++) - { - netplay->buffer[i].state = calloc(netplay->state_size, 1); - - if (!netplay->buffer[i].state) - { - netplay->savestates_work = false; - netplay->stall_frames = 0; - } - } - } - - /* Only relevant if we're connected */ if (!netplay->has_connection) { @@ -242,24 +214,6 @@ static void netplay_net_post_frame(netplay_t *netplay) netplay->replay_ptr = netplay->other_ptr; netplay->replay_frame_count = netplay->other_frame_count; - /* WORKAROUND: Some cores cannot serialize or unserialize too early in - * execution. We avoid the problem by forcing some phantom frames to - * pass. */ - if (netplay->self_frame_count < TOO_EARLY_TO_SAVE) - { - int frameskip; - for (frameskip = 0; frameskip < TOO_EARLY_TO_SAVE; frameskip++) - { -#if defined(HAVE_THREADS) - autosave_lock(); -#endif - core_run(); -#if defined(HAVE_THREADS) - autosave_unlock(); -#endif - } - } - serial_info.data = NULL; serial_info.data_const = netplay->buffer[netplay->replay_ptr].state; serial_info.size = netplay->state_size; diff --git a/network/netplay/netplay_spectate.c b/network/netplay/netplay_spectate.c index 49b2e3a894..e6dbbd8aac 100644 --- a/network/netplay/netplay_spectate.c +++ b/network/netplay/netplay_spectate.c @@ -36,29 +36,6 @@ **/ static bool netplay_spectate_pre_frame(netplay_t *netplay) { - /* WORKAROUND: We initialize the buffer states here as part of a workaround - * for cores that can't even core_serialize_size early. */ - if (netplay->self_frame_count == 0 && netplay->state_size == 0) - { - unsigned i; - retro_ctx_size_info_t info; - - core_serialize_size(&info); - - netplay->state_size = info.size; - - for (i = 0; i < netplay->buffer_size; i++) - { - netplay->buffer[i].state = calloc(netplay->state_size, 1); - - if (!netplay->buffer[i].state) - { - netplay->savestates_work = false; - netplay->stall_frames = 0; - } - } - } - if (netplay_is_server(netplay)) { fd_set fds;