mirror of
https://github.com/libretro/RetroArch
synced 2025-02-01 00:32:46 +00:00
Merge pull request #3699 from GregorR/netplay-remove-workarounds
Removing Netplay workarounds in anticipation of quirks API
This commit is contained in:
commit
6d47b57af7
@ -720,20 +720,15 @@ static bool netplay_poll(void)
|
|||||||
if (netplay_is_server(netplay_data) && netplay_data->spectate.enabled)
|
if (netplay_is_server(netplay_data) && netplay_data->spectate.enabled)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* WORKAROUND: The only reason poll_input is ignored in the first frame is
|
/* Read Netplay input, block if we're configured to stall for input every
|
||||||
* that some cores can't report state size until after the first frame. */
|
* frame */
|
||||||
if (netplay_data->self_frame_count > 0 || netplay_data->stall || netplay_data->spectate.enabled)
|
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
|
hangup(netplay_data);
|
||||||
* frame */
|
return false;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Simulate the input if we don't have real input */
|
/* 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)
|
if (!netplay->buffer)
|
||||||
return false;
|
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
|
unsigned i;
|
||||||
* early. */
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -61,18 +61,14 @@ static bool netplay_net_pre_frame(netplay_t *netplay)
|
|||||||
{
|
{
|
||||||
retro_ctx_serialize_info_t serial_info;
|
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_const = NULL;
|
||||||
serial_info.data = netplay->buffer[netplay->self_ptr].state;
|
serial_info.data = netplay->buffer[netplay->self_ptr].state;
|
||||||
serial_info.size = netplay->state_size;
|
serial_info.size = netplay->state_size;
|
||||||
|
|
||||||
if (!netplay->has_connection && netplay->self_frame_count < TOO_EARLY_TO_SAVE)
|
if (netplay->savestates_work && core_serialize(&serial_info))
|
||||||
{
|
|
||||||
/* 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->force_send_savestate)
|
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_ptr = NEXT_PTR(netplay->self_ptr);
|
||||||
netplay->self_frame_count++;
|
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 */
|
/* Only relevant if we're connected */
|
||||||
if (!netplay->has_connection)
|
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_ptr = netplay->other_ptr;
|
||||||
netplay->replay_frame_count = netplay->other_frame_count;
|
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 = NULL;
|
||||||
serial_info.data_const = netplay->buffer[netplay->replay_ptr].state;
|
serial_info.data_const = netplay->buffer[netplay->replay_ptr].state;
|
||||||
serial_info.size = netplay->state_size;
|
serial_info.size = netplay->state_size;
|
||||||
|
@ -36,29 +36,6 @@
|
|||||||
**/
|
**/
|
||||||
static bool netplay_spectate_pre_frame(netplay_t *netplay)
|
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))
|
if (netplay_is_server(netplay))
|
||||||
{
|
{
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user