summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authorCharles Pigott <charlespigott@googlemail.com>2021-01-08 10:16:18 +0000
committerGitHub <noreply@github.com>2021-01-08 11:16:18 +0100
commit9b800a96ed32720ff60b74e498a0e0a6351004f9 (patch)
tree3f287d339e15c4902ee415556475fd9b2918d33c /src/ai
parentc1fddb9a6ae5c3af6865461a7295788a341011a2 (diff)
downloadopenttd-9b800a96ed32720ff60b74e498a0e0a6351004f9.tar.xz
Codechange: Remove min/max functions in favour of STL variants (#8502)
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/ai_config.cpp4
-rw-r--r--src/ai/ai_gui.cpp10
2 files changed, 7 insertions, 7 deletions
diff --git a/src/ai/ai_config.cpp b/src/ai/ai_config.cpp
index 2afa69d39..98618feb2 100644
--- a/src/ai/ai_config.cpp
+++ b/src/ai/ai_config.cpp
@@ -39,7 +39,7 @@ AIConfig::AIConfig(const AIConfig *config) : ScriptConfig(config)
* This is necessary because the ScriptConfig constructor will instead call
* ScriptConfig::AddRandomDeviation(). */
int start_date = config->GetSetting("start_date");
- this->SetSetting("start_date", start_date != 0 ? max(1, this->GetSetting("start_date")) : 0);
+ this->SetSetting("start_date", start_date != 0 ? std::max(1, this->GetSetting("start_date")) : 0);
}
/* static */ AIConfig *AIConfig::GetConfig(CompanyID company, ScriptSettingSource source)
@@ -134,5 +134,5 @@ void AIConfig::AddRandomDeviation()
/* start_date = 0 is a special case, where random deviation does not occur.
* If start_date was not already 0, then a minimum value of 1 must apply. */
- this->SetSetting("start_date", start_date != 0 ? max(1, this->GetSetting("start_date")) : 0);
+ this->SetSetting("start_date", start_date != 0 ? std::max(1, this->GetSetting("start_date")) : 0);
}
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index 9e16ec3ec..30edc9940 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -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);