summaryrefslogtreecommitdiff
path: root/src/pathfinder
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-12-27 22:32:47 +0000
committerrubidium <rubidium@openttd.org>2010-12-27 22:32:47 +0000
commitade19e52429321b4f927af77a96438d13fbdcbfe (patch)
tree52c00ab6c30af425d0c170ced7b50b53e09c8e5e /src/pathfinder
parent639e22b83b4e49b126f696102e96c2c598916049 (diff)
downloadopenttd-ade19e52429321b4f927af77a96438d13fbdcbfe.tar.xz
(svn r21651) -Fix [FS#4338] (r21229): infinite loop in the road pathfinder due to bouncing around in an "one way" trap; two one ways pointing towards eachother making it impossible to leave
Diffstat (limited to 'src/pathfinder')
-rw-r--r--src/pathfinder/yapf/yapf_road.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/pathfinder/yapf/yapf_road.cpp b/src/pathfinder/yapf/yapf_road.cpp
index eb832b320..57d020622 100644
--- a/src/pathfinder/yapf/yapf_road.cpp
+++ b/src/pathfinder/yapf/yapf_road.cpp
@@ -103,6 +103,7 @@ public:
FORCEINLINE bool PfCalcCost(Node& n, const TrackFollower *tf)
{
int segment_cost = 0;
+ uint tiles = 0;
/* start at n.m_key.m_tile / n.m_key.m_td and walk to the end of segment */
TileIndex tile = n.m_key.m_tile;
Trackdir trackdir = n.m_key.m_td;
@@ -134,6 +135,7 @@ public:
/* if we skipped some tunnel tiles, add their cost */
segment_cost += F.m_tiles_skipped * YAPF_TILE_LENGTH;
+ tiles += F.m_tiles_skipped + 1;
/* add hilly terrain penalty */
segment_cost += Yapf().SlopeCost(tile, F.m_new_tile, trackdir);
@@ -148,6 +150,7 @@ public:
/* move to the next tile */
tile = F.m_new_tile;
trackdir = new_td;
+ if (tiles > MAX_MAP_SIZE) break;;
};
/* save end of segment back to the node */