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! */ /* Stalled out! */
if (netplay_data->is_server) if (netplay_data->is_server)
{ {
bool fixed = false;
for (i = 0; i < netplay_data->connections_size; i++) for (i = 0; i < netplay_data->connections_size; i++)
{ {
struct netplay_connection *connection = &netplay_data->connections[i]; struct netplay_connection *connection = &netplay_data->connections[i];
if (connection->active && if (connection->active &&
connection->mode == NETPLAY_CONNECTION_PLAYING && connection->mode == NETPLAY_CONNECTION_PLAYING &&
connection->stall && connection->stall)
now - connection->stall_time >= MAX_SERVER_STALL_TIME_USEC)
{ {
netplay_hangup(netplay_data, connection); netplay_hangup(netplay_data, connection);
fixed = true;
} }
} }
if (fixed) {
/* Not stalled now :) */
netplay_data->stall = NETPLAY_STALL_NONE;
return true;
}
} }
else else
goto catastrophe; goto catastrophe;

View File

@ -376,8 +376,9 @@ static bool netplay_init_buffers(netplay_t *netplay)
{ {
struct delta_frame *delta_frames = NULL; struct delta_frame *delta_frames = NULL;
/* Enough to get ahead or behind by MAX_STALL_FRAMES frames */ /* Enough to get ahead or behind by MAX_STALL_FRAMES frames, plus one for
netplay->buffer_size = NETPLAY_MAX_STALL_FRAMES + 1; * 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 /* If we're the server, we need enough to get ahead AND behind by
* MAX_STALL_FRAMES frame */ * MAX_STALL_FRAMES frame */