(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

This commit is contained in:
rubidium
2009-07-26 21:50:30 +00:00
parent 47a37b6093
commit 2ec12a3f58
13 changed files with 71 additions and 87 deletions

View File

@@ -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
*