diff --git a/src/yapf/yapf_destrail.hpp b/src/yapf/yapf_destrail.hpp --- a/src/yapf/yapf_destrail.hpp +++ b/src/yapf/yapf_destrail.hpp @@ -134,22 +134,11 @@ public: m_destTrackdirs = INVALID_TRACKDIR_BIT; break; - case OT_GOTO_WAYPOINT: { - Waypoint *wp = Waypoint::Get(v->current_order.GetDestination()); - if (wp == NULL) { - /* Invalid waypoint in orders! */ - DEBUG(yapf, 0, "Invalid waypoint in orders == 0x%04X (train %d, company %d)", v->current_order.GetDestination(), v->unitnumber, (CompanyID)v->owner); - break; - } - m_destTile = wp->xy; - if (m_destTile != v->dest_tile) { - /* Something is wrong with orders! */ - DEBUG(yapf, 0, "Invalid v->dest_tile == 0x%04X (train %d, company %d)", v->dest_tile, v->unitnumber, (CompanyID)v->owner); - } + case OT_GOTO_WAYPOINT: + m_destTile = Waypoint::Get(v->current_order.GetDestination())->xy; m_dest_station_id = INVALID_STATION; - m_destTrackdirs = TrackToTrackdirBits(AxisToTrack(GetWaypointAxis(wp->xy))); + m_destTrackdirs = IsRailWaypointTile(m_destTile) ? TrackToTrackdirBits(GetRailStationTrack(m_destTile)) : INVALID_TRACKDIR_BIT; break; - } default: m_destTile = v->dest_tile;