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.
This commit is contained in:
@@ -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, {});
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user