summaryrefslogtreecommitdiff
path: root/src/water_cmd.cpp
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-09-05 16:33:32 +0000
committeryexo <yexo@openttd.org>2010-09-05 16:33:32 +0000
commita2ba35f57c8ef789760c35c64a006a14f3fb9967 (patch)
treeb0885c13b29043b71a35e218536e93b243d0c5e5 /src/water_cmd.cpp
parent0e250f2bdfc8eb7f435f59398766f7774e31610c (diff)
downloadopenttd-a2ba35f57c8ef789760c35c64a006a14f3fb9967.tar.xz
(svn r20749) -Fix: allow overbuilding objects with buoys and ship depots
Diffstat (limited to 'src/water_cmd.cpp')
-rw-r--r--src/water_cmd.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 8f2895eba..9315ef849 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -100,7 +100,7 @@ CommandCost CmdBuildShipDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
TileIndex tile2 = tile + (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
- if (!IsWaterTile(tile) || !IsWaterTile(tile2)) {
+ if (!HasTileWaterClass(tile) || !IsTileOnWater(tile) || !HasTileWaterClass(tile2) || !IsTileOnWater(tile2)) {
return_cmd_error(STR_ERROR_MUST_BE_BUILT_ON_WATER);
}
@@ -111,14 +111,24 @@ CommandCost CmdBuildShipDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
}
+ if (!Depot::CanAllocateItem()) return CMD_ERROR;
+
WaterClass wc1 = GetWaterClass(tile);
WaterClass wc2 = GetWaterClass(tile2);
- CommandCost ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ CommandCost cost = CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_DEPOT_SHIP]);
+
+ bool add_cost = !IsWaterTile(tile);
+ CommandCost ret = DoCommand(tile, 0, 0, flags | DC_AUTO, CMD_LANDSCAPE_CLEAR);
if (ret.Failed()) return ret;
- ret = DoCommand(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ if (add_cost) {
+ cost.AddCost(ret);
+ }
+ add_cost = !IsWaterTile(tile2);
+ ret = DoCommand(tile2, 0, 0, flags | DC_AUTO, CMD_LANDSCAPE_CLEAR);
if (ret.Failed()) return ret;
-
- if (!Depot::CanAllocateItem()) return CMD_ERROR;
+ if (add_cost) {
+ cost.AddCost(ret);
+ }
if (flags & DC_EXEC) {
Depot *depot = new Depot(tile);
@@ -131,7 +141,7 @@ CommandCost CmdBuildShipDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
MakeDefaultName(depot);
}
- return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_DEPOT_SHIP]);
+ return cost;
}
void MakeWaterKeepingClass(TileIndex tile, Owner o)