summaryrefslogtreecommitdiff
path: root/src/industry_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/industry_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/industry_cmd.cpp')
-rw-r--r--src/industry_cmd.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index e2fa1b776..b7d6d3714 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -43,6 +43,8 @@
#include "cmd_helper.h"
#include "string_func.h"
#include "industry_cmd.h"
+#include "landscape_cmd.h"
+#include "terraform_cmd.h"
#include "table/strings.h"
#include "table/industry_land.h"
@@ -1101,7 +1103,7 @@ static bool SearchLumberMillTrees(TileIndex tile, void *user_data)
_industry_sound_tile = tile;
if (_settings_client.sound.ambient) SndPlayTileFx(SND_38_LUMBER_MILL_1, tile);
- DoCommand(DC_EXEC, CMD_LANDSCAPE_CLEAR, tile, 0, 0);
+ Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC, tile, 0, 0, {});
cur_company.Restore();
return true;
@@ -1483,13 +1485,13 @@ static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTil
/* Clear the tiles as OWNER_TOWN to not affect town rating, and to not clear protected buildings */
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
- CommandCost ret = DoCommand(DC_NONE, CMD_LANDSCAPE_CLEAR, cur_tile, 0, 0);
+ CommandCost ret = Command<CMD_LANDSCAPE_CLEAR>::Do(DC_NONE, cur_tile, 0, 0, {});
cur_company.Restore();
if (ret.Failed()) return ret;
} else {
/* Clear the tiles, but do not affect town ratings */
- CommandCost ret = DoCommand(DC_AUTO | DC_NO_TEST_TOWN_RATING | DC_NO_MODIFY_TOWN_RATING, CMD_LANDSCAPE_CLEAR, cur_tile, 0, 0);
+ CommandCost ret = Command<CMD_LANDSCAPE_CLEAR>::Do(DC_AUTO | DC_NO_TEST_TOWN_RATING | DC_NO_MODIFY_TOWN_RATING, cur_tile, 0, 0, {});
if (ret.Failed()) return ret;
}
@@ -1599,7 +1601,7 @@ static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, DoCommandFlag flags,
}
/* This is not 100% correct check, but the best we can do without modifying the map.
* What is missing, is if the difference in height is more than 1.. */
- if (DoCommand(flags & ~DC_EXEC, CMD_TERRAFORM_LAND, tile_walk, SLOPE_N, (curh > h) ? 0 : 1).Failed()) {
+ if (Command<CMD_TERRAFORM_LAND>::Do(flags & ~DC_EXEC, tile_walk, SLOPE_N, (curh > h) ? 0 : 1, {}).Failed()) {
cur_company.Restore();
return false;
}
@@ -1614,7 +1616,7 @@ static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, DoCommandFlag flags,
/* We give the terraforming for free here, because we can't calculate
* exact cost in the test-round, and as we all know, that will cause
* a nice assert if they don't match ;) */
- DoCommand(flags, CMD_TERRAFORM_LAND, tile_walk, SLOPE_N, (curh > h) ? 0 : 1);
+ Command<CMD_TERRAFORM_LAND>::Do(flags, tile_walk, SLOPE_N, (curh > h) ? 0 : 1, {});
curh += (curh > h) ? -1 : 1;
}
}
@@ -1884,7 +1886,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
WaterClass wc = (IsWaterTile(cur_tile) ? GetWaterClass(cur_tile) : WATER_CLASS_INVALID);
- DoCommand(DC_EXEC | DC_NO_TEST_TOWN_RATING | DC_NO_MODIFY_TOWN_RATING, CMD_LANDSCAPE_CLEAR, cur_tile, 0, 0);
+ Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC | DC_NO_TEST_TOWN_RATING | DC_NO_MODIFY_TOWN_RATING, cur_tile, 0, 0, {});
MakeIndustry(cur_tile, i->index, it.gfx, Random(), wc);
@@ -3060,7 +3062,7 @@ static CommandCost TerraformTile_Industry(TileIndex tile, DoCommandFlag flags, i
}
}
}
- return DoCommand(flags, CMD_LANDSCAPE_CLEAR, tile, 0, 0);
+ return Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile, 0, 0, {});
}
extern const TileTypeProcs _tile_type_industry_procs = {