mirror of
https://github.com/libretro/RetroArch
synced 2025-02-24 18:39:59 +00:00
Support for catching up if the netplay peer is ahead of us.
This commit is contained in:
parent
4e01481b39
commit
bade067d9a
@ -43,6 +43,7 @@ enum rarch_netplay_ctl_state
|
||||
RARCH_NETPLAY_CTL_IS_DATA_INITED,
|
||||
RARCH_NETPLAY_CTL_PAUSE,
|
||||
RARCH_NETPLAY_CTL_UNPAUSE,
|
||||
RARCH_NETPLAY_CTL_CATCH_UP,
|
||||
RARCH_NETPLAY_CTL_LOAD_SAVESTATE,
|
||||
RARCH_NETPLAY_CTL_DISCONNECT
|
||||
};
|
||||
|
@ -927,6 +927,9 @@ bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data)
|
||||
case RARCH_NETPLAY_CTL_UNPAUSE:
|
||||
netplay_frontend_paused(netplay_data, false);
|
||||
break;
|
||||
case RARCH_NETPLAY_CTL_CATCH_UP:
|
||||
ret = netplay_data->catch_up;
|
||||
break;
|
||||
case RARCH_NETPLAY_CTL_LOAD_SAVESTATE:
|
||||
netplay_load_savestate(netplay_data, (retro_ctx_serialize_info_t*)data, true);
|
||||
break;
|
||||
|
@ -409,6 +409,9 @@ struct netplay
|
||||
enum rarch_netplay_stall_reason stall;
|
||||
retro_time_t stall_time;
|
||||
|
||||
/* Opposite of stalling, should we be catching up? */
|
||||
bool catch_up;
|
||||
|
||||
/* Frequency with which to check CRCs */
|
||||
uint32_t check_frames;
|
||||
};
|
||||
|
@ -347,6 +347,7 @@ void netplay_sync_post_frame(netplay_t *netplay)
|
||||
{
|
||||
netplay->other_frame_count = netplay->self_frame_count;
|
||||
netplay->other_ptr = netplay->self_ptr;
|
||||
netplay->catch_up = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -454,6 +455,12 @@ void netplay_sync_post_frame(netplay_t *netplay)
|
||||
netplay->force_rewind = false;
|
||||
}
|
||||
|
||||
/* If we're behind, try to catch up */
|
||||
if (netplay->self_frame_count < netplay->unread_frame_count - 2)
|
||||
netplay->catch_up = true;
|
||||
else
|
||||
netplay->catch_up = false;
|
||||
|
||||
/* If we're supposed to stall, rewind (we shouldn't get this far if we're
|
||||
* stalled, so this is a last resort) */
|
||||
if (netplay->stall)
|
||||
|
@ -1226,6 +1226,11 @@ int runloop_iterate(unsigned *sleep_ms)
|
||||
if (!settings->fastforward_ratio)
|
||||
return 0;
|
||||
|
||||
#ifdef HAVE_NETWORKING
|
||||
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_CATCH_UP, NULL))
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
end:
|
||||
|
||||
current = cpu_features_get_time_usec();
|
||||
|
Loading…
x
Reference in New Issue
Block a user