Fix spectator mode to work with the late-serialization workaround

This commit is contained in:
Gregor Richards 2016-09-29 17:28:01 -04:00
parent 03215a831f
commit 5b62fbb355
2 changed files with 24 additions and 1 deletions

View File

@ -721,7 +721,7 @@ static bool netplay_poll(void)
/* 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)
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 */

View File

@ -36,6 +36,29 @@
**/
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)
{
int 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;