Changeset - r9669:e3f736f40341
[Not reviewed]
master
0 2 0
smatz - 16 years ago 2008-07-20 15:50:41
smatz@openttd.org
(svn r13758) -Fix (r13226): always use st->airport_tile, st->xy is different in many cases
2 files changed with 21 insertions and 22 deletions:
0 comments (0 inline, 0 general)
src/airport.h
Show inline comments
 
@@ -197,8 +197,4 @@ const AirportFTAClass *GetAirport(const 
 
 */
 
uint32 GetValidAirports();
 

	
 

	
 
/* Calculate the noise this type airport will generate */
 
uint8 GetAirportNoiseLevelForTown(const AirportFTAClass *afc, TileIndex town_tile, TileIndex tile);
 

	
 
#endif /* AIRPORT_H */
src/station_cmd.cpp
Show inline comments
 
@@ -1613,42 +1613,28 @@ static const byte * const _airport_secti
 
	_airport_sections_helistation        // Helistation
 
};
 

	
 
/** Recalculate the noise generated by the airports of each town */
 
void UpdateAirportsNoise()
 
{
 
	Town *t;
 
	const Station *st;
 

	
 
	FOR_ALL_TOWNS(t) t->noise_reached = 0;
 

	
 
	FOR_ALL_STATIONS(st) {
 
		if (IsAirport(st->xy)) {
 
			st->town->noise_reached += GetAirportNoiseLevelForTown(GetAirport(st->airport_type), st->town->xy, st->xy);
 
		}
 
	}
 
}
 

	
 
/** Get a possible noise reduction factor based on distance from town center.
 
 * The further you get, the less noise you generate.
 
 * So all those folks at city council can now happily slee...  work in their offices
 
 * @param afc AirportFTAClass pointer of the class being proposed
 
 * @param town_tile TileIndex of town's center, the one who will receive the airport's candidature
 
 * @param tile TileIndex where the new airport might be built
 
 * @param tile TileIndex of northern tile of an airport (present or to-be-built), NOT the station tile
 
 * @return the noise that will be generated, according to distance
 
 */
 
uint8 GetAirportNoiseLevelForTown(const AirportFTAClass *afc, TileIndex town_tile, TileIndex tile)
 
static uint8 GetAirportNoiseLevelForTown(const AirportFTAClass *afc, TileIndex town_tile, TileIndex tile)
 
{
 
	struct TileIndexDistance {
 
		TileIndex index;
 
		uint distance;
 
	};
 

	
 
	uint distance;
 

	
 
	/* 0 cannot be accounted, and 1 is the lowest that can be reduced from town.
 
	 * So no need to go any further*/
 
	if (afc->noise_level < 2) return afc->noise_level;
 

	
 
	uint distance;
 

	
 
	/* Find the airport-to-be's closest corner to the town */
 
	if (afc->size_x == 1 && afc->size_y == 1) {
 
		distance = DistanceManhattan(town_tile, tile);  // ont tile, one corner, it's THE corner
 
@@ -1692,6 +1678,23 @@ uint8 GetAirportNoiseLevelForTown(const 
 
	return noise_reduction >= afc->noise_level ? 1 : afc->noise_level - noise_reduction;
 
}
 

	
 

	
 
/** Recalculate the noise generated by the airports of each town */
 
void UpdateAirportsNoise()
 
{
 
	Town *t;
 
	const Station *st;
 

	
 
	FOR_ALL_TOWNS(t) t->noise_reached = 0;
 

	
 
	FOR_ALL_STATIONS(st) {
 
		if (st->airport_tile != 0) {
 
			st->town->noise_reached += GetAirportNoiseLevelForTown(GetAirport(st->airport_type), st->town->xy, st->airport_tile);
 
		}
 
	}
 
}
 

	
 

	
 
/** Place an Airport.
 
 * @param tile tile where airport will be built
 
 * @param flags operation to perform
0 comments (0 inline, 0 general)