diff --git a/src/newgrf.cpp b/src/newgrf.cpp --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -10,7 +10,6 @@ #include "stdafx.h" #include -#include #include "debug.h" #include "fileio_func.h" @@ -663,7 +662,7 @@ static Engine *GetNewEngine(const GRFFil scope_grfid, // Note: this is INVALID_GRFID if dynamic_engines is disabled, so no reservation internal_id, type, - static_cast(min(internal_id, _engine_counts[type])) // substitute_id == _engine_counts[subtype] means "no substitute" + std::min(internal_id, _engine_counts[type]) // substitute_id == _engine_counts[subtype] means "no substitute" }); if (engine_pool_size != Engine::GetPoolSize()) { @@ -2460,7 +2459,7 @@ static ChangeInfoResult TownHouseChangeI } case 0x16: // Periodic refresh multiplier - housespec->processing_time = min(buf->ReadByte(), 63); + housespec->processing_time = std::min(buf->ReadByte(), 63u); break; case 0x17: // Four random colours to use @@ -2642,7 +2641,7 @@ static ChangeInfoResult GlobalVarChangeI uint price = gvid + i; if (price < PR_END) { - _cur.grffile->price_base_multipliers[price] = min(factor - 8, MAX_PRICE_MODIFIER); + _cur.grffile->price_base_multipliers[price] = std::min(factor - 8, MAX_PRICE_MODIFIER); } else { grfmsg(1, "GlobalVarChangeInfo: Price %d out of range, ignoring", price); } @@ -3029,7 +3028,7 @@ static ChangeInfoResult CargoChangeInfo( break; case 0x1D: // Vehicle capacity muliplier - cs->multiplier = max(1u, buf->ReadWord()); + cs->multiplier = std::max(1u, buf->ReadWord()); break; default: @@ -3911,11 +3910,11 @@ static ChangeInfoResult AirportChangeInf } if (as->rotation[j] == DIR_E || as->rotation[j] == DIR_W) { - as->size_x = max(as->size_x, att[k].ti.y + 1); - as->size_y = max(as->size_y, att[k].ti.x + 1); + as->size_x = std::max(as->size_x, att[k].ti.y + 1); + as->size_y = std::max(as->size_y, att[k].ti.x + 1); } else { - as->size_x = max(as->size_x, att[k].ti.x + 1); - as->size_y = max(as->size_y, att[k].ti.y + 1); + as->size_x = std::max(as->size_x, att[k].ti.x + 1); + as->size_y = std::max(as->size_y, att[k].ti.y + 1); } } tile_table[j] = CallocT(size); @@ -5197,7 +5196,7 @@ static void NewSpriteGroup(ByteReader *b case GSF_AIRPORTTILES: case GSF_OBJECTS: case GSF_INDUSTRYTILES: { - byte num_building_sprites = max((uint8)1, type); + byte num_building_sprites = std::max((uint8)1, type); assert(TileLayoutSpriteGroup::CanAllocateItem()); TileLayoutSpriteGroup *group = new TileLayoutSpriteGroup(); @@ -6072,7 +6071,7 @@ static uint16 SanitizeSpriteOffset(uint1 if (offset + num > max_sprites) { grfmsg(4, "GraphicsNew: %s sprite overflow, truncating...", name); uint orig_num = num; - num = max(max_sprites - offset, 0); + num = std::max(max_sprites - offset, 0); return orig_num - num; } @@ -6233,7 +6232,7 @@ bool GetGlobalVariable(byte param, uint3 { switch (param) { case 0x00: // current date - *value = max(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0); + *value = std::max(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0); return true; case 0x01: // current year @@ -6954,7 +6953,7 @@ static uint32 GetPatchVariable(uint8 par { switch (param) { /* start year - 1920 */ - case 0x0B: return max(_settings_game.game_creation.starting_year, ORIGINAL_BASE_YEAR) - ORIGINAL_BASE_YEAR; + case 0x0B: return std::max(_settings_game.game_creation.starting_year, ORIGINAL_BASE_YEAR) - ORIGINAL_BASE_YEAR; /* freight trains weight factor */ case 0x0E: return _settings_game.vehicle.freight_trains; @@ -6993,7 +6992,7 @@ static uint32 GetPatchVariable(uint8 par byte map_bits = 0; byte log_X = MapLogX() - 6; // subtraction is required to make the minimal size (64) zero based byte log_Y = MapLogY() - 6; - byte max_edge = max(log_X, log_Y); + byte max_edge = std::max(log_X, log_Y); if (log_X == log_Y) { // we have a squared map, since both edges are identical SetBit(map_bits, 0); @@ -7001,7 +7000,7 @@ static uint32 GetPatchVariable(uint8 par if (max_edge == log_Y) SetBit(map_bits, 1); // edge Y been the biggest, mark it } - return (map_bits << 24) | (min(log_X, log_Y) << 20) | (max_edge << 16) | + return (map_bits << 24) | (std::min(log_X, log_Y) << 20) | (max_edge << 16) | (log_X << 12) | (log_Y << 8) | (log_X + log_Y); } @@ -7825,7 +7824,7 @@ static bool ChangeGRFNumUsedParams(size_ grfmsg(2, "StaticGRFInfo: expected only 1 byte for 'INFO'->'NPAR' but got " PRINTF_SIZE ", ignoring this field", len); buf->Skip(len); } else { - _cur.grfconfig->num_valid_params = min(buf->ReadByte(), lengthof(_cur.grfconfig->param)); + _cur.grfconfig->num_valid_params = std::min(buf->ReadByte(), lengthof(_cur.grfconfig->param)); } return true; } @@ -7979,8 +7978,8 @@ static bool ChangeGRFParamMask(size_t le buf->Skip(len - 1); } else { _cur_parameter->param_nr = param_nr; - if (len >= 2) _cur_parameter->first_bit = min(buf->ReadByte(), 31); - if (len >= 3) _cur_parameter->num_bit = min(buf->ReadByte(), 32 - _cur_parameter->first_bit); + if (len >= 2) _cur_parameter->first_bit = std::min(buf->ReadByte(), 31); + if (len >= 3) _cur_parameter->num_bit = std::min(buf->ReadByte(), 32 - _cur_parameter->first_bit); } }