summaryrefslogtreecommitdiff
path: root/src/station_cmd.cpp
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2019-12-17 22:04:09 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-12-21 20:13:03 +0100
commitee7a8eebca774666cd3625431a86dd05113b5e88 (patch)
tree7a7843a2ffae14db6e15933eb1bb29923945ddb0 /src/station_cmd.cpp
parent0b489f99249a8c62ee3826e490ed17f29377581c (diff)
downloadopenttd-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.cpp8
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) {