Skip to content

Commit

Permalink
Fix: conversion to smaller type warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rubidium42 committed May 3, 2023
1 parent 0adce22 commit d5d6e1c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/group_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,13 +606,13 @@ class VehicleGroupWindow : public BaseVehicleListWindow {

case WID_GL_LIST_GROUP: {
int y1 = r.top;
int max = std::min<size_t>(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<size_t>(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;
}
Expand All @@ -630,8 +630,8 @@ class VehicleGroupWindow : public BaseVehicleListWindow {
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<uint>(std::min<size_t>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehgroups.size()));
for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
size_t max = std::min<size_t>(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);
Expand Down
2 changes: 1 addition & 1 deletion src/highscore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void SaveToHighScore()
for (i = 0; i < SP_SAVED_HIGHSCORE_END; i++) {
for (hs = _highscore_table[i]; hs != endof(_highscore_table[i]); hs++) {
/* First character is a command character, so strlen will fail on that */
byte length = std::min(sizeof(hs->company), StrEmpty(hs->company) ? 0 : strlen(&hs->company[1]) + 1);
byte length = ClampTo<byte>(std::min(sizeof(hs->company), StrEmpty(hs->company) ? 0 : strlen(&hs->company[1]) + 1));

if (fwrite(&length, sizeof(length), 1, fp) != 1 || // write away string length
fwrite(hs->company, length, 1, fp) > 1 || // Yes... could be 0 bytes too
Expand Down
4 changes: 2 additions & 2 deletions src/station_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,15 +432,15 @@ class CompanyStationsWindow : public Window

case WID_STL_LIST: {
bool rtl = _current_text_dir == TD_RTL;
int max = std::min<size_t>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->stations.size());
size_t max = std::min<size_t>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->stations.size());
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
uint line_height = this->GetWidget<NWidgetBase>(widget)->resize_y;
/* Spacing between station name and first rating graph. */
int text_spacing = WidgetDimensions::scaled.hsep_wide;
/* 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);

Expand Down

0 comments on commit d5d6e1c

Please sign in to comment.