summaryrefslogtreecommitdiff
path: root/src/landscape.cpp
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-09-05 16:00:36 +0000
committeryexo <yexo@openttd.org>2010-09-05 16:00:36 +0000
commit0e250f2bdfc8eb7f435f59398766f7774e31610c (patch)
tree40f51747f1d8d65476c8bfe8e735c8dc53c49307 /src/landscape.cpp
parent323c526a4d344025b3ba30ade5923c0d41431d8c (diff)
downloadopenttd-0e250f2bdfc8eb7f435f59398766f7774e31610c.tar.xz
(svn r20748) -Fix: overbuilding an object tile with sea under it with a canal didn't take the cost for clearing the sea into account
Diffstat (limited to 'src/landscape.cpp')
-rw-r--r--src/landscape.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/landscape.cpp b/src/landscape.cpp
index e69dcab82..d85f24dea 100644
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -31,6 +31,7 @@
#include "core/random_func.hpp"
#include "object_base.h"
#include "water_map.h"
+#include "economy_func.h"
#include "table/strings.h"
#include "table/sprites.h"
@@ -606,6 +607,13 @@ void ClearSnowLine()
*/
CommandCost CmdLandscapeClear(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
+ CommandCost cost(EXPENSES_CONSTRUCTION);
+ bool do_clear = false;
+ if ((flags & DC_FORCE_CLEAR_TILE) && HasTileWaterClass(tile) && IsTileOnWater(tile)) {
+ if ((flags & DC_AUTO) && GetWaterClass(tile) == WATER_CLASS_CANAL) return_cmd_error(STR_ERROR_MUST_DEMOLISH_CANAL_FIRST);
+ do_clear = true;
+ cost.AddCost(GetWaterClass(tile) == WATER_CLASS_CANAL ? _price[PR_CLEAR_CANAL] : _price[PR_CLEAR_WATER]);
+ }
for (uint i = 0; i < _cleared_object_areas.Length(); i++) {
/* If this tile was the first tile which caused object destruction, always
* pass it on to the tile_type_proc. That way multiple test runs and the exec run stay consistent. */
@@ -619,10 +627,12 @@ CommandCost CmdLandscapeClear(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
if ((flags & DC_NO_WATER) && HasTileWaterClass(tile) && IsTileOnWater(tile)) {
return_cmd_error(STR_ERROR_CAN_T_BUILD_ON_WATER);
}
- return CommandCost();
+ return cost;
}
}
- return _tile_type_procs[GetTileType(tile)]->clear_tile_proc(tile, flags);
+ cost.AddCost(_tile_type_procs[GetTileType(tile)]->clear_tile_proc(tile, flags));
+ if (do_clear && (flags & DC_EXEC)) DoClearSquare(tile);
+ return cost;
}
/**