summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2017-04-03 21:53:51 +0000
committerpeter1138 <peter1138@openttd.org>2017-04-03 21:53:51 +0000
commit9bc27c9a72f2af5c9526f086884526e8ae8e8f79 (patch)
treefeb1687c014736d307d23e21760900155d401ab6 /src
parent39fa3c7cbd000fa078bc5742748fa1c3b66de12b (diff)
downloadopenttd-9bc27c9a72f2af5c9526f086884526e8ae8e8f79.tar.xz
(svn r27844) -Change: (Yapf) Treat max cost exceeded separately from path too long condition, as destination should not be considered in the former case.
Diffstat (limited to 'src')
-rw-r--r--src/pathfinder/yapf/yapf_costrail.hpp5
-rw-r--r--src/pathfinder/yapf/yapf_type.hpp6
2 files changed, 8 insertions, 3 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. */
diff --git a/src/pathfinder/yapf/yapf_type.hpp b/src/pathfinder/yapf/yapf_type.hpp
index 8d24eee5e..b0d99d660 100644
--- a/src/pathfinder/yapf/yapf_type.hpp
+++ b/src/pathfinder/yapf/yapf_type.hpp
@@ -19,6 +19,7 @@ enum EndSegmentReason {
ESR_RAIL_TYPE, ///< the next tile has a different rail type than our tiles
ESR_INFINITE_LOOP, ///< infinite loop detected
ESR_SEGMENT_TOO_LONG, ///< the segment is too long (possible infinite loop)
+ ESR_MAX_COST_EXCEEDED, ///< maximum cost is exceeded
ESR_CHOICE_FOLLOWS, ///< the next tile contains a choice (the track splits to more than one segments)
ESR_DEPOT, ///< stop in the depot (could be a target next time)
ESR_WAYPOINT, ///< waypoint encountered (could be a target next time)
@@ -43,6 +44,7 @@ enum EndSegmentReasonBits {
ESRB_RAIL_TYPE = 1 << ESR_RAIL_TYPE,
ESRB_INFINITE_LOOP = 1 << ESR_INFINITE_LOOP,
ESRB_SEGMENT_TOO_LONG = 1 << ESR_SEGMENT_TOO_LONG,
+ ESRB_MAX_COST_EXCEEDED = 1 << ESR_MAX_COST_EXCEEDED,
ESRB_CHOICE_FOLLOWS = 1 << ESR_CHOICE_FOLLOWS,
ESRB_DEPOT = 1 << ESR_DEPOT,
ESRB_WAYPOINT = 1 << ESR_WAYPOINT,
@@ -63,7 +65,7 @@ enum EndSegmentReasonBits {
ESRB_CACHED_MASK = ESRB_DEAD_END | ESRB_RAIL_TYPE | ESRB_INFINITE_LOOP | ESRB_SEGMENT_TOO_LONG | ESRB_CHOICE_FOLLOWS | ESRB_DEPOT | ESRB_WAYPOINT | ESRB_STATION | ESRB_SAFE_TILE,
/* Reasons to abort pathfinding in this direction. */
- ESRB_ABORT_PF_MASK = ESRB_DEAD_END | ESRB_PATH_TOO_LONG | ESRB_INFINITE_LOOP | ESRB_FIRST_TWO_WAY_RED,
+ ESRB_ABORT_PF_MASK = ESRB_DEAD_END | ESRB_PATH_TOO_LONG | ESRB_MAX_COST_EXCEEDED | ESRB_INFINITE_LOOP | ESRB_FIRST_TWO_WAY_RED,
};
DECLARE_ENUM_AS_BIT_SET(EndSegmentReasonBits)
@@ -71,7 +73,7 @@ DECLARE_ENUM_AS_BIT_SET(EndSegmentReasonBits)
inline CStrA ValueStr(EndSegmentReasonBits bits)
{
static const char * const end_segment_reason_names[] = {
- "DEAD_END", "RAIL_TYPE", "INFINITE_LOOP", "SEGMENT_TOO_LONG", "CHOICE_FOLLOWS",
+ "DEAD_END", "RAIL_TYPE", "INFINITE_LOOP", "SEGMENT_TOO_LONG", "MAX_COST_EXCEEDED", "CHOICE_FOLLOWS",
"DEPOT", "WAYPOINT", "STATION", "SAFE_TILE",
"PATH_TOO_LONG", "FIRST_TWO_WAY_RED", "LOOK_AHEAD_END", "TARGET_REACHED"
};