summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-03-01 15:16:26 +0100
committerPatric Stout <github@truebrain.nl>2021-03-01 16:35:16 +0100
commit40505e645aed0b19a8aa6884f75690e80ef1293a (patch)
tree0eb1bfb35cb77f094ae13825301c117167cbd570
parent25e5a92286958fd870f5783cbb4ebad5ecde77da (diff)
downloadopenttd-40505e645aed0b19a8aa6884f75690e80ef1293a.tar.xz
Fix: terraform limit acted random when maxing out per_64k_frames setting
uint32 + uint32 can overflow, so cast it to uint64 first.
-rw-r--r--src/company_cmd.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
index f1c559926..946ff0d57 100644
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -266,9 +266,9 @@ void SubtractMoneyFromCompanyFract(CompanyID company, const CommandCost &cst)
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);
}
}