summaryrefslogtreecommitdiff
path: root/src/pathfinder/yapf/yapf_road.cpp
diff options
context:
space:
mode:
authorCharles Pigott <charlespigott@googlemail.com>2021-02-21 23:58:01 +0000
committerCharles Pigott <charlespigott@googlemail.com>2021-02-22 00:25:47 +0000
commit80fb1c74f04be7a571f6a721d2f6d82ed95de9b6 (patch)
tree1560043385ad6ce68e80c28aed35f718e0b26064 /src/pathfinder/yapf/yapf_road.cpp
parentb749d6f1cb53911f09b69397c0f3553e0eb64d39 (diff)
downloadopenttd-80fb1c74f04be7a571f6a721d2f6d82ed95de9b6.tar.xz
Change: Make pathfinder account for maximum order speed, if set
Diffstat (limited to 'src/pathfinder/yapf/yapf_road.cpp')
-rw-r--r--src/pathfinder/yapf/yapf_road.cpp2
1 files changed, 1 insertions, 1 deletions
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);