diff options
author | Charles Pigott <charlespigott@googlemail.com> | 2021-02-13 22:18:12 +0000 |
---|---|---|
committer | Charles Pigott <charlespigott@googlemail.com> | 2021-02-21 10:53:25 +0000 |
commit | c461999b2b543238d0be2f88ea3d88544c2114ab (patch) | |
tree | 00f56088456cc8b0cdbc11dcdb20117696402f2b | |
parent | e1b1608dc6cb0f2befebcb7ee5255881a5861098 (diff) | |
download | openttd-c461999b2b543238d0be2f88ea3d88544c2114ab.tar.xz |
Fix #8594: [NRT] Road pathfinder did not account for roadtype speed limits
-rw-r--r-- | src/pathfinder/follow_track.hpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/pathfinder/follow_track.hpp b/src/pathfinder/follow_track.hpp index 5bc9ab03c..cac8ec5c5 100644 --- a/src/pathfinder/follow_track.hpp +++ b/src/pathfinder/follow_track.hpp @@ -466,13 +466,18 @@ public: if (!IsWaterTT() && IsBridgeTile(m_old_tile)) { int spd = GetBridgeSpec(GetBridgeType(m_old_tile))->speed; if (IsRoadTT()) spd *= 2; - if (max_speed > spd) max_speed = spd; + max_speed = std::min(max_speed, spd); } /* Check for speed limit imposed by railtype */ if (IsRailTT()) { uint16 rail_speed = GetRailTypeInfo(GetRailType(m_old_tile))->max_speed; if (rail_speed > 0) max_speed = std::min<int>(max_speed, rail_speed); } + if (IsRoadTT()) { + /* max_speed is already in roadvehicle units, no need to further modify (divide by 2) */ + uint16 road_speed = GetRoadTypeInfo(GetRoadType(m_old_tile, GetRoadTramType(RoadVehicle::From(m_veh)->roadtype)))->max_speed; + if (road_speed > 0) max_speed = std::min<int>(max_speed, road_speed); + } /* if min speed was requested, return it */ if (pmin_speed != nullptr) *pmin_speed = min_speed; |