Reduce duplication when iterating shared orders for departure board

This commit is contained in:
Jonathan G Rennison
2024-06-27 21:19:54 +01:00
parent 93d2b6716e
commit af11b76877

View File

@@ -164,11 +164,12 @@ protected:
CompanyMask companies = 0;
int unitnumber_max[4] = { -1, -1, -1, -1 };
for (const Vehicle *v : Vehicle::IterateFrontOnly()) {
if (v->type < 4 && this->show_types[v->type] && v->IsPrimaryVehicle()) {
for(const Order *order : v->Orders()) {
for (const Vehicle *veh : Vehicle::IterateFrontOnly()) {
if (veh->type < 4 && this->show_types[veh->type] && veh->IsPrimaryVehicle() && veh == veh->FirstShared()) {
for (const Order *order : veh->Orders()) {
if ((order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT) || order->IsType(OT_IMPLICIT))
&& order->GetDestination() == this->station) {
for (const Vehicle *v = veh; v != nullptr; v = v->NextShared()) {
this->vehicles.push_back(v);
if (_settings_client.gui.departure_show_vehicle) {
@@ -188,6 +189,7 @@ protected:
if (_settings_client.gui.departure_show_company) {
SetBit(companies, v->owner);
}
}
break;
}
}