mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 23:50:25 +00:00
Fix: Prevent overflow when calculating max town noise (#11564)
Max town noise could overflow if the population was high enough. The value is now clamped.
This commit is contained in:
parent
09251d993c
commit
a3d56e2c6e
@ -119,7 +119,7 @@ struct Town : TownPool::PoolItem<&_town_pool> {
|
||||
if (this->cache.population == 0) return 0; // no population? no noise
|
||||
|
||||
/* 3 is added (the noise of the lowest airport), so the user can at least build a small airfield. */
|
||||
return (this->cache.population / _settings_game.economy.town_noise_population[_settings_game.difficulty.town_council_tolerance]) + 3;
|
||||
return ClampTo<uint16_t>((this->cache.population / _settings_game.economy.town_noise_population[_settings_game.difficulty.town_council_tolerance]) + 3);
|
||||
}
|
||||
|
||||
void UpdateVirtCoord();
|
||||
|
Loading…
Reference in New Issue
Block a user