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

@@ -961,8 +961,8 @@ static CompanyID GetPreviewCompany(Engine *e)
c->old_economy[0].performance_history > best_hist) {
/* Check whether the company uses similar vehicles */
for (const Vehicle *v : Vehicle::Iterate()) {
if (v->owner != c->index || v->type != e->type || HasBit(v->subtype, GVSF_VIRTUAL)) continue;
for (const Vehicle *v : Vehicle::IterateType(e->type)) {
if (v->owner != c->index || HasBit(v->subtype, GVSF_VIRTUAL)) continue;
if (!v->GetEngine()->CanCarryCargo() || !HasBit(cargomask, v->cargo_type)) continue;
best_hist = c->old_economy[0].performance_history;