File diff r23482:de566f8c088d → r23483:3733e6b8ff17
src/company_cmd.cpp
Show inline comments
 
@@ -101,16 +101,14 @@ void Company::PostDestructor(size_t inde
 
 */
 
void SetLocalCompany(CompanyID new_company)
 
{
 
	/* company could also be COMPANY_SPECTATOR or OWNER_NONE */
 
	assert(Company::IsValidID(new_company) || new_company == COMPANY_SPECTATOR || new_company == OWNER_NONE);
 

	
 
#ifdef ENABLE_NETWORK
 
	/* Delete the chat window, if you were team chatting. */
 
	InvalidateWindowData(WC_SEND_NETWORK_MSG, DESTTYPE_TEAM, _local_company);
 
#endif
 

	
 
	assert(IsLocalCompany());
 

	
 
	_current_company = _local_company = new_company;
 

	
 
	/* Delete any construction windows... */
 
@@ -594,15 +592,13 @@ void StartupCompanies()
 
	_next_competitor_start = 0;
 
}
 

	
 
/** Start a new competitor company if possible. */
 
static bool MaybeStartNewCompany()
 
{
 
#ifdef ENABLE_NETWORK
 
	if (_networking && Company::GetNumItems() >= _settings_client.network.max_companies) return false;
 
#endif /* ENABLE_NETWORK */
 

	
 
	Company *c;
 

	
 
	/* count number of competitors */
 
	uint n = 0;
 
	FOR_ALL_COMPANIES(c) {
 
@@ -789,27 +785,23 @@ void CompanyNewsInformation::FillData(co
 
/**
 
 * Called whenever company related information changes in order to notify admins.
 
 * @param company The company data changed of.
 
 */
 
void CompanyAdminUpdate(const Company *company)
 
{
 
#ifdef ENABLE_NETWORK
 
	if (_network_server) NetworkAdminCompanyUpdate(company);
 
#endif /* ENABLE_NETWORK */
 
}
 

	
 
/**
 
 * Called whenever a company is removed in order to notify admins.
 
 * @param company_id The company that was removed.
 
 * @param reason     The reason the company was removed.
 
 */
 
void CompanyAdminRemove(CompanyID company_id, CompanyRemoveReason reason)
 
{
 
#ifdef ENABLE_NETWORK
 
	if (_network_server) NetworkAdminCompanyRemove(company_id, (AdminCompanyRemoveReason)reason);
 
#endif /* ENABLE_NETWORK */
 
}
 

	
 
/**
 
 * Control the companies: add, delete, etc.
 
 * @param tile unused
 
 * @param flags operation to perform
 
@@ -829,13 +821,12 @@ CommandCost CmdCompanyCtrl(TileIndex til
 

	
 
	switch ((CompanyCtrlAction)GB(p1, 0, 16)) {
 
		case CCA_NEW: { // Create a new company
 
			/* This command is only executed in a multiplayer game */
 
			if (!_networking) return CMD_ERROR;
 

	
 
#ifdef ENABLE_NETWORK
 
			/* Has the network client a correct ClientIndex? */
 
			if (!(flags & DC_EXEC)) return CommandCost();
 

	
 
			ClientID client_id = (ClientID)p2;
 
			NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(client_id);
 
#ifndef DEBUG_DUMP_COMMANDS
 
@@ -873,24 +864,21 @@ CommandCost CmdCompanyCtrl(TileIndex til
 
				SyncCompanySettings();
 

	
 
				MarkWholeScreenDirty();
 
			}
 

	
 
			NetworkServerNewCompany(c, ci);
 
#endif /* ENABLE_NETWORK */
 
			break;
 
		}
 

	
 
		case CCA_NEW_AI: { // Make a new AI company
 
			if (!(flags & DC_EXEC)) return CommandCost();
 

	
 
			if (company_id != INVALID_COMPANY && (company_id >= MAX_COMPANIES || Company::IsValidID(company_id))) return CMD_ERROR;
 
			Company *c = DoStartupNewCompany(true, company_id);
 
#ifdef ENABLE_NETWORK
 
			if (c != NULL) NetworkServerNewCompany(c, NULL);
 
#endif /* ENABLE_NETWORK */
 
			break;
 
		}
 

	
 
		case CCA_DELETE: { // Delete a company
 
			CompanyRemoveReason reason = (CompanyRemoveReason)GB(p2, 0, 2);
 
			if (reason >= CRR_END) return CMD_ERROR;