From b9e19cc6c15df0e66152d46df767b6370b89a9db Mon Sep 17 00:00:00 2001 From: yexo Date: Tue, 3 Jan 2012 00:44:23 +0000 Subject: (svn r23723) -Codechange: speedup flood checks a bit --- src/object_cmd.cpp | 4 ++-- src/water_cmd.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp index fa7ea68dc..117212e1f 100644 --- a/src/object_cmd.cpp +++ b/src/object_cmd.cpp @@ -697,8 +697,8 @@ void GenerateObjects() assert(tile < MapSize()); break; } - tile = AddTileIndexDiffCWrap(tile, TileIndexDiffCByDiagDir(dir)); - if (tile == INVALID_TILE) break; + tile += TileOffsByDiagDir(dir); + if (!IsValidTile(tile)) break; } } } diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index cab880926..bf1ec56c3 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -1148,8 +1148,8 @@ void TileLoop_Water(TileIndex tile) 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 @@ void TileLoop_Water(TileIndex tile) 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; -- cgit v1.2.3-70-g09d2