diff options
author | Patric Stout <truebrain@openttd.org> | 2021-08-23 19:38:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-23 19:38:02 +0200 |
commit | e31b5d387021c6d39b257840137c1f5da184d2cf (patch) | |
tree | 26a2fb3a0af2339b73e280aa6b91192456d4f3a8 /src/network | |
parent | b2f0491a90e6d48286915169a0dab62b52936da8 (diff) | |
download | openttd-e31b5d387021c6d39b257840137c1f5da184d2cf.tar.xz |
Fix #9490: [Network] a full server couldn't be queried either (#9508)
You can now still query a full server, as long as the maximum
amount of allowed connections isn't reached. This means that as
long as there are not 255 clients connected to a server, you can
always connect to query.
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/network_server.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index d28b818bf..993053469 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -305,7 +305,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::CloseConnection(NetworkRecvSta /* static */ bool ServerNetworkGameSocketHandler::AllowConnection() { extern byte _network_clients_connected; - bool accept = _network_clients_connected < MAX_CLIENTS && _network_game_info.clients_on < _settings_client.network.max_clients; + bool accept = _network_clients_connected < MAX_CLIENTS; /* We can't go over the MAX_CLIENTS limit here. However, the * pool must have place for all clients and ourself. */ @@ -805,6 +805,11 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet *p) return this->SendError(NETWORK_ERROR_NOT_EXPECTED); } + if (_network_game_info.clients_on >= _settings_client.network.max_clients) { + /* Turns out we are full. Inform the user about this. */ + return this->SendError(NETWORK_ERROR_FULL); + } + std::string client_revision = p->Recv_string(NETWORK_REVISION_LENGTH); uint32 newgrf_version = p->Recv_uint32(); |