diff --git a/src/pathfinder/yapf/yapf_ship.cpp b/src/pathfinder/yapf/yapf_ship.cpp index a5b9fc3e13..b4e2d57a2f 100644 --- a/src/pathfinder/yapf/yapf_ship.cpp +++ b/src/pathfinder/yapf/yapf_ship.cpp @@ -44,8 +44,9 @@ protected: public: void SetDestination(const Ship *v) { - if (v->current_order.IsType(OT_GOTO_STATION)) { + if (v->current_order.IsType(OT_GOTO_STATION) || v->current_order.IsType(OT_LEAVESTATION)) { this->dest_station = v->current_order.GetDestination(); + assert(Station::IsValidID(this->dest_station)); this->dest_tile = CalcClosestStationTile(this->dest_station, v->tile, StationType::Dock); this->dest_trackdirs = INVALID_TRACKDIR_BIT; } else { diff --git a/src/pathfinder/yapf/yapf_ship_regions.cpp b/src/pathfinder/yapf/yapf_ship_regions.cpp index 36a939ea74..6c79838694 100644 --- a/src/pathfinder/yapf/yapf_ship_regions.cpp +++ b/src/pathfinder/yapf/yapf_ship_regions.cpp @@ -184,8 +184,9 @@ public: Tpf pf(std::min(static_cast(Map::Size() * NODES_PER_REGION) / WATER_REGION_NUMBER_OF_TILES, MAX_NUMBER_OF_NODES)); pf.SetDestination(start_water_region_patch); - if (v->current_order.IsType(OT_GOTO_STATION)) { + if (v->current_order.IsType(OT_GOTO_STATION) || v->current_order.IsType(OT_LEAVESTATION)) { DestinationID station_id = v->current_order.GetDestination(); + assert(Station::IsValidID(station_id)); const BaseStation *station = BaseStation::Get(station_id); TileArea tile_area; station->GetTileArea(&tile_area, StationType::Dock);