Add wrapper to iterate vehicle pool with vehicle type filter
Without needing to dereference vehicle pointers if using tagged pointers
This commit is contained in:
@@ -3032,9 +3032,9 @@ bool CanBuildVehicleInfrastructure(VehicleType type, byte subtype)
|
||||
}
|
||||
|
||||
/* We should be able to build infrastructure when we have the actual vehicle type */
|
||||
for (const Vehicle *v : Vehicle::Iterate()) {
|
||||
if (v->type == VEH_ROAD && GetRoadTramType(RoadVehicle::From(v)->roadtype) != (RoadTramType)subtype) continue;
|
||||
if (v->owner == _local_company && v->type == type) return true;
|
||||
for (const Vehicle *v : Vehicle::IterateType(type)) {
|
||||
if (type == VEH_ROAD && GetRoadTramType(RoadVehicle::From(v)->roadtype) != (RoadTramType)subtype) continue;
|
||||
if (v->owner == _local_company) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user