summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-02-06 20:24:44 +0000
committerfrosch <frosch@openttd.org>2009-02-06 20:24:44 +0000
commit5a369e1b50d16ed4fcf8c8dc125cf70743577446 (patch)
tree590d267ae42ac2eec8c71d686c507ee75bd3ebaf /src
parent25a5178aaf517cc295b1586633a0054601dc2133 (diff)
downloadopenttd-5a369e1b50d16ed4fcf8c8dc125cf70743577446.tar.xz
(svn r15380) -Fix (r15190)[FS#2603]: Do not use TileY() on negative TileIndexDiffs. But the test was not needed anyway, as those tiles were already tested in previous iterations.
Diffstat (limited to 'src')
-rw-r--r--src/town_cmd.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 5af69578d..5c7e35a94 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -716,7 +716,7 @@ static RoadBits GetTownRoadBits(TileIndex tile)
}
/**
- * Check if a neighboring tile has a road
+ * Check if certain neighboring tiles have a road in a specific direction
*
* @param tile curent tile
* @param dir target direction
@@ -726,6 +726,8 @@ static RoadBits GetTownRoadBits(TileIndex tile)
*/
static bool IsNeighborRoadTile(TileIndex tile, const DiagDirection dir, uint dist_multi)
{
+ if (!IsValidTile(tile)) return false;
+
/* Lookup table for the used diff values */
const TileIndexDiff tid_lt[3] = {
TileOffsByDiagDir(ChangeDiagDir(dir, DIAGDIRDIFF_90RIGHT)),
@@ -747,7 +749,9 @@ static bool IsNeighborRoadTile(TileIndex tile, const DiagDirection dir, uint dis
if (pos & 2) cur += tid_lt[2];
cur = (uint)(pos / 4) * cur; // Multiply for the fitting distance
- if (IsValidTile(tile + TileXY(TileX(cur) / 2, TileY(cur) / 2)) && IsValidTile(tile + cur) && GetTownRoadBits(TILE_ADD(tile, cur)) & DiagDirToRoadBits((pos & 2) ? dir : ReverseDiagDir(dir))) return true;
+
+ if (IsValidTile(tile + cur) &&
+ GetTownRoadBits(TILE_ADD(tile, cur)) & DiagDirToRoadBits((pos & 2) ? dir : ReverseDiagDir(dir))) return true;
}
return false;
}