Changeset - r23583:f6bffb252509
[Not reviewed]
master
0 5 0
glx22 - 5 years ago 2019-04-05 13:11:52
glx22@users.noreply.github.com
Fix #7439: don't overwrite CompanyRemoveReason with ClientID (#7465)
5 files changed with 11 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_gui.cpp
Show inline comments
 
@@ -1279,13 +1279,13 @@ struct AIDebugWindow : public Window {
 
				ChangeToAI(OWNER_DEITY);
 
				break;
 

	
 
			case WID_AID_RELOAD_TOGGLE:
 
				if (ai_debug_company == OWNER_DEITY) break;
 
				/* First kill the company of the AI, then start a new one. This should start the current AI again */
 
				DoCommandP(0, CCA_DELETE | ai_debug_company << 16, CRR_MANUAL, CMD_COMPANY_CTRL);
 
				DoCommandP(0, CCA_DELETE | ai_debug_company << 16 | CRR_MANUAL << 24, 0, CMD_COMPANY_CTRL);
 
				DoCommandP(0, CCA_NEW_AI | ai_debug_company << 16, 0, CMD_COMPANY_CTRL);
 
				break;
 

	
 
			case WID_AID_SETTINGS:
 
				ShowAISettingsWindow(ai_debug_company);
 
				break;
src/company_cmd.cpp
Show inline comments
 
@@ -804,16 +804,15 @@ void CompanyAdminRemove(CompanyID compan
 
/**
 
 * Control the companies: add, delete, etc.
 
 * @param tile unused
 
 * @param flags operation to perform
 
 * @param p1 various functionality
 
 * - bits 0..15: CompanyCtrlAction
 
 * - bits 16..24: CompanyID
 
 * @param p2 various depending on CompanyCtrlAction
 
 * - bits 0..31: ClientID (with CCA_NEW)
 
 * - bits 0..1: CompanyRemoveReason (with CCA_DELETE)
 
 * - bits 16..23: CompanyID
 
 * - bits 24..31: CompanyRemoveReason (with CCA_DELETE)
 
 * @param p2 ClientID
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	InvalidateWindowData(WC_COMPANY_LEAGUE, 0, 0);
 
@@ -877,13 +876,13 @@ CommandCost CmdCompanyCtrl(TileIndex til
 
			Company *c = DoStartupNewCompany(true, company_id);
 
			if (c != NULL) NetworkServerNewCompany(c, NULL);
 
			break;
 
		}
 

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

	
 
			Company *c = Company::GetIfValid(company_id);
 
			if (c == NULL) return CMD_ERROR;
 

	
 
			if (!(flags & DC_EXEC)) return CommandCost();
src/console_cmds.cpp
Show inline comments
 
@@ -822,13 +822,13 @@ DEF_CONSOLE_CMD(ConResetCompany)
 
	if (ci->client_playas == index) {
 
		IConsoleError("Cannot remove company: the server is connected to that company.");
 
		return true;
 
	}
 

	
 
	/* It is safe to remove this company */
 
	DoCommandP(0, CCA_DELETE | index << 16, CRR_MANUAL, CMD_COMPANY_CTRL);
 
	DoCommandP(0, CCA_DELETE | index << 16 | CRR_MANUAL << 24, 0, CMD_COMPANY_CTRL);
 
	IConsolePrint(CC_DEFAULT, "Company deleted.");
 

	
 
	return true;
 
}
 

	
 
DEF_CONSOLE_CMD(ConNetworkClients)
 
@@ -1197,13 +1197,13 @@ DEF_CONSOLE_CMD(ConReloadAI)
 
	if (Company::IsHumanID(company_id)) {
 
		IConsoleWarning("Company is not controlled by an AI.");
 
		return true;
 
	}
 

	
 
	/* First kill the company of the AI, then start a new one. This should start the current AI again */
 
	DoCommandP(0, CCA_DELETE | company_id << 16, CRR_MANUAL, CMD_COMPANY_CTRL);
 
	DoCommandP(0, CCA_DELETE | company_id << 16 | CRR_MANUAL << 24, 0,CMD_COMPANY_CTRL);
 
	DoCommandP(0, CCA_NEW_AI | company_id << 16, 0, CMD_COMPANY_CTRL);
 
	IConsolePrint(CC_DEFAULT, "AI reloaded.");
 

	
 
	return true;
 
}
 

	
 
