Use vehicle order destination map for HasStationInUse()

This commit is contained in:
Jonathan G Rennison
2019-05-12 04:24:36 +01:00
parent 8196789eeb
commit 512bb5ca4d

View File

@@ -2638,19 +2638,18 @@ CommandCost CmdOpenCloseAirport(TileIndex tile, DoCommandFlag flags, uint32 p1,
*/
bool HasStationInUse(StationID station, bool include_company, CompanyID company)
{
const Vehicle *v;
FOR_ALL_VEHICLES(v) {
if ((v->owner == company) == include_company) {
const Order *order;
FOR_VEHICLE_ORDERS(v, order) {
if ((order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT)) && order->GetDestination() == station) {
return true;
}
}
}
}
bool found = false;
IterateOrderRefcountMapForDestinationID(station, [&](CompanyID cid, OrderType order_type, VehicleType veh_type, uint32 refcount) {
if ((cid == company) == include_company) {
if (order_type == OT_GOTO_STATION || order_type == OT_GOTO_WAYPOINT) {
found = true;
return false;
}
}
return true;
});
return found;
}
static const TileIndexDiffC _dock_tileoffs_chkaround[] = {
{-1, 0},