diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index 4dfce1c47d..fa4dc0e8ef 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -898,8 +898,12 @@ CommandCost CmdCompanyCtrl(DoCommandFlag flags, CompanyCtrlAction cca, CompanyID assert(_local_company == COMPANY_SPECTATOR); SetLocalCompany(c->index); - /* In network games, we need to try setting the company manager face here to sync it to all clients. - * If a favorite company manager face is selected, choose it. Otherwise, use a random face. */ + /* + * If a favorite company manager face is selected, choose it. Otherwise, use a random face. + * Because this needs to be synchronised over the network, only the client knows + * its configuration and we are currently in the execution of a command, we have + * to circumvent the normal ::Post logic for commands and just send the command. + */ if (_company_manager_face != 0) Command::SendNet(STR_NULL, c->index, _company_manager_face); /* Now that we have a new company, broadcast our company settings to diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 41f2b9cc50..099479c158 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -2157,6 +2157,13 @@ void NetworkServerNewCompany(const Company *c, NetworkClientInfo *ci) /* ci is nullptr when replaying, or for AIs. In neither case there is a client. */ ci->client_playas = c->index; NetworkUpdateClientInfo(ci->client_id); + + /* + * This function is called from a command, but is only called for the server. + * The client information is managed out-of-band from the commands, so to not have a + * different state/president/company name in the different clients, we need to + * circumvent the normal ::Post logic and go directly to sending the command. + */ Command::SendNet(STR_NULL, c->index, ci->public_key); Command::SendNet(STR_NULL, c->index, ci->client_name); diff --git a/src/settings.cpp b/src/settings.cpp index ed2f239d8f..293c20fb95 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1790,6 +1790,11 @@ void SyncCompanySettings() const SettingDesc *sd = GetSettingDesc(desc); uint32_t old_value = (uint32_t)sd->AsIntSetting()->Read(old_object); uint32_t new_value = (uint32_t)sd->AsIntSetting()->Read(new_object); + /* + * This is called from a command, and since it contains local configuration information + * that the rest of the clients do not know about, we need to circumvent the normal ::Post + * local command validation and immediately send the command to the server. + */ if (old_value != new_value) Command::SendNet(STR_NULL, _local_company, sd->GetName(), new_value); } }