summaryrefslogtreecommitdiff
path: root/src/pathfinder/yapf/yapf_costrail.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/pathfinder/yapf/yapf_costrail.hpp')
-rw-r--r--src/pathfinder/yapf/yapf_costrail.hpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/pathfinder/yapf/yapf_costrail.hpp b/src/pathfinder/yapf/yapf_costrail.hpp
index f8047955c..d9d89b12f 100644
--- a/src/pathfinder/yapf/yapf_costrail.hpp
+++ b/src/pathfinder/yapf/yapf_costrail.hpp
@@ -479,7 +479,7 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
/* Finish if we already exceeded the maximum path cost (i.e. when
* searching for the nearest depot). */
if (m_max_cost > 0 && (parent_cost + segment_entry_cost + segment_cost) > m_max_cost) {
- end_segment_reason |= ESRB_PATH_TOO_LONG;
+ end_segment_reason |= ESRB_MAX_COST_EXCEEDED;
}
/* Move to the next tile/trackdir. */
@@ -555,6 +555,9 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
} // for (;;)
+ /* Don't consider path any further it if exceeded max_cost. */
+ if (end_segment_reason & ESRB_MAX_COST_EXCEEDED) return false;
+
bool target_seen = false;
if ((end_segment_reason & ESRB_POSSIBLE_TARGET) != ESRB_NONE) {
/* Depot, station or waypoint. */