diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -1069,10 +1069,10 @@ CommandCost CanExpandRailStation(const B TileArea cur_ta = st->train_station; /* determine new size of train station region.. */ - int x = min(TileX(cur_ta.tile), TileX(new_ta.tile)); - int y = min(TileY(cur_ta.tile), TileY(new_ta.tile)); - new_ta.w = max(TileX(cur_ta.tile) + cur_ta.w, TileX(new_ta.tile) + new_ta.w) - x; - new_ta.h = max(TileY(cur_ta.tile) + cur_ta.h, TileY(new_ta.tile) + new_ta.h) - y; + int x = std::min(TileX(cur_ta.tile), TileX(new_ta.tile)); + int y = std::min(TileY(cur_ta.tile), TileY(new_ta.tile)); + new_ta.w = std::max(TileX(cur_ta.tile) + cur_ta.w, TileX(new_ta.tile) + new_ta.w) - x; + new_ta.h = std::max(TileY(cur_ta.tile) + cur_ta.h, TileY(new_ta.tile) + new_ta.h) - y; new_ta.tile = TileXY(x, y); /* make sure the final size is not too big. */ @@ -1325,7 +1325,7 @@ CommandCost CmdBuildRailStation(TileInde /* Perform NewStation checks */ /* Check if the station size is permitted */ - if (HasBit(statspec->disallowed_platforms, min(numtracks - 1, 7)) || HasBit(statspec->disallowed_lengths, min(plat_len - 1, 7))) { + if (HasBit(statspec->disallowed_platforms, std::min(numtracks - 1, 7)) || HasBit(statspec->disallowed_lengths, std::min(plat_len - 1, 7))) { return CMD_ERROR; } @@ -3364,7 +3364,7 @@ static VehicleEnterTileStatus VehicleEnt return VETSB_ENTERED_STATION | (VehicleEnterTileStatus)(station_id << VETS_STATION_ID_OFFSET); // enter station } else if (x < stop) { v->vehstatus |= VS_TRAIN_SLOWING; - uint16 spd = max(0, (stop - x) * 20 - 15); + uint16 spd = std::max(0, (stop - x) * 20 - 15); if (spd < v->cur_speed) v->cur_speed = spd; } } @@ -3456,7 +3456,7 @@ static void TruncateCargo(const CargoSpe if (source_station == nullptr) continue; GoodsEntry &source_ge = source_station->goods[cs->Index()]; - source_ge.max_waiting_cargo = max(source_ge.max_waiting_cargo, i->second); + source_ge.max_waiting_cargo = std::max(source_ge.max_waiting_cargo, i->second); } } @@ -3512,7 +3512,9 @@ static void UpdateStationRating(Station /* NewGRFs expect last speed to be 0xFF when no vehicle has arrived yet. */ uint last_speed = ge->HasVehicleEverTriedLoading() ? ge->last_speed : 0xFF; - uint32 var18 = min(ge->time_since_pickup, 0xFF) | (min(ge->max_waiting_cargo, 0xFFFF) << 8) | (min(last_speed, 0xFF) << 24); + uint32 var18 = std::min(ge->time_since_pickup, 0xFFu) + | (std::min(ge->max_waiting_cargo, 0xFFFFu) << 8) + | (std::min(last_speed, 0xFFu) << 24); /* Convert to the 'old' vehicle types */ uint32 var10 = (st->last_vehicle_type == VEH_INVALID) ? 0x0 : (st->last_vehicle_type + 0x10); uint16 callback = GetCargoCallback(CBID_CARGO_STATION_RATING_CALC, var10, var18, cs); @@ -3571,7 +3573,7 @@ static void UpdateStationRating(Station uint32 r = Random(); if (rating <= (int)GB(r, 0, 7)) { /* Need to have int, otherwise it will just overflow etc. */ - waiting = max((int)waiting - (int)((GB(r, 8, 2) - 1) * num_dests), 0); + waiting = std::max((int)waiting - (int)((GB(r, 8, 2) - 1) * num_dests), 0); waiting_changed = true; } } @@ -3587,7 +3589,7 @@ static void UpdateStationRating(Station uint difference = waiting - WAITING_CARGO_THRESHOLD; waiting -= (difference / WAITING_CARGO_CUT_FACTOR); - waiting = min(waiting, MAX_WAITING_CARGO); + waiting = std::min(waiting, MAX_WAITING_CARGO); waiting_changed = true; } @@ -3801,7 +3803,7 @@ void IncreaseStats(Station *st, const Ve * As usage is not such an important figure anyway we just * ignore the additional cargo then.*/ IncreaseStats(st, v->cargo_type, next_station_id, v->refit_cap, - min(v->refit_cap, v->cargo.StoredCount()), EUM_INCREASE); + std::min(v->refit_cap, v->cargo.StoredCount()), EUM_INCREASE); } } } @@ -4113,11 +4115,11 @@ void UpdateStationDockingTiles(Station * /* Expand the area by a tile on each side while * making sure that we remain inside the map. */ - int x2 = min(x + area->w + 1, MapSizeX()); - int x1 = max(x - 1, 0); - - int y2 = min(y + area->h + 1, MapSizeY()); - int y1 = max(y - 1, 0); + int x2 = std::min(x + area->w + 1, MapSizeX()); + int x1 = std::max(x - 1, 0); + + int y2 = std::min(y + area->h + 1, MapSizeY()); + int y1 = std::max(y - 1, 0); TileArea ta(TileXY(x1, y1), TileXY(x2 - 1, y2 - 1)); TILE_AREA_LOOP(tile, ta) { @@ -4586,7 +4588,7 @@ void FlowStat::ScaleToMonthly(uint runti SharesMap new_shares; uint share = 0; for (SharesMap::iterator i = this->shares.begin(); i != this->shares.end(); ++i) { - share = max(share + 1, i->first * 30 / runtime); + share = std::max(share + 1, i->first * 30 / runtime); new_shares[share] = i->second; if (this->unrestricted == i->first) this->unrestricted = share; }