summaryrefslogtreecommitdiff
path: root/src/script
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/script
parentc1fddb9a6ae5c3af6865461a7295788a341011a2 (diff)
downloadopenttd-9b800a96ed32720ff60b74e498a0e0a6351004f9.tar.xz
Codechange: Remove min/max functions in favour of STL variants (#8502)
Diffstat (limited to 'src/script')
-rw-r--r--src/script/api/script_bridge.cpp2
-rw-r--r--src/script/api/script_priorityqueue.cpp1
-rw-r--r--src/script/api/script_rail.cpp13
-rw-r--r--src/script/api/script_town.cpp4
-rw-r--r--src/script/squirrel_std.cpp4
5 files changed, 17 insertions, 7 deletions
diff --git a/src/script/api/script_bridge.cpp b/src/script/api/script_bridge.cpp
index 0a7c18552..4d685ca21 100644
--- a/src/script/api/script_bridge.cpp
+++ b/src/script/api/script_bridge.cpp
@@ -160,7 +160,7 @@ static void _DoCommandReturnBuildBridge1(class ScriptInstance *instance)
{
if (!IsValidBridge(bridge_id)) return -1;
- return min(::GetBridgeSpec(bridge_id)->max_length, _settings_game.construction.max_bridge_length) + 2;
+ return std::min(::GetBridgeSpec(bridge_id)->max_length, _settings_game.construction.max_bridge_length) + 2;
}
/* static */ int32 ScriptBridge::GetMinLength(BridgeID bridge_id)
diff --git a/src/script/api/script_priorityqueue.cpp b/src/script/api/script_priorityqueue.cpp
index 313008412..fda452096 100644
--- a/src/script/api/script_priorityqueue.cpp
+++ b/src/script/api/script_priorityqueue.cpp
@@ -13,7 +13,6 @@
#include "../squirrel_helper.hpp"
#include "../script_instance.hpp"
#include "../../debug.h"
-#include <algorithm>
#include "../../safeguards.h"
diff --git a/src/script/api/script_rail.cpp b/src/script/api/script_rail.cpp
index aedb4a364..01916c8c5 100644
--- a/src/script/api/script_rail.cpp
+++ b/src/script/api/script_rail.cpp
@@ -178,7 +178,18 @@
if (station_id != ScriptStation::STATION_JOIN_ADJACENT) p1 |= (1 << 24);
const GRFFile *file;
- uint16 res = GetAiPurchaseCallbackResult(GSF_STATIONS, cargo_id, 0, source_industry, goal_industry, min(255, distance / 2), AICE_STATION_GET_STATION_ID, source_station ? 0 : 1, min(15, num_platforms) << 4 | min(15, platform_length), &file);
+ uint16 res = GetAiPurchaseCallbackResult(
+ GSF_STATIONS,
+ cargo_id,
+ 0,
+ source_industry,
+ goal_industry,
+ std::min(255, distance / 2),
+ AICE_STATION_GET_STATION_ID,
+ source_station ? 0 : 1,
+ std::min(15u, num_platforms) << 4 | std::min(15u, platform_length),
+ &file
+ );
uint32 p2 = (ScriptStation::IsValidStation(station_id) ? station_id : INVALID_STATION) << 16;
if (res != CALLBACK_FAILED) {
int index = 0;
diff --git a/src/script/api/script_town.cpp b/src/script/api/script_town.cpp
index afe561456..161cf74fd 100644
--- a/src/script/api/script_town.cpp
+++ b/src/script/api/script_town.cpp
@@ -172,7 +172,7 @@
default:
EnforcePrecondition(false, (days_between_town_growth * DAY_TICKS / TOWN_GROWTH_TICKS) <= MAX_TOWN_GROWTH_TICKS);
/* Don't use growth_rate 0 as it means GROWTH_NORMAL */
- growth_rate = max(days_between_town_growth * DAY_TICKS, 2u) - 1;
+ growth_rate = std::max(days_between_town_growth * DAY_TICKS, 2u) - 1;
break;
}
@@ -376,7 +376,7 @@
for (const Station *st : Station::Iterate()) {
if (st->town == t && (st->facilities & FACIL_AIRPORT) && st->airport.type != AT_OILRIG) num++;
}
- return max(0, 2 - num);
+ return std::max(0, 2 - num);
}
/* static */ ScriptTown::RoadLayout ScriptTown::GetRoadLayout(TownID town_id)
diff --git a/src/script/squirrel_std.cpp b/src/script/squirrel_std.cpp
index 9a01dc5d6..502721f36 100644
--- a/src/script/squirrel_std.cpp
+++ b/src/script/squirrel_std.cpp
@@ -25,7 +25,7 @@ SQInteger SquirrelStd::min(HSQUIRRELVM vm)
sq_getinteger(vm, 2, &tmp1);
sq_getinteger(vm, 3, &tmp2);
- sq_pushinteger(vm, ::min(tmp1, tmp2));
+ sq_pushinteger(vm, std::min(tmp1, tmp2));
return 1;
}
@@ -35,7 +35,7 @@ SQInteger SquirrelStd::max(HSQUIRRELVM vm)
sq_getinteger(vm, 2, &tmp1);
sq_getinteger(vm, 3, &tmp2);
- sq_pushinteger(vm, ::max(tmp1, tmp2));
+ sq_pushinteger(vm, std::max(tmp1, tmp2));
return 1;
}