From 40505e645aed0b19a8aa6884f75690e80ef1293a Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Mon, 1 Mar 2021 15:16:26 +0100 Subject: Fix: terraform limit acted random when maxing out per_64k_frames setting uint32 + uint32 can overflow, so cast it to uint64 first. --- src/company_cmd.cpp | 6 +++--- 1 file 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(c->terraform_limit + _settings_game.construction.terraform_per_64k_frames, (uint32)_settings_game.construction.terraform_frame_burst << 16); - c->clear_limit = std::min(c->clear_limit + _settings_game.construction.clear_per_64k_frames, (uint32)_settings_game.construction.clear_frame_burst << 16); - c->tree_limit = std::min(c->tree_limit + _settings_game.construction.tree_per_64k_frames, (uint32)_settings_game.construction.tree_frame_burst << 16); + c->terraform_limit = std::min((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)c->clear_limit + _settings_game.construction.clear_per_64k_frames, (uint64)_settings_game.construction.clear_frame_burst << 16); + c->tree_limit = std::min((uint64)c->tree_limit + _settings_game.construction.tree_per_64k_frames, (uint64)_settings_game.construction.tree_frame_burst << 16); } } -- cgit v1.2.3-70-g09d2