Fix OrderDestinationIsAllowed not handling nearest depot orders

This commit is contained in:
Jonathan G Rennison
2019-09-27 08:19:24 +01:00
parent 5008a09fe9
commit ca4db69f12

View File

@@ -147,11 +147,19 @@ static bool OrderDestinationIsAllowed(const Order *order, const Vehicle *v, Owne
switch (order->GetType()) { switch (order->GetType()) {
case OT_IMPLICIT: case OT_IMPLICIT:
case OT_GOTO_STATION: case OT_GOTO_STATION:
case OT_GOTO_WAYPOINT: dest_owner = BaseStation::Get(order->GetDestination())->owner; break; case OT_GOTO_WAYPOINT:
case OT_GOTO_DEPOT: dest_owner = (v->type == VEH_AIRCRAFT) ? Station::Get(order->GetDestination())->owner : GetTileOwner(Depot::Get(order->GetDestination())->xy); break; dest_owner = BaseStation::Get(order->GetDestination())->owner;
break;
case OT_GOTO_DEPOT:
if ((order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) return true;
dest_owner = (v->type == VEH_AIRCRAFT) ? Station::Get(order->GetDestination())->owner : GetTileOwner(Depot::Get(order->GetDestination())->xy);
break;
case OT_LOADING_ADVANCE: case OT_LOADING_ADVANCE:
case OT_LOADING: dest_owner = Station::Get(v->last_station_visited)->owner; break; case OT_LOADING:
default: return true; dest_owner = Station::Get(v->last_station_visited)->owner;
break;
default:
return true;
} }
return dest_owner != owner && IsInfraUsageAllowed(v->type, v->owner, dest_owner); return dest_owner != owner && IsInfraUsageAllowed(v->type, v->owner, dest_owner);
} }