shithub: choc

Download patch

ref: b283ed0be692f0a9d96721013bda361717452665
parent: ba0390ac0a78e28a1f36925a1df891f3682a7b20
author: Simon Howard <fraggle@gmail.com>
date: Thu Oct 13 18:44:57 EDT 2011

Fix lockup just after startup of single-player multiplayer games. Don't
allow the server to advance too far ahead of the client.

Subversion-branch: /branches/v2-branch
Subversion-revision: 2420

--- a/src/net_server.c
+++ b/src/net_server.c
@@ -1294,6 +1294,7 @@
 {
     net_full_ticcmd_t cmd;
     int recv_index;
+    int num_players;
     int i;
     int starttic, endtic;
 
@@ -1317,6 +1318,8 @@
     // Check if we can generate a new entry for the send queue
     // using the data in recvwindow.
 
+    num_players = 0;
+
     for (i=0; i<MAXPLAYERS; ++i)
     {
         if (sv_players[i] == client)
@@ -1338,6 +1341,19 @@
 
             return;
         }
+
+        ++num_players;
+    }
+
+    // If this is a game with only a single player in it, we might
+    // be sending a ticcmd set containing 0 ticcmds. This is fine;
+    // however, there's nothing to stop the game running on ahead
+    // and never stopping. Don't let the server get too far ahead
+    // of the client.
+
+    if (num_players == 0 && client->sendseq > recvwindow_start + 10)
+    {
+        return;
     }
 
     //printf("SV: have complete ticcmd for %i\n", client->sendseq);