diff -r 6d64230b9fb9 -r 51bff16a04c9 src/landscape.cpp --- a/src/landscape.cpp Thu Dec 18 18:47:39 2008 +0000 +++ b/src/landscape.cpp Fri Dec 19 01:32:07 2008 +0200 @@ -654,7 +654,7 @@ TileIndex _cur_tileloop_tile; -#define TILELOOP_BITS 4 +#define TILELOOP_BITS 1 #define TILELOOP_SIZE (1 << TILELOOP_BITS) #define TILELOOP_ASSERTMASK ((TILELOOP_SIZE - 1) + ((TILELOOP_SIZE - 1) << MapLogX())) #define TILELOOP_CHKMASK (((1 << (MapLogX() - TILELOOP_BITS))-1) << TILELOOP_BITS) @@ -665,6 +665,7 @@ assert((tile & ~TILELOOP_ASSERTMASK) == 0); uint count = (MapSizeX() / TILELOOP_SIZE) * (MapSizeY() / TILELOOP_SIZE); + do { _tile_type_procs[GetTileType(tile)]->tile_loop_proc(tile); @@ -673,11 +674,12 @@ } else { tile = TILE_MASK(tile - TILELOOP_SIZE * (MapSizeX() / TILELOOP_SIZE - 1) + TileDiffXY(0, TILELOOP_SIZE)); /* x would overflow, also increase y */ } - } while (--count != 0); + } while (count && --count != 0); + assert((tile & ~TILELOOP_ASSERTMASK) == 0); tile += 9; - if (tile & TILELOOP_CHKMASK) { + if (tile & ~TILELOOP_ASSERTMASK) { tile = (tile + MapSizeX()) & TILELOOP_ASSERTMASK; } _cur_tileloop_tile = tile;