From ddabfed1cd3efa9ee229214207a60fc7cb3e0641 Mon Sep 17 00:00:00 2001 From: glx Date: Sun, 15 Dec 2019 05:55:59 +0100 Subject: Codechange: Replace station related FOR_ALL with range-based for loops --- src/script/api/script_depotlist.cpp | 3 +-- src/script/api/script_stationlist.cpp | 3 +-- src/script/api/script_town.cpp | 3 +-- src/script/api/script_waypointlist.cpp | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) (limited to 'src/script/api') diff --git a/src/script/api/script_depotlist.cpp b/src/script/api/script_depotlist.cpp index be0071473..ab2e09cfd 100644 --- a/src/script/api/script_depotlist.cpp +++ b/src/script/api/script_depotlist.cpp @@ -26,8 +26,7 @@ ScriptDepotList::ScriptDepotList(ScriptTile::TransportType transport_type) case ScriptTile::TRANSPORT_AIR: { /* Hangars are not seen as real depots by the depot code. */ - const Station *st; - FOR_ALL_STATIONS(st) { + for (const Station *st : Station::Iterate()) { if (st->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY) { for (uint i = 0; i < st->airport.GetNumHangars(); i++) { this->AddItem(st->airport.GetHangarTile(i)); diff --git a/src/script/api/script_stationlist.cpp b/src/script/api/script_stationlist.cpp index 9c2a56da9..9b9e67e7a 100644 --- a/src/script/api/script_stationlist.cpp +++ b/src/script/api/script_stationlist.cpp @@ -18,8 +18,7 @@ ScriptStationList::ScriptStationList(ScriptStation::StationType station_type) { - Station *st; - FOR_ALL_STATIONS(st) { + for (Station *st : Station::Iterate()) { if ((st->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY) && (st->facilities & station_type) != 0) this->AddItem(st->index); } } diff --git a/src/script/api/script_town.cpp b/src/script/api/script_town.cpp index fb5589707..1cb6e32bb 100644 --- a/src/script/api/script_town.cpp +++ b/src/script/api/script_town.cpp @@ -346,8 +346,7 @@ } int num = 0; - const Station *st; - FOR_ALL_STATIONS(st) { + for (const Station *st : Station::Iterate()) { if (st->town == t && (st->facilities & FACIL_AIRPORT) && st->airport.type != AT_OILRIG) num++; } return max(0, 2 - num); diff --git a/src/script/api/script_waypointlist.cpp b/src/script/api/script_waypointlist.cpp index 12f5f6bf1..1c0a804d1 100644 --- a/src/script/api/script_waypointlist.cpp +++ b/src/script/api/script_waypointlist.cpp @@ -17,8 +17,7 @@ ScriptWaypointList::ScriptWaypointList(ScriptWaypoint::WaypointType waypoint_type) { - const Waypoint *wp; - FOR_ALL_WAYPOINTS(wp) { + for (const Waypoint *wp : Waypoint::Iterate()) { if ((wp->facilities & waypoint_type) && (wp->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY || wp->owner == OWNER_NONE)) this->AddItem(wp->index); } -- cgit v1.2.3-70-g09d2