Removing Netplay workarounds in anticipation of quirks API

This commit is contained in:
Gregor Richards 2016-09-30 16:00:49 -04:00
parent e7513bec62
commit 01d379066e
3 changed files with 30 additions and 88 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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;