Changeset - r28783:cd631889bef5
[Not reviewed]
master
0 4 0
Damian Laczak - 10 months ago 2023-06-26 00:11:04
shoter@users.noreply.github.com
Fix #10983: [AdminPort] Correct order of messages
4 files changed with 13 insertions and 13 deletions:
0 comments (0 inline, 0 general)
src/company_cmd.cpp
Show inline comments
 
@@ -885,12 +885,17 @@ CommandCost CmdCompanyCtrl(DoCommandFlag
 
					ci->client_playas = COMPANY_SPECTATOR;
 
					NetworkUpdateClientInfo(ci->client_id);
 
				}
 
				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);
 
				SetLocalCompany(c->index);
 
				if (!_settings_client.network.default_company_pass.empty()) {
 
					NetworkChangeCompanyPassword(_local_company, _settings_client.network.default_company_pass);
 
@@ -903,14 +908,12 @@ CommandCost CmdCompanyCtrl(DoCommandFlag
 
				/* Now that we have a new company, broadcast our company settings to
 
				 * all clients so everything is in sync */
 
				SyncCompanySettings();
 

	
 
				MarkWholeScreenDirty();
 
			}
 

	
 
			NetworkServerNewCompany(c, ci);
 
			break;
 
		}
 

	
 
		case CCA_NEW_AI: { // Make a new AI company
 
			if (company_id != INVALID_COMPANY && company_id >= MAX_COMPANIES) return CMD_ERROR;
 

	
 
@@ -920,13 +923,16 @@ CommandCost CmdCompanyCtrl(DoCommandFlag
 
			if (!(flags & DC_EXEC)) return CommandCost();
 

	
 
			/* For network game, just assume deletion happened. */
 
			assert(company_id == INVALID_COMPANY || !Company::IsValidID(company_id));
 

	
 
			Company *c = DoStartupNewCompany(true, company_id);
 
			if (c != nullptr) NetworkServerNewCompany(c, nullptr);
 
			if (c != nullptr) {
 
				NetworkAdminCompanyNew(c);
 
				NetworkServerNewCompany(c, nullptr);
 
			}
 
			break;
 
		}
 

	
 
		case CCA_DELETE: { // Delete a company
 
			if (reason >= CRR_END) return CMD_ERROR;
 

	
src/network/network_admin.cpp
Show inline comments
 
@@ -850,30 +850,27 @@ void NetworkAdminClientError(ClientID cl
 
			as->SendClientError(client_id, 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");
 
		return;
 
	}
 

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

	
 
/**
 
 * Notify the admin network of company updates.
 
 * @param company company of which updates are going to be sent into the admin network.
src/network/network_admin.h
Show inline comments
 
@@ -100,13 +100,13 @@ public:
 
};
 

	
 
void NetworkAdminClientInfo(const NetworkClientSocket *cs, bool new_client = false);
 
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);
 

	
 
void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64_t data = 0, bool from_admin = false);
 
void NetworkAdminUpdate(AdminUpdateFrequency freq);
 
void NetworkServerSendAdminRcon(AdminIndex admin_index, TextColour colour_code, const std::string_view string);
src/network/network_server.cpp
Show inline comments
 
@@ -2195,15 +2195,12 @@ void NetworkServerNewCompany(const Compa
 
		/* ci is nullptr when replaying, or for AIs. In neither case there is a client. */
 
		ci->client_playas = c->index;
 
		NetworkUpdateClientInfo(ci->client_id);
 
		Command<CMD_RENAME_PRESIDENT>::SendNet(STR_NULL, c->index, ci->client_name);
 
	}
 

	
 
	/* 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
 
		   and then learn about a possibly joining client (see FS#6025) */
 
		NetworkServerSendChat(NETWORK_ACTION_COMPANY_NEW, DESTTYPE_BROADCAST, 0, "", ci->client_id, c->index + 1);
 
	}
0 comments (0 inline, 0 general)