ref: ad0d0d1ccbcba4ff66dc3843d78dd1de90cd1fa3
parent: ecdd879374fee32f48fe2551873cb4801e39711c
author: Simon Howard <[email protected]>
date: Sat Sep 30 06:22:48 EDT 2006
Make the server stop sending if one of the clients stops acknowledging. Fix check on number of players on connect. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 682
--- a/src/net_server.c
+++ b/src/net_server.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: net_server.c 680 2006-09-29 21:25:13Z fraggle $
+// $Id: net_server.c 682 2006-09-30 10:22:48Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -387,18 +387,14 @@
return count;
}
+// Find the latest tic which has been acknowledged as received by
+// all clients.
-// Possibly advance the recv window if all connected clients have
-// used the data in the window
-
-static void NET_SV_AdvanceWindow(void)
+static int NET_SV_LatestAcknowledged(void)
{
- int i;
int lowtic = -1;
+ int i;
- // Find the smallest value of client->acknowledged for all connected
- // clients
-
for (i=0; i<MAXNETNODES; ++i)
{
if (ClientConnected(&clients[i]))
@@ -410,6 +406,20 @@
}
}
+ return lowtic;
+}
+
+
+// Possibly advance the recv window if all connected clients have
+// used the data in the window
+
+static void NET_SV_AdvanceWindow(void)
+{
+ int lowtic;
+ int i;
+
+ lowtic = NET_SV_LatestAcknowledged();
+
if (lowtic < 0)
{
return;
@@ -648,7 +658,8 @@
NET_SV_AssignPlayers();
num_players = NET_SV_NumPlayers();
- if (num_players >= MAXPLAYERS)
+ if ((!cl_drone && num_players >= MAXPLAYERS)
+ || NET_SV_NumClients() >= MAXNETNODES)
{
NET_SV_SendReject(addr, "Server is full!");
return;
@@ -1280,6 +1291,16 @@
int i;
int starttic, endtic;
+ // If a client has not sent any acknowledgments for a while,
+ // wait until they catch up.
+
+ if (client->sendseq - NET_SV_LatestAcknowledged() > 40)
+ {
+ return;
+ }
+
+ // Work out the index into the receive window
+
recv_index = client->sendseq - recvwindow_start;
if (recv_index < 0 || recv_index >= BACKUPTICS)