mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-29 03:00:24 +00:00
Try to catch up if we're falling behind our peer, not anyone
In the previous catch-up system, we would only try to catch up if we were falling behind the farthest-behind peer. However, as they would also only try to catch up to us, everyone basically agreed to the worst-case latency. It makes more sense to try to be in parity with your direct peer than with indirect connections.
This commit is contained in:
parent
b535412914
commit
8195a5bcee
@ -344,6 +344,8 @@ process:
|
||||
*/
|
||||
void netplay_sync_post_frame(netplay_t *netplay, bool stalled)
|
||||
{
|
||||
uint32_t cmp_frame_count;
|
||||
|
||||
/* Unless we're stalling, we've just finished running a frame */
|
||||
if (!stalled)
|
||||
{
|
||||
@ -487,11 +489,16 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled)
|
||||
netplay->force_rewind = false;
|
||||
}
|
||||
|
||||
if (netplay->is_server)
|
||||
cmp_frame_count = netplay->unread_frame_count;
|
||||
else
|
||||
cmp_frame_count = netplay->server_frame_count;
|
||||
|
||||
/* If we're behind, try to catch up */
|
||||
if (netplay->catch_up)
|
||||
{
|
||||
/* Are we caught up? */
|
||||
if (netplay->self_frame_count >= netplay->unread_frame_count)
|
||||
if (netplay->self_frame_count >= cmp_frame_count)
|
||||
{
|
||||
netplay->catch_up = false;
|
||||
input_driver_unset_nonblock_state();
|
||||
@ -499,10 +506,10 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled)
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
else if (!stalled)
|
||||
{
|
||||
/* Are we falling behind? */
|
||||
if (netplay->self_frame_count < netplay->unread_frame_count - 2)
|
||||
if (netplay->self_frame_count < cmp_frame_count - 2)
|
||||
{
|
||||
netplay->catch_up = true;
|
||||
input_driver_set_nonblock_state();
|
||||
|
Loading…
Reference in New Issue
Block a user