Use vehicle order destination map for HasStationInUse()
This commit is contained in:
@@ -2638,18 +2638,17 @@ CommandCost CmdOpenCloseAirport(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
|||||||
*/
|
*/
|
||||||
bool HasStationInUse(StationID station, bool include_company, CompanyID company)
|
bool HasStationInUse(StationID station, bool include_company, CompanyID company)
|
||||||
{
|
{
|
||||||
const Vehicle *v;
|
bool found = false;
|
||||||
FOR_ALL_VEHICLES(v) {
|
IterateOrderRefcountMapForDestinationID(station, [&](CompanyID cid, OrderType order_type, VehicleType veh_type, uint32 refcount) {
|
||||||
if ((v->owner == company) == include_company) {
|
if ((cid == company) == include_company) {
|
||||||
const Order *order;
|
if (order_type == OT_GOTO_STATION || order_type == OT_GOTO_WAYPOINT) {
|
||||||
FOR_VEHICLE_ORDERS(v, order) {
|
found = true;
|
||||||
if ((order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT)) && order->GetDestination() == station) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TileIndexDiffC _dock_tileoffs_chkaround[] = {
|
static const TileIndexDiffC _dock_tileoffs_chkaround[] = {
|
||||||
|
Reference in New Issue
Block a user