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

@@ -370,7 +370,7 @@ struct GameOptionsWindow : Window {
/* Find the biggest description for the default size. */
for (int i = 0; i < BaseGraphics::GetNumSets(); i++) {
SetDParamStr(0, BaseGraphics::GetSet(i)->GetDescription(GetCurrentLanguageIsoCode()));
size->height = max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
size->height = std::max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
}
break;
@@ -389,7 +389,7 @@ struct GameOptionsWindow : Window {
/* Find the biggest description for the default size. */
for (int i = 0; i < BaseSounds::GetNumSets(); i++) {
SetDParamStr(0, BaseSounds::GetSet(i)->GetDescription(GetCurrentLanguageIsoCode()));
size->height = max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
size->height = std::max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
}
break;
@@ -397,7 +397,7 @@ struct GameOptionsWindow : Window {
/* Find the biggest description for the default size. */
for (int i = 0; i < BaseMusic::GetNumSets(); i++) {
SetDParamStr(0, BaseMusic::GetSet(i)->GetDescription(GetCurrentLanguageIsoCode()));
size->height = max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
size->height = std::max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
}
break;
@@ -1273,7 +1273,7 @@ uint SettingsContainer::GetMaxHelpHeight(int maxw)
{
uint biggest = 0;
for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
biggest = max(biggest, (*it)->GetMaxHelpHeight(maxw));
biggest = std::max(biggest, (*it)->GetMaxHelpHeight(maxw));
}
return biggest;
}
@@ -1852,7 +1852,7 @@ struct GameSettingsWindow : Window {
{
switch (widget) {
case WID_GS_OPTIONSPANEL:
resize->height = SETTING_HEIGHT = max(max<int>(_circle_size.height, SETTING_BUTTON_HEIGHT), FONT_HEIGHT_NORMAL) + 1;
resize->height = SETTING_HEIGHT = std::max({(int)_circle_size.height, SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL}) + 1;
resize->width = 1;
size->height = 5 * resize->height + SETTINGTREE_TOP_OFFSET + SETTINGTREE_BOTTOM_OFFSET;
@@ -1866,16 +1866,16 @@ struct GameSettingsWindow : Window {
};
for (uint i = 0; i < lengthof(setting_types); i++) {
SetDParam(0, setting_types[i]);
size->width = max(size->width, GetStringBoundingBox(STR_CONFIG_SETTING_TYPE).width);
size->width = std::max(size->width, GetStringBoundingBox(STR_CONFIG_SETTING_TYPE).width);
}
size->height = 2 * FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL +
max(size->height, GetSettingsTree().GetMaxHelpHeight(size->width));
std::max(size->height, GetSettingsTree().GetMaxHelpHeight(size->width));
break;
}
case WID_GS_RESTRICT_CATEGORY:
case WID_GS_RESTRICT_TYPE:
size->width = max(GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_CATEGORY).width, GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_TYPE).width);
size->width = std::max(GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_CATEGORY).width, GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_TYPE).width);
break;
default:
@@ -2631,7 +2631,7 @@ struct CustomCurrencyWindow : Window {
case WID_CC_YEAR: { // Year to switch to euro
int val = atoi(str);
_custom_currency.to_euro = (val < 2000 ? CF_NOEURO : min(val, MAX_YEAR));
_custom_currency.to_euro = (val < 2000 ? CF_NOEURO : std::min(val, MAX_YEAR));
break;
}
}