diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index 9d41b4a3a9..d72b4aae18 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -268,14 +268,19 @@ void SubtractMoneyFromCompanyFract(CompanyID company, const CommandCost &cst) if (cost != 0) SubtractMoneyFromAnyCompany(c, CommandCost(cst.GetExpensesType(), cost)); } +static constexpr void UpdateLandscapingLimit(uint32_t &limit, uint64_t per_64k_frames, uint64_t burst) +{ + limit = static_cast(std::min(limit + per_64k_frames, burst << 16)); +} + /** Update the landscaping limits per company. */ void UpdateLandscapingLimits() { for (Company *c : Company::Iterate()) { - 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); - c->build_object_limit = std::min((uint64)c->build_object_limit + _settings_game.construction.build_object_per_64k_frames, (uint64)_settings_game.construction.build_object_frame_burst << 16); + UpdateLandscapingLimit(c->terraform_limit, _settings_game.construction.terraform_per_64k_frames, _settings_game.construction.terraform_frame_burst); + UpdateLandscapingLimit(c->clear_limit, _settings_game.construction.clear_per_64k_frames, _settings_game.construction.clear_frame_burst); + UpdateLandscapingLimit(c->tree_limit, _settings_game.construction.tree_per_64k_frames, _settings_game.construction.tree_frame_burst); + UpdateLandscapingLimit(c->build_object_limit, _settings_game.construction.build_object_per_64k_frames, _settings_game.construction.build_object_frame_burst); } } diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 429a25e49e..704c41ec91 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -606,13 +606,13 @@ public: case WID_GL_LIST_GROUP: { int y1 = r.top; - int max = std::min(this->group_sb->GetPosition() + this->group_sb->GetCapacity(), this->groups.size()); - for (int i = this->group_sb->GetPosition(); i < max; ++i) { + size_t max = std::min(this->group_sb->GetPosition() + this->group_sb->GetCapacity(), this->groups.size()); + for (size_t i = this->group_sb->GetPosition(); i < max; ++i) { const Group *g = this->groups[i]; assert(g->owner == this->owner); - DrawGroupInfo(y1, r.left, r.right, g->index, this->indents[i] * WidgetDimensions::scaled.hsep_indent, HasBit(g->flags, GroupFlags::GF_REPLACE_PROTECTION), g->folded || (i + 1 < (int)this->groups.size() && indents[i + 1] > this->indents[i])); + DrawGroupInfo(y1, r.left, r.right, g->index, this->indents[i] * WidgetDimensions::scaled.hsep_indent, HasBit(g->flags, GroupFlags::GF_REPLACE_PROTECTION), g->folded || (i + 1 < this->groups.size() && indents[i + 1] > this->indents[i])); y1 += this->tiny_step_height; } @@ -630,8 +630,8 @@ public: if (this->vli.index != ALL_GROUP && this->grouping == GB_NONE) { /* Mark vehicles which are in sub-groups (only if we are not using shared order coalescing) */ Rect mr = r.WithHeight(this->resize.step_height); - uint max = static_cast(std::min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehgroups.size())); - for (uint i = this->vscroll->GetPosition(); i < max; ++i) { + size_t max = std::min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehgroups.size()); + for (size_t i = this->vscroll->GetPosition(); i < max; ++i) { const Vehicle *v = this->vehgroups[i].GetSingleVehicle(); if (v->group_id != this->vli.index) { GfxFillRect(mr.Shrink(WidgetDimensions::scaled.bevel), _colour_gradient[COLOUR_GREY][3], FILLRECT_CHECKER); diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 959bcd84da..3308ac10b8 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -1037,10 +1037,10 @@ public: case EA_MULTIPLIER: if (decrease) { if (i->prod_level <= PRODLEVEL_MINIMUM) return; - i->prod_level = std::max(i->prod_level / 2, PRODLEVEL_MINIMUM); + i->prod_level = static_cast(std::max(i->prod_level / 2, PRODLEVEL_MINIMUM)); } else { if (i->prod_level >= PRODLEVEL_MAXIMUM) return; - i->prod_level = std::min(i->prod_level * 2, PRODLEVEL_MAXIMUM); + i->prod_level = static_cast(std::min(i->prod_level * 2, PRODLEVEL_MAXIMUM)); } break; diff --git a/src/spriteloader/grf.cpp b/src/spriteloader/grf.cpp index bb678b053d..e1e79e57bd 100644 --- a/src/spriteloader/grf.cpp +++ b/src/spriteloader/grf.cpp @@ -165,7 +165,7 @@ bool DecodeSingleSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t f if (colour_fmt & SCC_PAL) { switch (sprite_type) { case SpriteType::Normal: data->m = file.NeedsPaletteRemap() ? _palmap_w2d[*dest] : *dest; break; - case SpriteType::Font: data->m = std::min(*dest, 2u); break; + case SpriteType::Font: data->m = std::min(*dest, 2u); break; default: data->m = *dest; break; } /* Magic blue. */ @@ -202,7 +202,7 @@ bool DecodeSingleSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t f if (colour_fmt & SCC_PAL) { switch (sprite_type) { case SpriteType::Normal: sprite->data[i].m = file.NeedsPaletteRemap() ? _palmap_w2d[*pixel] : *pixel; break; - case SpriteType::Font: sprite->data[i].m = std::min(*pixel, 2u); break; + case SpriteType::Font: sprite->data[i].m = std::min(*pixel, 2u); break; default: sprite->data[i].m = *pixel; break; } /* Magic blue. */ diff --git a/src/station_gui.cpp b/src/station_gui.cpp index a73252f685..052b5f2783 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -432,7 +432,7 @@ public: case WID_STL_LIST: { bool rtl = _current_text_dir == TD_RTL; - int max = std::min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->stations.size()); + size_t max = std::min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->stations.size()); Rect tr = r.Shrink(WidgetDimensions::scaled.framerect); uint line_height = this->GetWidget(widget)->resize_y; /* Spacing between station name and first rating graph. */ @@ -440,7 +440,7 @@ public: /* Spacing between additional rating graphs. */ int rating_spacing = WidgetDimensions::scaled.hsep_normal; - for (int i = this->vscroll->GetPosition(); i < max; ++i) { // do until max number of stations of owner + for (size_t i = this->vscroll->GetPosition(); i < max; ++i) { // do until max number of stations of owner const Station *st = this->stations[i]; assert(st->xy != INVALID_TILE); diff --git a/src/tgp.cpp b/src/tgp.cpp index 931c2cc117..15a8da57ed 100644 --- a/src/tgp.cpp +++ b/src/tgp.cpp @@ -820,7 +820,7 @@ static void HeightMapSmoothCoastInDirection(int org_x, int org_y, int dir_x, int * Soften the coast slope */ for (depth = 0; IsValidXY(x, y) && depth <= max_coast_Smooth_depth; depth++, x += dir_x, y += dir_y) { h = _height_map.height(x, y); - h = std::min(h, h_prev + (4 + depth)); // coast softening formula + h = static_cast(std::min(h, h_prev + (4 + depth))); // coast softening formula _height_map.height(x, y) = h; h_prev = h; }