summaryrefslogtreecommitdiff
path: root/src/map_func.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-07-26 21:50:30 +0000
committerrubidium <rubidium@openttd.org>2009-07-26 21:50:30 +0000
commit2ec12a3f587f4271a2d8ba5e22af233e1094e321 (patch)
tree114688ff4bf43f5c94891a3fa67b5b172d187323 /src/map_func.h
parent47a37b6093c3bb93dba81e4d3440c4098699a849 (diff)
downloadopenttd-2ec12a3f587f4271a2d8ba5e22af233e1094e321.tar.xz
(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
Diffstat (limited to 'src/map_func.h')
-rw-r--r--src/map_func.h22
1 files changed, 5 insertions, 17 deletions
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
*