summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2007-08-09 00:03:41 +0000
committerSimon Howard2007-08-09 00:03:41 +0000
commit7e59c3bc40bf8c3ffdd5d43978160feb643d71d2 (patch)
treed7ad1a1b03993aadfc3c450917924aa3fb4acebb
parent8d99dbd721ac4c049ce6aeeee3be57b232f2ef8e (diff)
downloadchocolate-doom-7e59c3bc40bf8c3ffdd5d43978160feb643d71d2.tar.gz
chocolate-doom-7e59c3bc40bf8c3ffdd5d43978160feb643d71d2.tar.bz2
chocolate-doom-7e59c3bc40bf8c3ffdd5d43978160feb643d71d2.zip
Disconnect any remaining drones when the last real player quits.
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 954
-rw-r--r--src/net_server.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/net_server.c b/src/net_server.c
index 0db25f40..9f7b1957 100644
--- a/src/net_server.c
+++ b/src/net_server.c
@@ -1382,6 +1382,27 @@ void NET_SV_CheckDeadlock(net_client_t *client)
}
}
+// 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 @@ static void NET_SV_RunClient(net_client_t *client)
// 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();
}
}