Fix stall-out causing total disconnection with >2 players

This commit is contained in:
Gregor Richards 2019-02-17 21:37:58 -05:00
parent 45287628d4
commit c0ed989738
2 changed files with 12 additions and 4 deletions

View File

@ -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;

View File

@ -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 */