diff options
author | glx <glx@openttd.org> | 2019-12-17 03:37:43 +0100 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2019-12-21 20:13:03 +0100 |
commit | d8a1be48cd60c690235de175e9a044b95f92ea28 (patch) | |
tree | 2e1481aa11661c28df49f0d62f56fbf730577152 /src/script/api/script_vehiclelist.cpp | |
parent | 9892d90b26db4dfe97ec7baeb89e43acb53a178e (diff) | |
download | openttd-d8a1be48cd60c690235de175e9a044b95f92ea28.tar.xz |
Codechange: Replace vehicle related FOR_ALL with range-based for loops
Diffstat (limited to 'src/script/api/script_vehiclelist.cpp')
-rw-r--r-- | src/script/api/script_vehiclelist.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/script/api/script_vehiclelist.cpp b/src/script/api/script_vehiclelist.cpp index 727306231..58c03ff9a 100644 --- a/src/script/api/script_vehiclelist.cpp +++ b/src/script/api/script_vehiclelist.cpp @@ -20,8 +20,7 @@ ScriptVehicleList::ScriptVehicleList() { - const Vehicle *v; - FOR_ALL_VEHICLES(v) { + for (const Vehicle *v : Vehicle::Iterate()) { if ((v->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY) && (v->IsPrimaryVehicle() || (v->type == VEH_TRAIN && ::Train::From(v)->IsFreeWagon()))) this->AddItem(v->index); } } @@ -30,8 +29,7 @@ ScriptVehicleList_Station::ScriptVehicleList_Station(StationID station_id) { if (!ScriptBaseStation::IsValidBaseStation(station_id)) return; - const Vehicle *v; - FOR_ALL_VEHICLES(v) { + for (const Vehicle *v : Vehicle::Iterate()) { if ((v->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY) && v->IsPrimaryVehicle()) { const Order *order; @@ -81,8 +79,7 @@ ScriptVehicleList_Depot::ScriptVehicleList_Depot(TileIndex tile) return; } - const Vehicle *v; - FOR_ALL_VEHICLES(v) { + for (const Vehicle *v : Vehicle::Iterate()) { if ((v->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY) && v->IsPrimaryVehicle() && v->type == type) { const Order *order; @@ -109,8 +106,7 @@ ScriptVehicleList_Group::ScriptVehicleList_Group(GroupID group_id) { if (!ScriptGroup::IsValidGroup((ScriptGroup::GroupID)group_id)) return; - const Vehicle *v; - FOR_ALL_VEHICLES(v) { + for (const Vehicle *v : Vehicle::Iterate()) { if (v->owner == ScriptObject::GetCompany() && v->IsPrimaryVehicle()) { if (v->group_id == group_id) this->AddItem(v->index); } @@ -121,8 +117,7 @@ ScriptVehicleList_DefaultGroup::ScriptVehicleList_DefaultGroup(ScriptVehicle::Ve { if (vehicle_type < ScriptVehicle::VT_RAIL || vehicle_type > ScriptVehicle::VT_AIR) return; - const Vehicle *v; - FOR_ALL_VEHICLES(v) { + for (const Vehicle *v : Vehicle::Iterate()) { if (v->owner == ScriptObject::GetCompany() && v->IsPrimaryVehicle()) { if (v->type == (::VehicleType)vehicle_type && v->group_id == ScriptGroup::GROUP_DEFAULT) this->AddItem(v->index); } |