diff options
author | glx <glx@openttd.org> | 2019-12-17 22:04:09 +0100 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2019-12-21 20:13:03 +0100 |
commit | ee7a8eebca774666cd3625431a86dd05113b5e88 (patch) | |
tree | 7a7843a2ffae14db6e15933eb1bb29923945ddb0 /src/station_cmd.cpp | |
parent | 0b489f99249a8c62ee3826e490ed17f29377581c (diff) | |
download | openttd-ee7a8eebca774666cd3625431a86dd05113b5e88.tar.xz |
Codechange: Replace FOR_ALL_TOWNS with range-based for loops
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r-- | src/station_cmd.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 86b3aedae..deed5161b 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2185,10 +2185,10 @@ uint8 GetAirportNoiseLevelForDistance(const AirportSpec *as, uint distance) */ Town *AirportGetNearestTown(const AirportSpec *as, const TileIterator &it, uint &mindist) { - Town *t, *nearest = nullptr; + Town *nearest = nullptr; uint add = as->size_x + as->size_y - 2; // GetMinimalAirportDistanceToTile can differ from DistanceManhattan by this much mindist = UINT_MAX - add; // prevent overflow - FOR_ALL_TOWNS(t) { + for (Town *t : Town::Iterate()) { if (DistanceManhattan(t->xy, it) < mindist + add) { // avoid calling GetMinimalAirportDistanceToTile too often TileIterator *copy = it.Clone(); uint dist = GetMinimalAirportDistanceToTile(*copy, t->xy); @@ -2207,9 +2207,7 @@ Town *AirportGetNearestTown(const AirportSpec *as, const TileIterator &it, uint /** Recalculate the noise generated by the airports of each town */ void UpdateAirportsNoise() { - Town *t; - - FOR_ALL_TOWNS(t) t->noise_reached = 0; + for (Town *t : Town::Iterate()) t->noise_reached = 0; for (const Station *st : Station::Iterate()) { if (st->airport.tile != INVALID_TILE && st->airport.type != AT_OILRIG) { |