summaryrefslogtreecommitdiff
path: root/src/vehicle.cpp
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/vehicle.cpp
parentc1fddb9a6ae5c3af6865461a7295788a341011a2 (diff)
downloadopenttd-9b800a96ed32720ff60b74e498a0e0a6351004f9.tar.xz
Codechange: Remove min/max functions in favour of STL variants (#8502)
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r--src/vehicle.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index e35842118..e8901e059 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -973,7 +973,7 @@ void CallVehicleTicks()
Vehicle *front = v->First();
if (v->vcache.cached_cargo_age_period != 0) {
- v->cargo_age_counter = min(v->cargo_age_counter, v->vcache.cached_cargo_age_period);
+ v->cargo_age_counter = std::min(v->cargo_age_counter, v->vcache.cached_cargo_age_period);
if (--v->cargo_age_counter == 0) {
v->cargo.AgeCargo();
v->cargo_age_counter = v->vcache.cached_cargo_age_period;
@@ -1213,7 +1213,7 @@ Vehicle *CheckClickOnVehicle(const Viewport *vp, int x, int y)
x >= v->coord.left && x <= v->coord.right &&
y >= v->coord.top && y <= v->coord.bottom) {
- dist = max(
+ dist = std::max(
abs(((v->coord.left + v->coord.right) >> 1) - x),
abs(((v->coord.top + v->coord.bottom) >> 1) - y)
);
@@ -1256,7 +1256,7 @@ void CheckVehicleBreakdown(Vehicle *v)
/* decrease reliability */
if (!_settings_game.order.no_servicing_if_no_breakdowns ||
_settings_game.difficulty.vehicle_breakdowns != 0) {
- v->reliability = rel = max((rel_old = v->reliability) - v->reliability_spd_dec, 0);
+ v->reliability = rel = std::max((rel_old = v->reliability) - v->reliability_spd_dec, 0);
if ((rel_old >> 8) != (rel >> 8)) SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
}
@@ -1271,7 +1271,7 @@ void CheckVehicleBreakdown(Vehicle *v)
/* increase chance of failure */
int chance = v->breakdown_chance + 1;
if (Chance16I(1, 25, r)) chance += 25;
- v->breakdown_chance = min(255, chance);
+ v->breakdown_chance = std::min(255, chance);
/* calculate reliability value to use in comparison */
rel = v->reliability;
@@ -1281,7 +1281,7 @@ void CheckVehicleBreakdown(Vehicle *v)
if (_settings_game.difficulty.vehicle_breakdowns == 1) rel += 0x6666;
/* check if to break down */
- if (_breakdown_chance[(uint)min(rel, 0xffff) >> 10] <= v->breakdown_chance) {
+ if (_breakdown_chance[(uint)std::min(rel, 0xffff) >> 10] <= v->breakdown_chance) {
v->breakdown_ctr = GB(r, 16, 6) + 0x3F;
v->breakdown_delay = GB(r, 24, 7) + 0x80;
v->breakdown_chance = 0;
@@ -1623,10 +1623,10 @@ void Vehicle::UpdateViewport(bool dirty)
this->MarkAllViewportsDirty();
} else {
::MarkAllViewportsDirty(
- min(old_coord.left, this->coord.left),
- min(old_coord.top, this->coord.top),
- max(old_coord.right, this->coord.right),
- max(old_coord.bottom, this->coord.bottom));
+ std::min(old_coord.left, this->coord.left),
+ std::min(old_coord.top, this->coord.top),
+ std::max(old_coord.right, this->coord.right),
+ std::max(old_coord.bottom, this->coord.bottom));
}
}
}
@@ -1724,7 +1724,7 @@ FreeUnitIDGenerator::FreeUnitIDGenerator(VehicleType type, CompanyID owner) : ca
/* Find maximum */
for (const Vehicle *v : Vehicle::Iterate()) {
if (v->type == type && v->owner == owner) {
- this->maxid = max<UnitID>(this->maxid, v->unitnumber);
+ this->maxid = std::max<UnitID>(this->maxid, v->unitnumber);
}
}
@@ -2279,7 +2279,7 @@ void Vehicle::HandleLoading(bool mode)
{
switch (this->current_order.GetType()) {
case OT_LOADING: {
- uint wait_time = max(this->current_order.GetTimetabledWait() - this->lateness_counter, 0);
+ uint wait_time = std::max(this->current_order.GetTimetabledWait() - this->lateness_counter, 0);
/* Not the first call for this tick, or still loading */
if (mode || !HasBit(this->vehicle_flags, VF_LOADING_FINISHED) || this->current_order_time < wait_time) return;