diff --git a/src/pathfinder/yapf/yapf_destrail.hpp b/src/pathfinder/yapf/yapf_destrail.hpp index 7f89639bf2..1c41579cba 100644 --- a/src/pathfinder/yapf/yapf_destrail.hpp +++ b/src/pathfinder/yapf/yapf_destrail.hpp @@ -118,6 +118,7 @@ protected: TileIndex m_destTile; TrackdirBits m_destTrackdirs; StationID m_dest_station_id; + bool m_any_depot; /** to access inherited path finder */ Tpf& Yapf() @@ -128,6 +129,7 @@ protected: public: void SetDestination(const Train *v) { + m_any_depot = false; switch (v->current_order.GetType()) { case OT_GOTO_WAYPOINT: if (!Waypoint::Get(v->current_order.GetDestination())->IsSingleTile()) { @@ -146,6 +148,12 @@ public: m_destTrackdirs = INVALID_TRACKDIR_BIT; break; + case OT_GOTO_DEPOT: + if (v->current_order.GetDepotActionType() & ODATFB_NEAREST_DEPOT) { + m_any_depot = true; + } + FALLTHROUGH; + default: m_destTile = v->dest_tile; m_dest_station_id = INVALID_STATION; @@ -170,6 +178,10 @@ public: && (GetRailStationTrack(tile) == TrackdirToTrack(td)); } + if (m_any_depot) { + return IsRailDepotTile(tile); + } + return (tile == m_destTile) && HasTrackdir(m_destTrackdirs, td); }