Codechange: Remove min/max functions in favour of STL variants (#8502)

This commit is contained in:
Charles Pigott
2021-01-08 10:16:18 +00:00
committed by GitHub
parent c1fddb9a6a
commit 9b800a96ed
181 changed files with 900 additions and 954 deletions

View File

@@ -119,13 +119,13 @@ uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, i
SB(retval, 0, 4, y & 0xF);
SB(retval, 4, 4, x & 0xF);
} else {
SB(retval, 0, 4, min(15, y));
SB(retval, 4, 4, min(15, length - y - 1));
SB(retval, 8, 4, min(15, x));
SB(retval, 12, 4, min(15, platforms - x - 1));
SB(retval, 0, 4, std::min(15, y));
SB(retval, 4, 4, std::min(15, length - y - 1));
SB(retval, 8, 4, std::min(15, x));
SB(retval, 12, 4, std::min(15, platforms - x - 1));
}
SB(retval, 16, 4, min(15, length));
SB(retval, 20, 4, min(15, platforms));
SB(retval, 16, 4, std::min(15, length));
SB(retval, 20, 4, std::min(15, platforms));
SB(retval, 24, 4, tile);
return retval;
@@ -424,7 +424,7 @@ uint32 Station::GetNewGRFVariable(const ResolverObject &object, byte variable, b
const GoodsEntry *ge = &this->goods[c];
switch (variable) {
case 0x60: return min(ge->cargo.TotalCount(), 4095);
case 0x60: return std::min(ge->cargo.TotalCount(), 4095u);
case 0x61: return ge->HasVehicleEverTriedLoading() ? ge->time_since_pickup : 0;
case 0x62: return ge->HasRating() ? ge->rating : 0xFFFFFFFF;
case 0x63: return ge->cargo.DaysInTransit();
@@ -444,7 +444,7 @@ uint32 Station::GetNewGRFVariable(const ResolverObject &object, byte variable, b
const GoodsEntry *g = &this->goods[GB(variable - 0x8C, 3, 4)];
switch (GB(variable - 0x8C, 0, 3)) {
case 0: return g->cargo.TotalCount();
case 1: return GB(min(g->cargo.TotalCount(), 4095), 0, 4) | (GB(g->status, GoodsEntry::GES_ACCEPTANCE, 1) << 7);
case 1: return GB(std::min(g->cargo.TotalCount(), 4095u), 0, 4) | (GB(g->status, GoodsEntry::GES_ACCEPTANCE, 1) << 7);
case 2: return g->time_since_pickup;
case 3: return g->rating;
case 4: return g->cargo.Source();
@@ -520,7 +520,7 @@ uint32 Waypoint::GetNewGRFVariable(const ResolverObject &object, byte variable,
}
if (HasBit(this->station_scope.statspec->flags, SSF_DIV_BY_STATION_SIZE)) cargo /= (st->train_station.w + st->train_station.h);
cargo = min(0xfff, cargo);
cargo = std::min(0xfffu, cargo);
if (cargo > this->station_scope.statspec->cargo_threshold) {
if (group->num_loading > 0) {