From 825867f2c50ce508fac442e6113da9cebbfccf75 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Tue, 6 Apr 2021 19:31:52 +0100 Subject: 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. --- src/network/network_server.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/network') 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); -- cgit v1.2.3-54-g00ecf