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.
This commit is contained in:
Jonathan G Rennison 2021-04-06 19:31:52 +01:00 committed by GitHub
parent 920bf703cd
commit 825867f2c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 6 deletions

View File

@ -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);