summaryrefslogtreecommitdiff
path: root/src/clear_cmd.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-01-04 18:18:46 +0000
committerpeter1138 <peter1138@openttd.org>2008-01-04 18:18:46 +0000
commit9299f76af42eb4c8ca8d7077fc60f87c2d962047 (patch)
tree508479974d8c96e3bbe1e304ace061d91d4a6d71 /src/clear_cmd.cpp
parent6a1306793108d0ebd51c8d79b8bb8cecd77a6ef6 (diff)
downloadopenttd-9299f76af42eb4c8ca8d7077fc60f87c2d962047.tar.xz
(svn r11759) -Feature: Add drag-n-drop support to the raise/lower land tools. Land is raised/lowered at the start and the rest of the area levelled to match. Patch by Roujin.
Diffstat (limited to 'src/clear_cmd.cpp')
-rw-r--r--src/clear_cmd.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp
index eb443d85b..73183c504 100644
--- a/src/clear_cmd.cpp
+++ b/src/clear_cmd.cpp
@@ -355,7 +355,7 @@ CommandCost CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* @param tile end tile of area-drag
* @param flags for this command type
* @param p1 start tile of area drag
- * @param p2 unused
+ * @param p2 height difference; eg raise (+1), lower (-1) or level (0)
* @return error or cost of terraforming
*/
CommandCost CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
@@ -364,7 +364,7 @@ CommandCost CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
int ex;
int ey;
int sx, sy;
- uint h, curh;
+ uint h, oldh, curh;
CommandCost money;
CommandCost ret;
CommandCost cost;
@@ -374,7 +374,13 @@ CommandCost CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
/* remember level height */
- h = TileHeight(p1);
+ oldh = TileHeight(p1);
+
+ /* compute new height */
+ h = oldh + p2;
+
+ /* Check range of destination height */
+ if (h > MAX_TILE_HEIGHT) return_cmd_error((oldh == 0) ? STR_1003_ALREADY_AT_SEA_LEVEL : STR_1004_TOO_HIGH);
/* make sure sx,sy are smaller than ex,ey */
ex = TileX(tile);