1
0
Fork 0

Fix #10983: [AdminPort] Correct order of messages

pull/12115/head
Damian Laczak 2023-06-26 02:11:04 +02:00 committed by rubidium42
parent f20d241e81
commit 49c3215751
4 changed files with 13 additions and 13 deletions

View File

@ -888,6 +888,11 @@ CommandCost CmdCompanyCtrl(DoCommandFlag flags, CompanyCtrlAction cca, CompanyID
break; 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 */ /* This is the client (or non-dedicated server) who wants a new company */
if (client_id == _network_own_client_id) { if (client_id == _network_own_client_id) {
assert(_local_company == COMPANY_SPECTATOR); assert(_local_company == COMPANY_SPECTATOR);
@ -906,8 +911,6 @@ CommandCost CmdCompanyCtrl(DoCommandFlag flags, CompanyCtrlAction cca, CompanyID
MarkWholeScreenDirty(); MarkWholeScreenDirty();
} }
NetworkServerNewCompany(c, ci);
break; break;
} }
@ -923,7 +926,10 @@ CommandCost CmdCompanyCtrl(DoCommandFlag flags, CompanyCtrlAction cca, CompanyID
assert(company_id == INVALID_COMPANY || !Company::IsValidID(company_id)); assert(company_id == INVALID_COMPANY || !Company::IsValidID(company_id));
Company *c = DoStartupNewCompany(true, company_id); Company *c = DoStartupNewCompany(true, company_id);
if (c != nullptr) NetworkServerNewCompany(c, nullptr); if (c != nullptr) {
NetworkAdminCompanyNew(c);
NetworkServerNewCompany(c, nullptr);
}
break; break;
} }

View File

@ -853,11 +853,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 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) { if (company == nullptr) {
Debug(net, 1, "[admin] Empty company given for update"); Debug(net, 1, "[admin] Empty company given for update");
@ -867,10 +866,8 @@ void NetworkAdminCompanyInfo(const Company *company, bool new_company)
for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::IterateActive()) { for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::IterateActive()) {
if (as->update_frequency[ADMIN_UPDATE_COMPANY_INFO] != ADMIN_FREQUENCY_AUTOMATIC) continue; if (as->update_frequency[ADMIN_UPDATE_COMPANY_INFO] != ADMIN_FREQUENCY_AUTOMATIC) continue;
as->SendCompanyNew(company->index);
as->SendCompanyInfo(company); as->SendCompanyInfo(company);
if (new_company) {
as->SendCompanyNew(company->index);
}
} }
} }

View File

@ -103,7 +103,7 @@ void NetworkAdminClientInfo(const NetworkClientSocket *cs, bool new_client = fal
void NetworkAdminClientUpdate(const NetworkClientInfo *ci); void NetworkAdminClientUpdate(const NetworkClientInfo *ci);
void NetworkAdminClientQuit(ClientID client_id); void NetworkAdminClientQuit(ClientID client_id);
void NetworkAdminClientError(ClientID client_id, NetworkErrorCode error_code); 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 NetworkAdminCompanyUpdate(const Company *company);
void NetworkAdminCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bcrr); void NetworkAdminCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bcrr);

View File

@ -2198,9 +2198,6 @@ void NetworkServerNewCompany(const Company *c, NetworkClientInfo *ci)
Command<CMD_RENAME_PRESIDENT>::SendNet(STR_NULL, c->index, ci->client_name); Command<CMD_RENAME_PRESIDENT>::SendNet(STR_NULL, c->index, ci->client_name);
} }
/* Announce new company on network. */
NetworkAdminCompanyInfo(c, true);
if (ci != nullptr) { if (ci != nullptr) {
/* ci is nullptr when replaying, or for AIs. In neither case there is a client. /* 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 We need to send Admin port update here so that they first know about the new company