@@ -1234,13 +1234,13 @@ DEF_CONSOLE_CMD(ConStopAI)
 
	if (Company::IsHumanID(company_id) || company_id == _local_company) {
 
		IConsoleWarning("Company is not controlled by an AI.");
 
		return true;
 
	}
 

	
 
	/* Now kill the company of the AI. */
 
	DoCommandP(0, CCA_DELETE | company_id << 16, CRR_MANUAL, CMD_COMPANY_CTRL);
 
	DoCommandP(0, CCA_DELETE | company_id << 16 | CRR_MANUAL << 24, 0, CMD_COMPANY_CTRL);
 
	IConsolePrint(CC_DEFAULT, "AI stopped, company deleted.");
 

	
 
	return true;
 
}
 

	
 
DEF_CONSOLE_CMD(ConRescanAI)
src/economy.cpp
Show inline comments
 
@@ -637,13 +637,13 @@ static void CompanyCheckBankrupt(Company
 
			 * StateGameLoop which can't change the current company, and thus
 
			 * updating the local company triggers an assert later on. In the
 
			 * case of a network game the command will be processed at a time
 
			 * that changing the current company is okay. In case of single
 
			 * player we are sure (the above check) that we are not the local
 
			 * company and thus we won't be moved. */
 
			if (!_networking || _network_server) DoCommandP(0, CCA_DELETE | (c->index << 16), CRR_BANKRUPT, CMD_COMPANY_CTRL);
 
			if (!_networking || _network_server) DoCommandP(0, CCA_DELETE | (c->index << 16) | (CRR_BANKRUPT << 24), 0, CMD_COMPANY_CTRL);
 
			break;
 
		}
 
	}
 
}
 

	
 
/**
src/network/network_server.cpp
Show inline comments
 
@@ -1670,13 +1670,13 @@ static void NetworkAutoCleanCompanies()
 
			/* The company is empty for one month more */
 
			_network_company_states[c->index].months_empty++;
 

	
 
			/* Is the company empty for autoclean_unprotected-months, and is there no protection? */
 
			if (_settings_client.network.autoclean_unprotected != 0 && _network_company_states[c->index].months_empty > _settings_client.network.autoclean_unprotected && StrEmpty(_network_company_states[c->index].password)) {
 
				/* Shut the company down */
 
				DoCommandP(0, CCA_DELETE | c->index << 16, CRR_AUTOCLEAN, CMD_COMPANY_CTRL);
 
				DoCommandP(0, CCA_DELETE | c->index << 16 | CRR_AUTOCLEAN << 24, 0, CMD_COMPANY_CTRL);
 
				IConsolePrintF(CC_DEFAULT, "Auto-cleaned company #%d with no password", c->index + 1);
 
			}
 
			/* Is the company empty for autoclean_protected-months, and there is a protection? */
 
			if (_settings_client.network.autoclean_protected != 0 && _network_company_states[c->index].months_empty > _settings_client.network.autoclean_protected && !StrEmpty(_network_company_states[c->index].password)) {
 
				/* Unprotect the company */
 
				_network_company_states[c->index].password[0] = '\0';
 
@@ -1684,13 +1684,13 @@ static void NetworkAutoCleanCompanies()
 
				_network_company_states[c->index].months_empty = 0;
 
				NetworkServerUpdateCompanyPassworded(c->index, false);
 
			}
 
			/* Is the company empty for autoclean_novehicles-months, and has no vehicles? */
 
			if (_settings_client.network.autoclean_novehicles != 0 && _network_company_states[c->index].months_empty > _settings_client.network.autoclean_novehicles && vehicles_in_company[c->index] == 0) {
 
				/* Shut the company down */
 
				DoCommandP(0, CCA_DELETE | c->index << 16, CRR_AUTOCLEAN, CMD_COMPANY_CTRL);
 
				DoCommandP(0, CCA_DELETE | c->index << 16 | CRR_AUTOCLEAN << 24, 0, CMD_COMPANY_CTRL);
 
				IConsolePrintF(CC_DEFAULT, "Auto-cleaned company #%d with no vehicles", c->index + 1);
 
			}
 
		} else {
 
			/* It is not empty, reset the date */
 
			_network_company_states[c->index].months_empty = 0;
 
		}
0 comments (0 inline, 0 general)