summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorJonathan G Rennison <j.g.rennison@gmail.com>2021-04-06 19:31:52 +0100
committerGitHub <noreply@github.com>2021-04-06 19:31:52 +0100
commit825867f2c50ce508fac442e6113da9cebbfccf75 (patch)
treee543a1baee4cf51506d131839ca85c37ee8712b9 /src/network
parent920bf703cda28e2c864531f5bc5468cff1f0ce73 (diff)
downloadopenttd-825867f2c50ce508fac442e6113da9cebbfccf75.tar.xz
Fix: [Network] State conditions for sending client info/quit packets (#8959)
Use status >= STATUS_AUTHORIZED as the state criteria for all cases where updates about other clients are sent. This avoids the case where a client is informed that another client has joined but not informed when it later quits, resulting in stale entries in the client list window.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network_server.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 9e4d0d88f..86885d598 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -456,7 +456,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendError(NetworkErrorCode err
}
for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) {
- if (new_cs->status > STATUS_AUTHORIZED && new_cs != this) {
+ if (new_cs->status >= STATUS_AUTHORIZED && new_cs != this) {
/* Some errors we filter to a more general error. Clients don't have to know the real
* reason a joining failed. */
if (error == NETWORK_ERROR_NOT_AUTHORIZED || error == NETWORK_ERROR_NOT_EXPECTED || error == NETWORK_ERROR_WRONG_REVISION) {
@@ -549,7 +549,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendWelcome()
/* Transmit info about all the active clients */
for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) {
- if (new_cs != this && new_cs->status > STATUS_AUTHORIZED) {
+ if (new_cs != this && new_cs->status >= STATUS_AUTHORIZED) {
this->SendClientInfo(new_cs->GetInfo());
}
}
@@ -1068,7 +1068,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_MAP_OK(Packet *
this->last_frame_server = _frame_counter;
for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) {
- if (new_cs->status > STATUS_AUTHORIZED) {
+ if (new_cs->status >= STATUS_AUTHORIZED) {
new_cs->SendClientInfo(this->GetInfo());
new_cs->SendJoin(this->client_id);
}
@@ -1178,7 +1178,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ERROR(Packet *p
NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, nullptr, strid);
for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) {
- if (new_cs->status > STATUS_AUTHORIZED) {
+ if (new_cs->status >= STATUS_AUTHORIZED) {
new_cs->SendErrorQuit(this->client_id, errorno);
}
}
@@ -1204,7 +1204,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_QUIT(Packet *p)
NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, nullptr, STR_NETWORK_MESSAGE_CLIENT_LEAVING);
for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) {
- if (new_cs->status > STATUS_AUTHORIZED && new_cs != this) {
+ if (new_cs->status >= STATUS_AUTHORIZED && new_cs != this) {
new_cs->SendQuit(this->client_id);
}
}
@@ -1607,7 +1607,9 @@ void NetworkUpdateClientInfo(ClientID client_id)
DEBUG(desync, 1, "client: %08x; %02x; %02x; %04x", _date, _date_fract, (int)ci->client_playas, client_id);
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
- cs->SendClientInfo(ci);
+ if (cs->status >= ServerNetworkGameSocketHandler::STATUS_AUTHORIZED) {
+ cs->SendClientInfo(ci);
+ }
}
NetworkAdminClientUpdate(ci);