diff options
author | Charles Pigott <charlespigott@googlemail.com> | 2021-02-21 23:58:01 +0000 |
---|---|---|
committer | Charles Pigott <charlespigott@googlemail.com> | 2021-02-22 00:25:47 +0000 |
commit | 80fb1c74f04be7a571f6a721d2f6d82ed95de9b6 (patch) | |
tree | 1560043385ad6ce68e80c28aed35f718e0b26064 /src/pathfinder/yapf | |
parent | b749d6f1cb53911f09b69397c0f3553e0eb64d39 (diff) | |
download | openttd-80fb1c74f04be7a571f6a721d2f6d82ed95de9b6.tar.xz |
Change: Make pathfinder account for maximum order speed, if set
Diffstat (limited to 'src/pathfinder/yapf')
-rw-r--r-- | src/pathfinder/yapf/yapf_costrail.hpp | 2 | ||||
-rw-r--r-- | src/pathfinder/yapf/yapf_road.cpp | 2 |
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); |