From c0ed989738f0bcd35ac5e75e00132e29dc94e73f Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Sun, 17 Feb 2019 21:37:58 -0500 Subject: [PATCH] Fix stall-out causing total disconnection with >2 players --- network/netplay/netplay_frontend.c | 11 +++++++++-- network/netplay/netplay_init.c | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/network/netplay/netplay_frontend.c b/network/netplay/netplay_frontend.c index c5315e3076..a1d9799f66 100644 --- a/network/netplay/netplay_frontend.c +++ b/network/netplay/netplay_frontend.c @@ -500,17 +500,24 @@ static bool netplay_poll(void) /* Stalled out! */ if (netplay_data->is_server) { + bool fixed = false; for (i = 0; i < netplay_data->connections_size; i++) { struct netplay_connection *connection = &netplay_data->connections[i]; if (connection->active && connection->mode == NETPLAY_CONNECTION_PLAYING && - connection->stall && - now - connection->stall_time >= MAX_SERVER_STALL_TIME_USEC) + connection->stall) { netplay_hangup(netplay_data, connection); + fixed = true; } } + + if (fixed) { + /* Not stalled now :) */ + netplay_data->stall = NETPLAY_STALL_NONE; + return true; + } } else goto catastrophe; diff --git a/network/netplay/netplay_init.c b/network/netplay/netplay_init.c index 4822b31614..434fe781f2 100644 --- a/network/netplay/netplay_init.c +++ b/network/netplay/netplay_init.c @@ -376,8 +376,9 @@ static bool netplay_init_buffers(netplay_t *netplay) { struct delta_frame *delta_frames = NULL; - /* Enough to get ahead or behind by MAX_STALL_FRAMES frames */ - netplay->buffer_size = NETPLAY_MAX_STALL_FRAMES + 1; + /* Enough to get ahead or behind by MAX_STALL_FRAMES frames, plus one for + * other remote clients, plus one to send the stall message */ + netplay->buffer_size = NETPLAY_MAX_STALL_FRAMES + 2; /* If we're the server, we need enough to get ahead AND behind by * MAX_STALL_FRAMES frame */