* 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 as airport information * @param distance minimum distance between town and airport * @return the noise that will be generated, according to distance */
| 2521 | * @return the noise that will be generated, according to distance |
| 2522 | */ |
| 2523 | uint8_t GetAirportNoiseLevelForDistance(const AirportSpec *as, uint distance) |
| 2524 | { |
| 2525 | /* 0 cannot be accounted, and 1 is the lowest that can be reduced from town. |
| 2526 | * So no need to go any further*/ |
| 2527 | if (as->noise_level < 2) return as->noise_level; |
| 2528 | |
| 2529 | /* The steps for measuring noise reduction are based on the "magical" (and arbitrary) 8 base distance |
| 2530 | * adding the town_council_tolerance 4 times, as a way to graduate, depending of the tolerance. |
| 2531 | * Basically, it says that the less tolerant a town is, the bigger the distance before |
| 2532 | * an actual decrease can be granted */ |
| 2533 | uint8_t town_tolerance_distance = 8 + (_settings_game.difficulty.town_council_tolerance * 4); |
| 2534 | |
| 2535 | /* now, we want to have the distance segmented using the distance judged bareable by town |
| 2536 | * This will give us the coefficient of reduction the distance provides. */ |
| 2537 | uint noise_reduction = distance / town_tolerance_distance; |
| 2538 | |
| 2539 | /* If the noise reduction equals the airport noise itself, don't give it for free. |
| 2540 | * Otherwise, simply reduce the airport's level. */ |
| 2541 | return noise_reduction >= as->noise_level ? 1 : as->noise_level - noise_reduction; |
| 2542 | } |
| 2543 | |
| 2544 | /** |
| 2545 | * Finds the town nearest to given airport. Based on minimal manhattan distance to any airport's tile. |
no outgoing calls
no test coverage detected