summaryrefslogtreecommitdiff
path: root/src/water_cmd.cpp
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-10-30 01:31:46 +0200
committerMichael Lutz <michi@icosahedron.de>2021-12-16 22:28:32 +0100
commite740c24eb7a90bc771f5976d64d80639ee7576e5 (patch)
treeb3c8f0c87419cb11c106ba1cb58d6ae0648beef4 /src/water_cmd.cpp
parentc88b104ec662ea80bec89f58aa7ad9d0baac7704 (diff)
downloadopenttd-e740c24eb7a90bc771f5976d64d80639ee7576e5.tar.xz
Codechange: Template DoCommand to automagically reflect the parameters of the command proc.
When finished, this will allow each command handler to take individually different parameters, obliviating the need for bit-packing.
Diffstat (limited to 'src/water_cmd.cpp')
-rw-r--r--src/water_cmd.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 6e357f9c6..07c13adcd 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -39,6 +39,7 @@
#include "newgrf_generic.h"
#include "industry.h"
#include "water_cmd.h"
+#include "landscape_cmd.h"
#include "table/strings.h"
@@ -123,13 +124,13 @@ CommandCost CmdBuildShipDepot(DoCommandFlag flags, TileIndex tile, uint32 p1, ui
CommandCost cost = CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_DEPOT_SHIP]);
bool add_cost = !IsWaterTile(tile);
- CommandCost ret = DoCommand(flags | DC_AUTO, CMD_LANDSCAPE_CLEAR, tile, 0, 0);
+ CommandCost ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags | DC_AUTO, tile, 0, 0, {});
if (ret.Failed()) return ret;
if (add_cost) {
cost.AddCost(ret);
}
add_cost = !IsWaterTile(tile2);
- ret = DoCommand(flags | DC_AUTO, CMD_LANDSCAPE_CLEAR, tile2, 0, 0);
+ ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags | DC_AUTO, tile2, 0, 0, {});
if (ret.Failed()) return ret;
if (add_cost) {
cost.AddCost(ret);
@@ -307,13 +308,13 @@ static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlag
/* middle tile */
WaterClass wc_middle = HasTileWaterGround(tile) ? GetWaterClass(tile) : WATER_CLASS_CANAL;
- ret = DoCommand(flags, CMD_LANDSCAPE_CLEAR, tile, 0, 0);
+ ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile, 0, 0, {});
if (ret.Failed()) return ret;
cost.AddCost(ret);
/* lower tile */
if (!IsWaterTile(tile - delta)) {
- ret = DoCommand(flags, CMD_LANDSCAPE_CLEAR, tile - delta, 0, 0);
+ ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile - delta, 0, 0, {});
if (ret.Failed()) return ret;
cost.AddCost(ret);
cost.AddCost(_price[PR_BUILD_CANAL]);
@@ -325,7 +326,7 @@ static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlag
/* upper tile */
if (!IsWaterTile(tile + delta)) {
- ret = DoCommand(flags, CMD_LANDSCAPE_CLEAR, tile + delta, 0, 0);
+ ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile + delta, 0, 0, {});
if (ret.Failed()) return ret;
cost.AddCost(ret);
cost.AddCost(_price[PR_BUILD_CANAL]);
@@ -481,7 +482,7 @@ CommandCost CmdBuildCanal(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32
/* Outside the editor, prevent building canals over your own or OWNER_NONE owned canals */
if (water && IsCanal(current_tile) && _game_mode != GM_EDITOR && (IsTileOwner(current_tile, _current_company) || IsTileOwner(current_tile, OWNER_NONE))) continue;
- ret = DoCommand(flags, CMD_LANDSCAPE_CLEAR, current_tile, 0, 0);
+ ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags, current_tile, 0, 0, {});
if (ret.Failed()) return ret;
if (!water) cost.AddCost(ret);
@@ -1136,7 +1137,7 @@ void DoFloodTile(TileIndex target)
FALLTHROUGH;
case MP_CLEAR:
- if (DoCommand(DC_EXEC, CMD_LANDSCAPE_CLEAR, target, 0, 0).Succeeded()) {
+ if (Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC, target, 0, 0, {}).Succeeded()) {
MakeShore(target);
MarkTileDirtyByTile(target);
flooded = true;
@@ -1151,7 +1152,7 @@ void DoFloodTile(TileIndex target)
FloodVehicles(target);
/* flood flat tile */
- if (DoCommand(DC_EXEC, CMD_LANDSCAPE_CLEAR, target, 0, 0).Succeeded()) {
+ if (Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC, target, 0, 0, {}).Succeeded()) {
MakeSea(target);
MarkTileDirtyByTile(target);
flooded = true;
@@ -1203,7 +1204,7 @@ static void DoDryUp(TileIndex tile)
case MP_WATER:
assert(IsCoast(tile));
- if (DoCommand(DC_EXEC, CMD_LANDSCAPE_CLEAR, tile, 0, 0).Succeeded()) {
+ if (Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC, tile, 0, 0, {}).Succeeded()) {
MakeClear(tile, CLEAR_GRASS, 3);
MarkTileDirtyByTile(tile);
}
@@ -1362,7 +1363,7 @@ static void ChangeTileOwner_Water(TileIndex tile, Owner old_owner, Owner new_own
}
/* Remove depot */
- if (IsShipDepot(tile)) DoCommand(DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR, tile, 0, 0);
+ if (IsShipDepot(tile)) Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC | DC_BANKRUPT, tile, 0, 0, {});
/* Set owner of canals and locks ... and also canal under dock there was before.
* Check if the new owner after removing depot isn't OWNER_WATER. */
@@ -1382,7 +1383,7 @@ static CommandCost TerraformTile_Water(TileIndex tile, DoCommandFlag flags, int
/* Canals can't be terraformed */
if (IsWaterTile(tile) && IsCanal(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_CANAL_FIRST);
- return DoCommand(flags, CMD_LANDSCAPE_CLEAR, tile, 0, 0);
+ return Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC, tile, 0, 0, {});
}