summaryrefslogtreecommitdiff
path: root/src/terraform_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-12-13 11:21:53 +0000
committerrubidium <rubidium@openttd.org>2010-12-13 11:21:53 +0000
commitb448b7c98d8db341a0546848f0b00a46385ef272 (patch)
tree24776ddd8f460e2b833af2d28ac972eb5b370bc9 /src/terraform_cmd.cpp
parentc0999109a9aabce2aac15306782b9d2ae81af314 (diff)
downloadopenttd-b448b7c98d8db341a0546848f0b00a46385ef272.tar.xz
(svn r21493) -Codechange: don't use the full 32 bits of the level land command to tell whether to raise, lower or keep the level of the first selected tile
Diffstat (limited to 'src/terraform_cmd.cpp')
-rw-r--r--src/terraform_cmd.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp
index 1b58a91da..406bdf5be 100644
--- a/src/terraform_cmd.cpp
+++ b/src/terraform_cmd.cpp
@@ -378,7 +378,8 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
* @param tile end tile of area-drag
* @param flags for this command type
* @param p1 start tile of area drag
- * @param p2 height difference; eg raise (+1), lower (-1) or level (0)
+ * @param p2 various bitstuffed data.
+ * bits 1 - 2: Mode of leveling \c LevelMode.
* @param text unused
* @return the cost of this operation or an error
*/
@@ -392,14 +393,21 @@ CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
uint oldh = TileHeight(p1);
/* compute new height */
- uint h = oldh + (int8)p2;
+ uint h = oldh;
+ LevelMode lm = (LevelMode)GB(p2, 1, 2);
+ switch (lm) {
+ case LM_LEVEL: break;
+ case LM_RAISE: h++; break;
+ case LM_LOWER: h--; break;
+ default: return CMD_ERROR;
+ }
/* Check range of destination height */
if (h > MAX_TILE_HEIGHT) return_cmd_error((oldh == 0) ? STR_ERROR_ALREADY_AT_SEA_LEVEL : STR_ERROR_TOO_HIGH);
Money money = GetAvailableMoneyForCommand();
CommandCost cost(EXPENSES_CONSTRUCTION);
- CommandCost last_error((p2 == 0) ? STR_ERROR_ALREADY_LEVELLED : INVALID_STRING_ID);
+ CommandCost last_error(lm == LM_LEVEL ? STR_ERROR_ALREADY_LEVELLED : INVALID_STRING_ID);
bool had_success = false;
TileArea ta(tile, p1);