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:
Jonathan G Rennison
2024-02-25 13:38:49 +00:00
parent be4aea0dad
commit 05e237f8d1
10 changed files with 47 additions and 26 deletions

View File

@@ -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;