Changeset - r28275:8873154cda89
[Not reviewed]
master
0 1 0
SamuXarick - 12 months ago 2023-12-10 15:42:55
43006711+SamuXarick@users.noreply.github.com
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.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/town.h
Show inline comments
 
@@ -119,7 +119,7 @@ struct Town : TownPool::PoolItem<&_town_
 
		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();
0 comments (0 inline, 0 general)