summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfonsinchen <fonsinchen@openttd.org>2014-02-02 14:53:52 +0000
committerfonsinchen <fonsinchen@openttd.org>2014-02-02 14:53:52 +0000
commitdda4ffab5e017c6e782c7ee10208fb0d364e907b (patch)
treeae872f19500fccc47243a728fee4909cf50ac238
parent547e521381a4794c122e4fcea166b6e75b5bc48f (diff)
downloadopenttd-dda4ffab5e017c6e782c7ee10208fb0d364e907b.tar.xz
(svn r26290) -Codechange: Use nicer orthogonal tile iterator constructor and simplify calculation of explosion points when clearing.
-rw-r--r--src/landscape.cpp10
-rw-r--r--src/terraform_cmd.cpp3
2 files changed, 5 insertions, 8 deletions
diff --git a/src/landscape.cpp b/src/landscape.cpp
index d69275dd3..d5b06422a 100644
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -667,8 +667,7 @@ CommandCost CmdClearArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
const Company *c = (flags & (DC_AUTO | DC_BANKRUPT)) ? NULL : Company::GetIfValid(_current_company);
int limit = (c == NULL ? INT32_MAX : GB(c->clear_limit, 16, 16));
- TileArea ta(tile, p1);
- TileIterator *iter = HasBit(p2, 0) ? (TileIterator *)new DiagonalTileIterator(tile, p1) : new OrthogonalTileIterator(ta);
+ TileIterator *iter = HasBit(p2, 0) ? (TileIterator *)new DiagonalTileIterator(tile, p1) : new OrthogonalTileIterator(tile, p1);
for (; *iter != INVALID_TILE; ++(*iter)) {
TileIndex t = *iter;
CommandCost ret = DoCommand(t, 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR);
@@ -692,11 +691,10 @@ CommandCost CmdClearArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
/* draw explosion animation...
* Disable explosions when game is paused. Looks silly and blocks the view. */
- TileIndex off = t - ta.tile;
- if ((TileX(off) == 0 || TileX(off) == ta.w - 1U) && (TileY(off) == 0 || TileY(off) == ta.h - 1U) && _pause_mode == PM_UNPAUSED) {
- /* big explosion in each corner, or small explosion for single tiles */
+ if ((t == tile || t == p1) && _pause_mode == PM_UNPAUSED) {
+ /* big explosion in two corners, or small explosion for single tiles */
CreateEffectVehicleAbove(TileX(t) * TILE_SIZE + TILE_SIZE / 2, TileY(t) * TILE_SIZE + TILE_SIZE / 2, 2,
- ta.w == 1 && ta.h == 1 ? EV_EXPLOSION_SMALL : EV_EXPLOSION_LARGE
+ TileX(tile) == TileX(p1) && TileY(tile) == TileY(p1) ? EV_EXPLOSION_SMALL : EV_EXPLOSION_LARGE
);
}
} else {
diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp
index 8c0c63ac0..7321a6d83 100644
--- a/src/terraform_cmd.cpp
+++ b/src/terraform_cmd.cpp
@@ -424,8 +424,7 @@ CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
int limit = (c == NULL ? INT32_MAX : GB(c->terraform_limit, 16, 16));
if (limit == 0) return_cmd_error(STR_ERROR_TERRAFORM_LIMIT_REACHED);
- TileArea ta(tile, p1);
- TileIterator *iter = HasBit(p2, 0) ? (TileIterator *)new DiagonalTileIterator(tile, p1) : new OrthogonalTileIterator(ta);
+ TileIterator *iter = HasBit(p2, 0) ? (TileIterator *)new DiagonalTileIterator(tile, p1) : new OrthogonalTileIterator(tile, p1);
for (; *iter != INVALID_TILE; ++(*iter)) {
TileIndex t = *iter;
uint curh = TileHeight(t);