Mercurial > hg > openttd
changeset 18874:cbdefaa36526 draft
(svn r23723) -Codechange: speedup flood checks a bit
author | yexo <yexo@openttd.org> |
---|---|
date | Tue, 03 Jan 2012 00:44:23 +0000 |
parents | 2b302b40fba9 |
children | b09d72b6f543 |
files | src/object_cmd.cpp src/water_cmd.cpp |
diffstat | 2 files changed, 6 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/object_cmd.cpp +++ b/src/object_cmd.cpp @@ -697,8 +697,8 @@ assert(tile < MapSize()); break; } - tile = AddTileIndexDiffCWrap(tile, TileIndexDiffCByDiagDir(dir)); - if (tile == INVALID_TILE) break; + tile += TileOffsByDiagDir(dir); + if (!IsValidTile(tile)) break; } } }
--- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -1148,8 +1148,8 @@ switch (GetFloodingBehaviour(tile)) { case FLOOD_ACTIVE: for (Direction dir = DIR_BEGIN; dir < DIR_END; dir++) { - TileIndex dest = AddTileIndexDiffCWrap(tile, TileIndexDiffCByDir(dir)); - if (dest == INVALID_TILE) continue; + TileIndex dest = tile + TileOffsByDir(dir); + if (!IsValidTile(dest)) continue; /* do not try to flood water tiles - increases performance a lot */ if (IsTileType(dest, MP_WATER)) continue; @@ -1167,8 +1167,8 @@ Slope slope_here = GetFoundationSlope(tile) & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP; uint dir; FOR_EACH_SET_BIT(dir, _flood_from_dirs[slope_here]) { - TileIndex dest = AddTileIndexDiffCWrap(tile, TileIndexDiffCByDir((Direction)dir)); - if (dest == INVALID_TILE) continue; + TileIndex dest = tile + TileOffsByDir(dir); + if (!IsValidTile(dest)) continue; FloodingBehaviour dest_behaviour = GetFloodingBehaviour(dest); if ((dest_behaviour == FLOOD_ACTIVE) || (dest_behaviour == FLOOD_PASSIVE)) return;