summaryrefslogtreecommitdiff
path: root/src/terraform_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-12-13 15:15:02 +0000
committerrubidium <rubidium@openttd.org>2010-12-13 15:15:02 +0000
commit6892cc8a60df5ea34dc882eaa19d00fbdfa0a87d (patch)
treedac29ea6e8a497476ccca38533bf4a47e52948f6 /src/terraform_cmd.cpp
parentb20e77be921acc32b5887f9f35ecae8573c588af (diff)
downloadopenttd-6892cc8a60df5ea34dc882eaa19d00fbdfa0a87d.tar.xz
(svn r21500) -Feature [FS#730]: diagonal tile clearing and terraforming. Based on patch by fonsinchen
Diffstat (limited to 'src/terraform_cmd.cpp')
-rw-r--r--src/terraform_cmd.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp
index b9614b035..5cb7e6b66 100644
--- a/src/terraform_cmd.cpp
+++ b/src/terraform_cmd.cpp
@@ -379,6 +379,7 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
* @param flags for this command type
* @param p1 start tile of area drag
* @param p2 various bitstuffed data.
+ * bit 0: Whether to use the Orthogonal (0) or Diagonal (1) iterator.
* bits 1 - 2: Mode of leveling \c LevelMode.
* @param text unused
* @return the cost of this operation or an error
@@ -411,7 +412,9 @@ CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
bool had_success = false;
TileArea ta(tile, p1);
- TILE_AREA_LOOP(t, ta) {
+ TileIterator *iter = HasBit(p2, 0) ? (TileIterator *)new DiagonalTileIterator(tile, p1) : new OrthogonalTileIterator(ta);
+ for (; *iter != INVALID_TILE; ++(*iter)) {
+ TileIndex t = *iter;
uint curh = TileHeight(t);
while (curh != h) {
CommandCost ret = DoCommand(t, SLOPE_N, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND);
@@ -424,6 +427,7 @@ CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
money -= ret.GetCost();
if (money < 0) {
_additional_cash_required = ret.GetCost();
+ delete iter;
return cost;
}
DoCommand(t, SLOPE_N, (curh > h) ? 0 : 1, flags, CMD_TERRAFORM_LAND);
@@ -435,5 +439,6 @@ CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
}
}
+ delete iter;
return had_success ? cost : last_error;
}