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

@@ -236,7 +236,7 @@ struct AIListWindow : public Window {
this->vscroll->SetCount((int)this->info_list->size() + 1);
/* selected goes from -1 .. length of ai list - 1. */
this->selected = min(this->selected, this->vscroll->GetCount() - 2);
this->selected = std::min(this->selected, this->vscroll->GetCount() - 2);
}
};
@@ -349,7 +349,7 @@ struct AISettingsWindow : public Window {
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
if (widget == WID_AIS_BACKGROUND) {
this->line_height = max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL) + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
this->line_height = std::max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL) + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
resize->width = 1;
resize->height = this->line_height;
@@ -879,9 +879,9 @@ struct AIConfigWindow : public Window {
case WID_AIC_INCREASE: {
int new_value;
if (widget == WID_AIC_DECREASE) {
new_value = max(0, GetGameSettings().difficulty.max_no_competitors - 1);
new_value = std::max(0, GetGameSettings().difficulty.max_no_competitors - 1);
} else {
new_value = min(MAX_COMPANIES - 1, GetGameSettings().difficulty.max_no_competitors + 1);
new_value = std::min(MAX_COMPANIES - 1, GetGameSettings().difficulty.max_no_competitors + 1);
}
IConsoleSetSetting("difficulty.max_no_competitors", new_value);
break;
@@ -1176,7 +1176,7 @@ struct AIDebugWindow : public Window {
this->autoscroll = this->vscroll->GetPosition() >= log->used - this->vscroll->GetCapacity();
}
if (this->autoscroll) {
int scroll_pos = max(0, log->used - this->vscroll->GetCapacity());
int scroll_pos = std::max(0, log->used - this->vscroll->GetCapacity());
if (scroll_pos != this->vscroll->GetPosition()) {
this->vscroll->SetPosition(scroll_pos);