summaryrefslogtreecommitdiff
path: root/src/terraform_gui.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-01-04 18:49:27 +0000
committerrubidium <rubidium@openttd.org>2010-01-04 18:49:27 +0000
commitb42e76d85897af64c7b2ca5c58e15c1286ea639c (patch)
tree1fdd445654e0732c63926e69bf4ab8eb23861c96 /src/terraform_gui.cpp
parent76bf94bf0028eeb9b147c8b1ec23101e5f611bac (diff)
downloadopenttd-b42e76d85897af64c7b2ca5c58e15c1286ea639c.tar.xz
(svn r18723) -Codechange: also simplify looping over an area when building trees, desert, rocky areas or leveling land
Diffstat (limited to 'src/terraform_gui.cpp')
-rw-r--r--src/terraform_gui.cpp30
1 files changed, 6 insertions, 24 deletions
diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp
index c13a94872..7ce150317 100644
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -50,21 +50,12 @@ void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2)
/** Scenario editor command that generates desert areas */
static void GenerateDesertArea(TileIndex end, TileIndex start)
{
- int size_x, size_y;
- int sx = TileX(start);
- int sy = TileY(start);
- int ex = TileX(end);
- int ey = TileY(end);
-
if (_game_mode != GM_EDITOR) return;
- if (ex < sx) Swap(ex, sx);
- if (ey < sy) Swap(ey, sy);
- size_x = (ex - sx) + 1;
- size_y = (ey - sy) + 1;
-
_generating_world = true;
- TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) {
+
+ TileArea ta(start, end);
+ TILE_AREA_LOOP(tile, ta) {
SetTropicZone(tile, (_ctrl_pressed) ? TROPICZONE_NORMAL : TROPICZONE_DESERT);
DoCommandP(tile, 0, 0, CMD_LANDSCAPE_CLEAR);
MarkTileDirtyByTile(tile);
@@ -75,21 +66,12 @@ static void GenerateDesertArea(TileIndex end, TileIndex start)
/** Scenario editor command that generates rocky areas */
static void GenerateRockyArea(TileIndex end, TileIndex start)
{
- int size_x, size_y;
- bool success = false;
- int sx = TileX(start);
- int sy = TileY(start);
- int ex = TileX(end);
- int ey = TileY(end);
-
if (_game_mode != GM_EDITOR) return;
- if (ex < sx) Swap(ex, sx);
- if (ey < sy) Swap(ey, sy);
- size_x = (ex - sx) + 1;
- size_y = (ey - sy) + 1;
+ bool success = false;
+ TileArea ta(start, end);
- TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) {
+ TILE_AREA_LOOP(tile, ta) {
switch (GetTileType(tile)) {
case MP_TREES:
if (GetTreeGround(tile) == TREE_GROUND_SHORE) continue;