From b42e76d85897af64c7b2ca5c58e15c1286ea639c Mon Sep 17 00:00:00 2001 From: rubidium Date: Mon, 4 Jan 2010 18:49:27 +0000 Subject: (svn r18723) -Codechange: also simplify looping over an area when building trees, desert, rocky areas or leveling land --- src/terraform_gui.cpp | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) (limited to 'src/terraform_gui.cpp') 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; -- cgit v1.2.3-54-g00ecf