Fix #10983: [AdminPort] Correct order of messages
(cherry picked from commit 49c3215751
)
This commit is contained in:

committed by
Jonathan G Rennison

parent
5c35a87ed7
commit
2aa574a48f
@@ -965,6 +965,11 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32_t p1, uin
|
||||
break;
|
||||
}
|
||||
|
||||
/* Send new companies, before potentially setting the password. Otherwise,
|
||||
* the password update could be sent when the company is not yet known. */
|
||||
NetworkAdminCompanyNew(c);
|
||||
NetworkServerNewCompany(c, ci);
|
||||
|
||||
/* This is the client (or non-dedicated server) who wants a new company */
|
||||
if (client_id == _network_own_client_id) {
|
||||
assert(_local_company == COMPANY_SPECTATOR);
|
||||
@@ -984,7 +989,6 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32_t p1, uin
|
||||
MarkWholeScreenDirty();
|
||||
}
|
||||
|
||||
NetworkServerNewCompany(c, ci);
|
||||
DEBUG(desync, 1, "new_company: %s, company_id: %u", debug_date_dumper().HexDate(), c->index);
|
||||
break;
|
||||
}
|
||||
@@ -1002,6 +1006,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32_t p1, uin
|
||||
|
||||
Company *c = DoStartupNewCompany(DSNC_AI, company_id);
|
||||
if (c != nullptr) {
|
||||
NetworkAdminCompanyNew(c);
|
||||
NetworkServerNewCompany(c, nullptr);
|
||||
DEBUG(desync, 1, "new_company_ai: %s, company_id: %u", debug_date_dumper().HexDate(), c->index);
|
||||
}
|
||||
|
@@ -864,11 +864,10 @@ void NetworkAdminClientError(ClientID client_id, NetworkErrorCode error_code)
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the admin network of company details.
|
||||
* Notify the admin network of a new company.
|
||||
* @param company the company of which details will be sent into the admin network.
|
||||
* @param new_company whether this is a new company or not.
|
||||
*/
|
||||
void NetworkAdminCompanyInfo(const Company *company, bool new_company)
|
||||
void NetworkAdminCompanyNew(const Company *company)
|
||||
{
|
||||
if (company == nullptr) {
|
||||
DEBUG(net, 1, "[admin] Empty company given for update");
|
||||
@@ -878,10 +877,8 @@ void NetworkAdminCompanyInfo(const Company *company, bool new_company)
|
||||
for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::IterateActive()) {
|
||||
if (as->update_frequency[ADMIN_UPDATE_COMPANY_INFO] != ADMIN_FREQUENCY_AUTOMATIC) continue;
|
||||
|
||||
as->SendCompanyNew(company->index);
|
||||
as->SendCompanyInfo(company);
|
||||
if (new_company) {
|
||||
as->SendCompanyNew(company->index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -103,7 +103,7 @@ void NetworkAdminClientInfo(const NetworkClientSocket *cs, bool new_client = fal
|
||||
void NetworkAdminClientUpdate(const NetworkClientInfo *ci);
|
||||
void NetworkAdminClientQuit(ClientID client_id);
|
||||
void NetworkAdminClientError(ClientID client_id, NetworkErrorCode error_code);
|
||||
void NetworkAdminCompanyInfo(const Company *company, bool new_company);
|
||||
void NetworkAdminCompanyNew(const Company *company);
|
||||
void NetworkAdminCompanyUpdate(const Company *company);
|
||||
void NetworkAdminCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bcrr);
|
||||
|
||||
|
@@ -2454,9 +2454,6 @@ void NetworkServerNewCompany(const Company *c, NetworkClientInfo *ci)
|
||||
NetworkSendCommand(0, 0, 0, 0, CMD_RENAME_PRESIDENT, nullptr, ci->client_name.c_str(), c->index, nullptr);
|
||||
}
|
||||
|
||||
/* Announce new company on network. */
|
||||
NetworkAdminCompanyInfo(c, true);
|
||||
|
||||
if (ci != nullptr) {
|
||||
/* ci is nullptr when replaying, or for AIs. In neither case there is a client.
|
||||
We need to send Admin port update here so that they first know about the new company
|
||||
|
Reference in New Issue
Block a user