summaryrefslogtreecommitdiff
path: root/src/script/api
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2019-12-17 03:37:43 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-12-21 20:13:03 +0100
commitd8a1be48cd60c690235de175e9a044b95f92ea28 (patch)
tree2e1481aa11661c28df49f0d62f56fbf730577152 /src/script/api
parent9892d90b26db4dfe97ec7baeb89e43acb53a178e (diff)
downloadopenttd-d8a1be48cd60c690235de175e9a044b95f92ea28.tar.xz
Codechange: Replace vehicle related FOR_ALL with range-based for loops
Diffstat (limited to 'src/script/api')
-rw-r--r--src/script/api/script_group.cpp6
-rw-r--r--src/script/api/script_vehiclelist.cpp15
2 files changed, 7 insertions, 14 deletions
diff --git a/src/script/api/script_group.cpp b/src/script/api/script_group.cpp
index 67aa1ac35..7f8081586 100644
--- a/src/script/api/script_group.cpp
+++ b/src/script/api/script_group.cpp
@@ -154,8 +154,7 @@
Money profit = 0;
- const Vehicle *v;
- FOR_ALL_VEHICLES(v) {
+ for (const Vehicle *v : Vehicle::Iterate()) {
if (v->group_id != group_id) continue;
if (!v->IsPrimaryVehicle()) continue;
@@ -179,8 +178,7 @@
uint32 occupancy = 0;
uint32 vehicle_count = 0;
- const Vehicle *v;
- FOR_ALL_VEHICLES(v) {
+ for (const Vehicle *v : Vehicle::Iterate()) {
if (v->group_id != group_id) continue;
if (!v->IsPrimaryVehicle()) continue;
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);
}