Codechange: Replace FOR_ALL_TOWNS with range-based for loops
This commit is contained in:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user