summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorglx22 <glx22@users.noreply.github.com>2019-04-05 15:11:52 +0200
committerGitHub <noreply@github.com>2019-04-05 15:11:52 +0200
commita1e492d0d8970217800ebd78d328c9ddf0f13a31 (patch)
treec4135eccb649a412c2113f45b6306d95e9e08341 /src
parentfb6e31ca43b10b40fcaf1db0596dfaa48a1ecf20 (diff)
downloadopenttd-a1e492d0d8970217800ebd78d328c9ddf0f13a31.tar.xz
Fix #7439: don't overwrite CompanyRemoveReason with ClientID (#7465)
Diffstat (limited to 'src')
-rw-r--r--src/ai/ai_gui.cpp2
-rw-r--r--src/company_cmd.cpp9
-rw-r--r--src/console_cmds.cpp6
-rw-r--r--src/economy.cpp2
-rw-r--r--src/network/network_server.cpp4
5 files changed, 11 insertions, 12 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index 8b00de988..2730070c3 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -1282,7 +1282,7 @@ struct AIDebugWindow : public Window {
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;
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
index 4d8750851..df0588f91 100644
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -807,10 +807,9 @@ void CompanyAdminRemove(CompanyID company_id, CompanyRemoveReason reason)
* @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
*/
@@ -880,7 +879,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
}
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);
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 1d3e9c52c..00b953694 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -825,7 +825,7 @@ DEF_CONSOLE_CMD(ConResetCompany)
}
/* 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;
@@ -1200,7 +1200,7 @@ DEF_CONSOLE_CMD(ConReloadAI)
}
/* 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.");
@@ -1237,7 +1237,7 @@ DEF_CONSOLE_CMD(ConStopAI)
}
/* 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;
diff --git a/src/economy.cpp b/src/economy.cpp
index d1ebd8a04..07dec815a 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -640,7 +640,7 @@ static void CompanyCheckBankrupt(Company *c)
* 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;
}
}
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 36dde0f2c..1bcd7ca12 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -1673,7 +1673,7 @@ static void NetworkAutoCleanCompanies()
/* 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? */
@@ -1687,7 +1687,7 @@ static void NetworkAutoCleanCompanies()
/* 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 {