summaryrefslogtreecommitdiff
path: root/src/station_cmd.cpp
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/station_cmd.cpp
parent9892d90b26db4dfe97ec7baeb89e43acb53a178e (diff)
downloadopenttd-d8a1be48cd60c690235de175e9a044b95f92ea28.tar.xz
Codechange: Replace vehicle related FOR_ALL with range-based for loops
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r--src/station_cmd.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 4b2acb2db..86b3aedae 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -2033,8 +2033,7 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags)
delete cur_stop;
/* Make sure no vehicle is going to the old roadstop */
- RoadVehicle *v;
- FOR_ALL_ROADVEHICLES(v) {
+ for (RoadVehicle *v : RoadVehicle::Iterate()) {
if (v->First() == v && v->current_order.IsType(OT_GOTO_STATION) &&
v->dest_tile == tile) {
v->SetDestTile(v->GetOrderStationLocation(st->index));
@@ -2380,8 +2379,7 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
CommandCost cost(EXPENSES_CONSTRUCTION);
- const Aircraft *a;
- FOR_ALL_AIRCRAFT(a) {
+ for (const Aircraft *a : Aircraft::Iterate()) {
if (!a->IsNormalAircraft()) continue;
if (a->targetairport == st->index && a->state != FLYING) {
return_cmd_error(STR_ERROR_AIRCRAFT_IN_THE_WAY);
@@ -2480,8 +2478,7 @@ CommandCost CmdOpenCloseAirport(TileIndex tile, DoCommandFlag flags, uint32 p1,
*/
bool HasStationInUse(StationID station, bool include_company, CompanyID company)
{
- const Vehicle *v;
- FOR_ALL_VEHICLES(v) {
+ for (const Vehicle *v : Vehicle::Iterate()) {
if ((v->owner == company) == include_company) {
const Order *order;
FOR_VEHICLE_ORDERS(v, order) {
@@ -2721,8 +2718,7 @@ static CommandCost RemoveDock(TileIndex tile, DoCommandFlag flags)
* will be selected and in case of no appropriate order it will just
* wander around the world. */
if (!(st->facilities & FACIL_DOCK)) {
- Ship *s;
- FOR_ALL_SHIPS(s) {
+ for (Ship *s : Ship::Iterate()) {
if (s->current_order.IsType(OT_LOADING) && s->current_order.GetDestination() == st->index) {
s->LeaveStation();
}