summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pathfinder/yapf/yapf_costrail.hpp2
-rw-r--r--src/pathfinder/yapf/yapf_road.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/pathfinder/yapf/yapf_costrail.hpp b/src/pathfinder/yapf/yapf_costrail.hpp
index e6422dc24..2f4834633 100644
--- a/src/pathfinder/yapf/yapf_costrail.hpp
+++ b/src/pathfinder/yapf/yapf_costrail.hpp
@@ -464,7 +464,7 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
{
int min_speed = 0;
int max_speed = tf->GetSpeedLimit(&min_speed);
- int max_veh_speed = v->GetDisplayMaxSpeed();
+ int max_veh_speed = std::min<int>(v->GetDisplayMaxSpeed(), v->current_order.GetMaxSpeed());
if (max_speed < max_veh_speed) {
extra_cost += YAPF_TILE_LENGTH * (max_veh_speed - max_speed) * (4 + tf->m_tiles_skipped) / max_veh_speed;
}
diff --git a/src/pathfinder/yapf/yapf_road.cpp b/src/pathfinder/yapf/yapf_road.cpp
index 98cd889c9..0122e1d88 100644
--- a/src/pathfinder/yapf/yapf_road.cpp
+++ b/src/pathfinder/yapf/yapf_road.cpp
@@ -159,7 +159,7 @@ public:
/* add min/max speed penalties */
int min_speed = 0;
- int max_veh_speed = v->GetDisplayMaxSpeed();
+ int max_veh_speed = std::min<int>(v->GetDisplayMaxSpeed(), v->current_order.GetMaxSpeed() * 2);
int max_speed = F.GetSpeedLimit(&min_speed);
if (max_speed < max_veh_speed) segment_cost += YAPF_TILE_LENGTH * (max_veh_speed - max_speed) * (4 + F.m_tiles_skipped) / max_veh_speed;
if (min_speed > max_veh_speed) segment_cost += YAPF_TILE_LENGTH * (min_speed - max_veh_speed);