Changeset - r24975:622146494837
[Not reviewed]
master
0 1 0
Patric Stout - 4 years ago 2021-03-01 14:16:26
truebrain@openttd.org
Fix: terraform limit acted random when maxing out per_64k_frames setting

uint32 + uint32 can overflow, so cast it to uint64 first.
1 file changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/company_cmd.cpp
Show inline comments
 
@@ -266,9 +266,9 @@ void SubtractMoneyFromCompanyFract(Compa
 
void UpdateLandscapingLimits()
 
{
 
	for (Company *c : Company::Iterate()) {
 
		c->terraform_limit = std::min<uint32>(c->terraform_limit + _settings_game.construction.terraform_per_64k_frames, (uint32)_settings_game.construction.terraform_frame_burst << 16);
 
		c->clear_limit     = std::min<uint32>(c->clear_limit     + _settings_game.construction.clear_per_64k_frames,     (uint32)_settings_game.construction.clear_frame_burst << 16);
 
		c->tree_limit      = std::min<uint32>(c->tree_limit      + _settings_game.construction.tree_per_64k_frames,      (uint32)_settings_game.construction.tree_frame_burst << 16);
 
		c->terraform_limit = std::min<uint64>((uint64)c->terraform_limit + _settings_game.construction.terraform_per_64k_frames, (uint64)_settings_game.construction.terraform_frame_burst << 16);
 
		c->clear_limit     = std::min<uint64>((uint64)c->clear_limit     + _settings_game.construction.clear_per_64k_frames,     (uint64)_settings_game.construction.clear_frame_burst << 16);
 
		c->tree_limit      = std::min<uint64>((uint64)c->tree_limit      + _settings_game.construction.tree_per_64k_frames,      (uint64)_settings_game.construction.tree_frame_burst << 16);
 
	}
 
}
 

	
0 comments (0 inline, 0 general)