summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-06-02 19:56:23 +0000
committersmatz <smatz@openttd.org>2009-06-02 19:56:23 +0000
commit2b4d37de3dfc1500288190d360fd64a5ca9b7f6e (patch)
tree20470e397c6b7cce65581a941e8f5fb45eadc39c /src/network
parent2fc0cb3e76ec36826056c661555b925b3ce43fe3 (diff)
downloadopenttd-2b4d37de3dfc1500288190d360fd64a5ca9b7f6e.tar.xz
(svn r16506) -Fix: count only active clients (not those waiting for map download) when checking min_active_clients limit
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp
index 32b1cb683..90f048b2c 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -334,14 +334,20 @@ StringID GetNetworkErrorMsg(NetworkErrorCode err)
return network_error_strings[err];
}
-/* Count the number of active clients connected */
+/**
+ * Counts the number of active clients connected.
+ * It has to be in STATUS_ACTIVE and not a spectator
+ * @return number of active clients
+ */
static uint NetworkCountActiveClients()
{
- const NetworkClientInfo *ci;
+ const NetworkClientSocket *cs;
uint count = 0;
- FOR_ALL_CLIENT_INFOS(ci) {
- if (Company::IsValidID(ci->client_playas)) count++;
+ FOR_ALL_CLIENT_SOCKETS(cs) {
+ if (cs->status != STATUS_ACTIVE) continue;
+ if (!Company::IsValidID(cs->GetInfo()->client_playas)) continue;
+ count++;
}
return count;