diff options
author | Charles Pigott <charlespigott@googlemail.com> | 2021-01-08 10:16:18 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-08 11:16:18 +0100 |
commit | 9b800a96ed32720ff60b74e498a0e0a6351004f9 (patch) | |
tree | 3f287d339e15c4902ee415556475fd9b2918d33c /src/train_cmd.cpp | |
parent | c1fddb9a6ae5c3af6865461a7295788a341011a2 (diff) | |
download | openttd-9b800a96ed32720ff60b74e498a0e0a6351004f9.tar.xz |
Codechange: Remove min/max functions in favour of STL variants (#8502)
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r-- | src/train_cmd.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index ae9cb45de..ddd8cafc7 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -78,7 +78,7 @@ void CheckTrainsLengths() for (const Train *u = v, *w = v->Next(); w != nullptr; u = w, w = w->Next()) { if (u->track != TRACK_BIT_DEPOT) { if ((w->track != TRACK_BIT_DEPOT && - max(abs(u->x_pos - w->x_pos), abs(u->y_pos - w->y_pos)) != u->CalcNextVehicleOffset()) || + std::max(abs(u->x_pos - w->x_pos), abs(u->y_pos - w->y_pos)) != u->CalcNextVehicleOffset()) || (w->track == TRACK_BIT_DEPOT && TicksToLeaveDepot(u) <= 0)) { SetDParam(0, v->index); SetDParam(1, v->owner); @@ -181,7 +181,7 @@ void Train::ConsistChanged(ConsistChangeFlags allowed_changes) /* max speed is the minimum of the speed limits of all vehicles in the consist */ if ((rvi_u->railveh_type != RAILVEH_WAGON || _settings_game.vehicle.wagon_speed_limits) && !UsesWagonOverride(u)) { uint16 speed = GetVehicleProperty(u, PROP_TRAIN_SPEED, rvi_u->max_speed); - if (speed != 0) max_speed = min(speed, max_speed); + if (speed != 0) max_speed = std::min(speed, max_speed); } } @@ -189,7 +189,7 @@ void Train::ConsistChanged(ConsistChangeFlags allowed_changes) if (allowed_changes & CCF_CAPACITY) { /* Update vehicle capacity. */ if (u->cargo_cap > new_cap) u->cargo.Truncate(new_cap); - u->refit_cap = min(new_cap, u->refit_cap); + u->refit_cap = std::min(new_cap, u->refit_cap); u->cargo_cap = new_cap; } else { /* Verify capacity hasn't changed. */ @@ -391,26 +391,26 @@ int Train::GetCurrentMaxSpeed() const st_max_speed = this->cur_speed - (delta_v / 10); } - st_max_speed = max(st_max_speed, 25 * distance_to_go); - max_speed = min(max_speed, st_max_speed); + st_max_speed = std::max(st_max_speed, 25 * distance_to_go); + max_speed = std::min(max_speed, st_max_speed); } } } for (const Train *u = this; u != nullptr; u = u->Next()) { if (_settings_game.vehicle.train_acceleration_model == AM_REALISTIC && u->track == TRACK_BIT_DEPOT) { - max_speed = min(max_speed, 61); + max_speed = std::min(max_speed, 61); break; } /* Vehicle is on the middle part of a bridge. */ if (u->track == TRACK_BIT_WORMHOLE && !(u->vehstatus & VS_HIDDEN)) { - max_speed = min(max_speed, GetBridgeSpec(GetBridgeType(u->tile))->speed); + max_speed = std::min<int>(max_speed, GetBridgeSpec(GetBridgeType(u->tile))->speed); } } - max_speed = min(max_speed, this->current_order.GetMaxSpeed()); - return min(max_speed, this->gcache.cached_max_track_speed); + max_speed = std::min<int>(max_speed, this->current_order.GetMaxSpeed()); + return std::min<int>(max_speed, this->gcache.cached_max_track_speed); } /** Update acceleration of the train from the cached power and weight. */ @@ -567,9 +567,9 @@ void GetTrainSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, /* Calculate values relative to an imaginary center between the two sprites. */ width = ScaleGUITrad(TRAININFO_DEFAULT_VEHICLE_WIDTH) + UnScaleGUI(rect.right) - xoffs; - height = max<uint>(height, UnScaleGUI(rect.bottom - rect.top + 1)); + height = std::max<uint>(height, UnScaleGUI(rect.bottom - rect.top + 1)); xoffs = xoffs - ScaleGUITrad(TRAININFO_DEFAULT_VEHICLE_WIDTH) / 2; - yoffs = min(yoffs, UnScaleGUI(rect.top)); + yoffs = std::min(yoffs, UnScaleGUI(rect.top)); } } |