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/ground_vehicle.cpp | |
parent | c1fddb9a6ae5c3af6865461a7295788a341011a2 (diff) | |
download | openttd-9b800a96ed32720ff60b74e498a0e0a6351004f9.tar.xz |
Codechange: Remove min/max functions in favour of STL variants (#8502)
Diffstat (limited to 'src/ground_vehicle.cpp')
-rw-r--r-- | src/ground_vehicle.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/ground_vehicle.cpp b/src/ground_vehicle.cpp index 0f1915c96..f6e44c2e2 100644 --- a/src/ground_vehicle.cpp +++ b/src/ground_vehicle.cpp @@ -38,7 +38,7 @@ void GroundVehicle<T, Type>::PowerChanged() /* Get minimum max speed for this track. */ uint16 track_speed = u->GetMaxTrackSpeed(); - if (track_speed > 0) max_track_speed = min(max_track_speed, track_speed); + if (track_speed > 0) max_track_speed = std::min(max_track_speed, track_speed); } byte air_drag; @@ -48,7 +48,7 @@ void GroundVehicle<T, Type>::PowerChanged() if (air_drag_value == 0) { uint16 max_speed = v->GetDisplayMaxSpeed(); /* Simplification of the method used in TTDPatch. It uses <= 10 to change more steadily from 128 to 196. */ - air_drag = (max_speed <= 10) ? 192 : max(2048 / max_speed, 1); + air_drag = (max_speed <= 10) ? 192 : std::max(2048 / max_speed, 1); } else { /* According to the specs, a value of 0x01 in the air drag property means "no air drag". */ air_drag = (air_drag_value == 1) ? 0 : air_drag_value; @@ -89,7 +89,7 @@ void GroundVehicle<T, Type>::CargoChanged() } /* Store consist weight in cache. */ - this->gcache.cached_weight = max<uint32>(1, weight); + this->gcache.cached_weight = std::max(1u, weight); /* Friction in bearings and other mechanical parts is 0.1% of the weight (result in N). */ this->gcache.cached_axle_resistance = 10 * weight; @@ -162,8 +162,8 @@ int GroundVehicle<T, Type>::GetAcceleration() const } } else { /* "Kickoff" acceleration. */ - force = (mode == AS_ACCEL && !maglev) ? min(max_te, power) : power; - force = max(force, (mass * 8) + resistance); + force = (mode == AS_ACCEL && !maglev) ? std::min<int>(max_te, power) : power; + force = std::max(force, (mass * 8) + resistance); } if (mode == AS_ACCEL) { @@ -176,9 +176,9 @@ int GroundVehicle<T, Type>::GetAcceleration() const * a hill will never speed up enough to (eventually) get back to the * same (maximum) speed. */ int accel = ClampToI32((force - resistance) / (mass * 4)); - return force < resistance ? min(-1, accel) : max(1, accel); + return force < resistance ? std::min(-1, accel) : std::max(1, accel); } else { - return ClampToI32(min(-force - resistance, -10000) / mass); + return ClampToI32(std::min<int64>(-force - resistance, -10000) / mass); } } |