summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ai/ai_gui.cpp4
-rw-r--r--src/company_cmd.cpp15
-rw-r--r--src/company_type.h9
-rw-r--r--src/console_cmds.cpp10
-rw-r--r--src/economy.cpp2
-rw-r--r--src/network/network_client.cpp2
-rw-r--r--src/network/network_server.cpp4
-rw-r--r--src/toolbar_gui.cpp4
8 files changed, 28 insertions, 22 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index 69476856c..dbdd77245 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -1282,8 +1282,8 @@ 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, 2 | ai_debug_company << 16, CRR_MANUAL, CMD_COMPANY_CTRL);
- DoCommandP(0, 1 | ai_debug_company << 16, 0, CMD_COMPANY_CTRL);
+ DoCommandP(0, CCA_DELETE | ai_debug_company << 16, CRR_MANUAL, CMD_COMPANY_CTRL);
+ DoCommandP(0, CCA_NEW_AI | ai_debug_company << 16, 0, CMD_COMPANY_CTRL);
break;
case WID_AID_SETTINGS:
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
index cf66690f4..392f97afb 100644
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -612,7 +612,7 @@ static bool MaybeStartNewCompany()
if (n < (uint)_settings_game.difficulty.max_no_competitors) {
/* Send a command to all clients to start up a new AI.
* Works fine for Multiplayer and Singleplayer */
- return DoCommandP(0, 1 | INVALID_COMPANY << 16, 0, CMD_COMPANY_CTRL);
+ return DoCommandP(0, CCA_NEW_AI | INVALID_COMPANY << 16, 0, CMD_COMPANY_CTRL);
}
return false;
@@ -810,10 +810,7 @@ void CompanyAdminRemove(CompanyID company_id, CompanyRemoveReason reason)
* @param tile unused
* @param flags operation to perform
* @param p1 various functionality
- * - bits 0..15:
- * = 0 - create a new company
- * = 1 - create a new AI company
- * = 2 - delete a company
+ * - bits 0..15: CompanyCtrlAction
* - bits 16..24: CompanyID
* @param p2 ClientID
* @param text unused
@@ -827,8 +824,8 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
ClientID client_id = (ClientID)p2;
#endif /* ENABLE_NETWORK */
- switch (GB(p1, 0, 16)) {
- case 0: { // Create a new company
+ 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;
@@ -878,7 +875,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
break;
}
- case 1: { // Make a new AI company
+ 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;
@@ -889,7 +886,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
break;
}
- case 2: { // Delete a company
+ case CCA_DELETE: { // Delete a company
CompanyRemoveReason reason = (CompanyRemoveReason)GB(p2, 0, 2);
if (reason >= CRR_END) return CMD_ERROR;
diff --git a/src/company_type.h b/src/company_type.h
index 44a074e10..771e6d8b9 100644
--- a/src/company_type.h
+++ b/src/company_type.h
@@ -64,4 +64,13 @@ enum CompanyRemoveReason {
CRR_END, ///< Sentinel for end.
};
+/** The action to do with CMD_COMPANY_CTRL. */
+enum CompanyCtrlAction {
+ CCA_NEW, ///< Create a new company.
+ CCA_NEW_AI, ///< Create a new AI company.
+ CCA_DELETE, ///< Delete a company.
+
+ CCA_END, ///< Sentinel for end.
+};
+
#endif /* COMPANY_TYPE_H */
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index d9155a97d..732ace6a2 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -836,7 +836,7 @@ DEF_CONSOLE_CMD(ConResetCompany)
}
/* It is safe to remove this company */
- DoCommandP(0, 2 | index << 16, CRR_MANUAL, CMD_COMPANY_CTRL);
+ DoCommandP(0, CCA_DELETE | index << 16, CRR_MANUAL, CMD_COMPANY_CTRL);
IConsolePrint(CC_DEFAULT, "Company deleted.");
return true;
@@ -1178,7 +1178,7 @@ DEF_CONSOLE_CMD(ConStartAI)
}
/* Start a new AI company */
- DoCommandP(0, 1 | INVALID_COMPANY << 16, 0, CMD_COMPANY_CTRL);
+ DoCommandP(0, CCA_NEW_AI | INVALID_COMPANY << 16, 0, CMD_COMPANY_CTRL);
return true;
}
@@ -1213,8 +1213,8 @@ 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, 2 | company_id << 16, CRR_MANUAL, CMD_COMPANY_CTRL);
- DoCommandP(0, 1 | company_id << 16, 0, CMD_COMPANY_CTRL);
+ DoCommandP(0, CCA_DELETE | company_id << 16, CRR_MANUAL, CMD_COMPANY_CTRL);
+ DoCommandP(0, CCA_NEW_AI | company_id << 16, 0, CMD_COMPANY_CTRL);
IConsolePrint(CC_DEFAULT, "AI reloaded.");
return true;
@@ -1250,7 +1250,7 @@ DEF_CONSOLE_CMD(ConStopAI)
}
/* Now kill the company of the AI. */
- DoCommandP(0, 2 | company_id << 16, CRR_MANUAL, CMD_COMPANY_CTRL);
+ DoCommandP(0, CCA_DELETE | company_id << 16, CRR_MANUAL, CMD_COMPANY_CTRL);
IConsolePrint(CC_DEFAULT, "AI stopped, company deleted.");
return true;
diff --git a/src/economy.cpp b/src/economy.cpp
index 6d3c2a8b2..97283ae44 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -642,7 +642,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, 2 | (c->index << 16), CRR_BANKRUPT, CMD_COMPANY_CTRL);
+ if (!_networking || _network_server) DoCommandP(0, CCA_DELETE | (c->index << 16), CRR_BANKRUPT, CMD_COMPANY_CTRL);
break;
}
}
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index 9e34ebb09..b4d0a06f7 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -878,7 +878,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(Packet
* the server will give us a client-id and let us in */
_network_join_status = NETWORK_JOIN_STATUS_REGISTERING;
ShowJoinStatusWindow();
- NetworkSendCommand(0, 0, 0, CMD_COMPANY_CTRL, NULL, NULL, _local_company);
+ NetworkSendCommand(0, CCA_NEW, 0, CMD_COMPANY_CTRL, NULL, NULL, _local_company);
}
} else {
/* take control over an existing company */
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 275b6200e..05fb27fc8 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -1675,7 +1675,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, 2 | c->index << 16, CRR_AUTOCLEAN, CMD_COMPANY_CTRL);
+ DoCommandP(0, CCA_DELETE | c->index << 16, CRR_AUTOCLEAN, 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? */
@@ -1689,7 +1689,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, 2 | c->index << 16, CRR_AUTOCLEAN, CMD_COMPANY_CTRL);
+ DoCommandP(0, CCA_DELETE | c->index << 16, CRR_AUTOCLEAN, CMD_COMPANY_CTRL);
IConsolePrintF(CC_DEFAULT, "Auto-cleaned company #%d with no vehicles", c->index + 1);
}
} else {
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index afa9adacb..fbc099f8a 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -618,9 +618,9 @@ static CallBackFunction MenuClickCompany(int index)
case CTMN_NEW_COMPANY:
if (_network_server) {
- DoCommandP(0, 0, _network_own_client_id, CMD_COMPANY_CTRL);
+ DoCommandP(0, CCA_NEW, _network_own_client_id, CMD_COMPANY_CTRL);
} else {
- NetworkSendCommand(0, 0, 0, CMD_COMPANY_CTRL, NULL, NULL, _local_company);
+ NetworkSendCommand(0, CCA_NEW, 0, CMD_COMPANY_CTRL, NULL, NULL, _local_company);
}
return CBF_NONE;