Codechange: Remove min/max functions in favour of STL variants (#8502)

This commit is contained in:
Charles Pigott
2021-01-08 10:16:18 +00:00
committed by GitHub
parent c1fddb9a6a
commit 9b800a96ed
181 changed files with 900 additions and 954 deletions

View File

@@ -141,7 +141,7 @@ public:
uint Height(uint width) const override
{
return max(max(this->icon_size.height, this->lock_size.height) + 2U, (uint)FONT_HEIGHT_NORMAL);
return std::max(std::max(this->icon_size.height, this->lock_size.height) + 2U, (uint)FONT_HEIGHT_NORMAL);
}
void Draw(int left, int right, int top, int bottom, bool sel, Colours bg_colour) const override
@@ -1356,10 +1356,10 @@ public:
/* First initialise some variables... */
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
child_wid->SetupSmallestSize(w, init_array);
this->smallest_y = max(this->smallest_y, child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom);
this->smallest_y = std::max(this->smallest_y, child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom);
if (this->IsButton(child_wid->type)) {
nbuttons++;
this->smallest_x = max(this->smallest_x, child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right);
this->smallest_x = std::max(this->smallest_x, child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right);
} else if (child_wid->type == NWID_SPACER) {
this->spacers++;
}
@@ -1401,7 +1401,7 @@ public:
/* Now assign the widgets to their rightful place */
uint position = 0; // Place to put next child relative to origin of the container.
uint spacer_space = max(0, (int)given_width - (int)(button_count * this->smallest_x)); // Remaining spacing for 'spacer' widgets
uint spacer_space = std::max(0, (int)given_width - (int)(button_count * this->smallest_x)); // Remaining spacing for 'spacer' widgets
uint button_space = given_width - spacer_space; // Remaining spacing for the buttons
uint spacer_i = 0;
uint button_i = 0;
@@ -1784,7 +1784,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer {
};
/* If at least BIGGEST_ARRANGEMENT fit, just spread all the buttons nicely */
uint full_buttons = max(CeilDiv(width, this->smallest_x), SMALLEST_ARRANGEMENT);
uint full_buttons = std::max(CeilDiv(width, this->smallest_x), SMALLEST_ARRANGEMENT);
if (full_buttons > BIGGEST_ARRANGEMENT) {
button_count = arrangable_count = lengthof(arrange_all);
spacer_count = this->spacers;
@@ -2266,7 +2266,7 @@ static NWidgetBase *MakeMainToolbar(int *biggest_index)
hor->Add(new NWidgetLeaf(i == WID_TN_SAVE ? WWT_IMGBTN_2 : WWT_IMGBTN, COLOUR_GREY, i, toolbar_button_sprites[i], STR_TOOLBAR_TOOLTIP_PAUSE_GAME + i));
}
*biggest_index = max<int>(*biggest_index, WID_TN_SWITCH_BAR);
*biggest_index = std::max<int>(*biggest_index, WID_TN_SWITCH_BAR);
return hor;
}
@@ -2418,13 +2418,13 @@ struct ScenarioEditorToolbarWindow : Window {
{
switch (widget) {
case WID_TE_SPACER:
size->width = max(GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_OPENTTD).width, GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR).width) + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
size->width = std::max(GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_OPENTTD).width, GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR).width) + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
break;
case WID_TE_DATE:
SetDParam(0, ConvertYMDToDate(MAX_YEAR, 0, 1));
*size = GetStringBoundingBox(STR_WHITE_DATE_LONG);
size->height = max(size->height, GetSpriteSize(SPR_IMG_SAVE).height + WD_IMGBTN_TOP + WD_IMGBTN_BOTTOM);
size->height = std::max(size->height, GetSpriteSize(SPR_IMG_SAVE).height + WD_IMGBTN_TOP + WD_IMGBTN_BOTTOM);
break;
}
}