mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-17 11:39:11 +00:00
Codechange: Remove min/max functions in favour of STL variants (#8502)
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user