From a3d56e2c6e80d51761ccb79affbfcf9177e34dce Mon Sep 17 00:00:00 2001 From: SamuXarick <43006711+SamuXarick@users.noreply.github.com> Date: Sun, 10 Dec 2023 15:42:55 +0000 Subject: [PATCH] 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. --- src/town.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/town.h b/src/town.h index dd88d03323..459d843313 100644 --- a/src/town.h +++ b/src/town.h @@ -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((this->cache.population / _settings_game.economy.town_noise_population[_settings_game.difficulty.town_council_tolerance]) + 3); } void UpdateVirtCoord();