shithub: choc

Download patch

ref: 7e59c3bc40bf8c3ffdd5d43978160feb643d71d2
parent: 8d99dbd721ac4c049ce6aeeee3be57b232f2ef8e
author: Simon Howard <fraggle@gmail.com>
date: Wed Aug 8 20:03:41 EDT 2007

Disconnect any remaining drones when the last real player quits.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 954

--- a/src/net_server.c
+++ b/src/net_server.c
@@ -1382,6 +1382,27 @@
     }
 }
 
+// Called when all players have disconnected.  Return to listening for 
+// players to start a new game, and disconnect any drones still connected.
+
+static void NET_SV_GameEnded(void)
+{
+    int i;
+
+    printf("Game ended, clearing out all remaining clients\n");
+
+    server_state = SERVER_WAITING_START;
+    sv_gamemode = indetermined;
+
+    for (i=0; i<MAXNETNODES; ++i)
+    {
+        if (clients[i].active)
+        {
+            NET_SV_DisconnectClient(&clients[i]);
+        }
+    }
+}
+
 // Perform any needed action on a client
 
 static void NET_SV_RunClient(net_client_t *client)
@@ -1409,11 +1430,12 @@
 
         // Are there any clients left connected?  If not, return the
         // server to the waiting-for-players state.
+        //
+	// Disconnect any drones still connected.
 
-        if (NET_SV_NumClients() <= 0)
+        if (NET_SV_NumPlayers() <= 0)
         {
-            server_state = SERVER_WAITING_START;
-            sv_gamemode = indetermined;
+            NET_SV_GameEnded();
         }
     }