summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/road_cmd.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 175e776e5..d9825c9bf 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -809,7 +809,9 @@ do_clear:;
*/
static bool CanConnectToRoad(TileIndex tile, RoadType rt, DiagDirection dir)
{
- RoadBits bits = GetAnyRoadBits(tile + TileOffsByDiagDir(dir), rt, false);
+ tile += TileOffsByDiagDir(dir);
+ if (!IsValidTile(tile)) return false;
+ RoadBits bits = GetAnyRoadBits(tile, rt, false);
return (bits & DiagDirToRoadBits(ReverseDiagDir(dir))) != 0;
}