From 2ec12a3f587f4271a2d8ba5e22af233e1094e321 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 26 Jul 2009 21:50:30 +0000 Subject: (svn r16966) -Codechange: BEGIN_TILE_LOOP and END_TILE_LOOP reworked into TILE_LOOP, which means no more duplication of parameters between BEGIN_TILE_LOOP and END_TILE_LOOP --- src/map_func.h | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'src/map_func.h') diff --git a/src/map_func.h b/src/map_func.h index 1deafc00c..09bbc462d 100644 --- a/src/map_func.h +++ b/src/map_func.h @@ -327,7 +327,7 @@ uint DistanceMaxPlusManhattan(TileIndex, TileIndex); ///< Max + Manhattan uint DistanceFromEdge(TileIndex); ///< shortest distance from any edge of the map /** - * Starts a loop which iterates to a square of tiles + * A loop which iterates to a square of tiles * * This macro starts 2 nested loops which iterates over a square of tiles. * @@ -336,22 +336,10 @@ uint DistanceFromEdge(TileIndex); ///< shortest distance from any edge of the ma * @param h The heigth (y-width) of the square * @param tile The start tile of the square */ -#define BEGIN_TILE_LOOP(var, w, h, tile) \ - { \ - int h_cur = h; \ - uint var = tile; \ - do { \ - int w_cur = w; \ - do { -/** - * Ends the square-loop used before - * - * @see BEGIN_TILE_LOOP - */ -#define END_TILE_LOOP(var, w, h, tile) \ - } while (++var, --w_cur != 0); \ - } while (var += TileDiffXY(0, 1) - (w), --h_cur != 0); \ - } +#define TILE_LOOP(var, w, h, tile) \ + for (uint var = tile, cur_h = (h); cur_h > 0; --cur_h, var += TileDiffXY(0, 1) - (w)) \ + for (uint cur_w = (w); cur_w > 0; --cur_w, var++) + /** * Convert a DiagDirection to a TileIndexDiff * -- cgit v1.2.3-54-g00ecf