diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -94,7 +94,7 @@ static uint32 GetClosestIndustry(TileInd for (const Industry *i : Industry::Iterate()) { if (i->type != type || i == current) continue; - best_dist = min(best_dist, DistanceManhattan(tile, i->location.tile)); + best_dist = std::min(best_dist, DistanceManhattan(tile, i->location.tile)); } return best_dist; @@ -140,13 +140,13 @@ static uint32 GetCountAndDistanceOfClose /* If the filter is 0, it could be because none was specified as well as being really a 0. * In either case, just do the regular var67 */ closest_dist = GetClosestIndustry(current->location.tile, ind_index, current); - count = min(Industry::GetIndustryTypeCount(ind_index), UINT8_MAX); // clamp to 8 bit + count = std::min(Industry::GetIndustryTypeCount(ind_index), UINT8_MAX); // clamp to 8 bit } else { /* Count only those who match the same industry type and layout filter * Unfortunately, we have to do it manually */ for (const Industry *i : Industry::Iterate()) { if (i->type == ind_index && i != current && (i->selected_layout == layout_filter || layout_filter == 0) && (!town_filter || i->town == current->town)) { - closest_dist = min(closest_dist, DistanceManhattan(current->location.tile, i->location.tile)); + closest_dist = std::min(closest_dist, DistanceManhattan(current->location.tile, i->location.tile)); count++; } } @@ -180,7 +180,7 @@ static uint32 GetCountAndDistanceOfClose case 0x88: return GetTownRadiusGroup(this->industry->town, this->tile); /* Manhattan distance of the closest town */ - case 0x89: return min(DistanceManhattan(this->industry->town->xy, this->tile), 255); + case 0x89: return std::min(DistanceManhattan(this->industry->town->xy, this->tile), 255u); /* Lowest height of the tile */ case 0x8A: return Clamp(GetTileZ(this->tile) * (this->ro.grffile->grf_version >= 8 ? 1 : TILE_HEIGHT), 0, 0xFF); @@ -189,7 +189,7 @@ static uint32 GetCountAndDistanceOfClose case 0x8B: return GetClosestWaterDistance(this->tile, (GetIndustrySpec(this->industry->type)->behaviour & INDUSTRYBEH_BUILT_ONWATER) == 0); /* Square of Euclidian distance from town */ - case 0x8D: return min(DistanceSquare(this->industry->town->xy, this->tile), 65535); + case 0x8D: return std::min(DistanceSquare(this->industry->town->xy, this->tile), 65535u); /* 32 random bits */ case 0x8F: return this->random_bits; @@ -213,9 +213,9 @@ static uint32 GetCountAndDistanceOfClose if (HasBit(callback, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HasBit(callback, CBM_IND_PRODUCTION_256_TICKS)) { if ((indspec->behaviour & INDUSTRYBEH_PROD_MULTI_HNDLING) != 0) { if (this->industry->prod_level == 0) return 0; - return min(this->industry->incoming_cargo_waiting[variable - 0x40] / this->industry->prod_level, (uint16)0xFFFF); + return std::min(this->industry->incoming_cargo_waiting[variable - 0x40] / this->industry->prod_level, 0xFFFFu); } else { - return min(this->industry->incoming_cargo_waiting[variable - 0x40], (uint16)0xFFFF); + return std::min(this->industry->incoming_cargo_waiting[variable - 0x40], 0xFFFFu); } } else { return 0; @@ -283,11 +283,11 @@ static uint32 GetCountAndDistanceOfClose /* Get town zone and Manhattan distance of closest town */ case 0x65: if (this->tile == INVALID_TILE) break; - return GetTownRadiusGroup(this->industry->town, this->tile) << 16 | min(DistanceManhattan(this->tile, this->industry->town->xy), 0xFFFF); + return GetTownRadiusGroup(this->industry->town, this->tile) << 16 | std::min(DistanceManhattan(this->tile, this->industry->town->xy), 0xFFFFu); /* Get square of Euclidian distance of closes town */ case 0x66: if (this->tile == INVALID_TILE) break; - return GetTownRadiusGroup(this->industry->town, this->tile) << 16 | min(DistanceSquare(this->tile, this->industry->town->xy), 0xFFFF); + return GetTownRadiusGroup(this->industry->town, this->tile) << 16 | std::min(DistanceSquare(this->tile, this->industry->town->xy), 0xFFFFu); /* Count of industry, distance of closest instance * 68 is the same as 67, but with a filtering on selected layout */ @@ -639,7 +639,7 @@ void IndustryProductionCallback(Industry ind->incoming_cargo_waiting[i] = Clamp(ind->incoming_cargo_waiting[i] - DerefIndProd(group->subtract_input[i], deref) * multiplier, 0, 0xFFFF); } for (uint i = 0; i < group->num_output; i++) { - ind->produced_cargo_waiting[i] = Clamp(ind->produced_cargo_waiting[i] + max(DerefIndProd(group->add_output[i], deref), 0) * multiplier, 0, 0xFFFF); + ind->produced_cargo_waiting[i] = Clamp(ind->produced_cargo_waiting[i] + std::max(DerefIndProd(group->add_output[i], deref), 0) * multiplier, 0, 0xFFFF); } } else { /* Callback receives list of cargos to apply for, which need to have their cargo slots in industry looked up */ @@ -651,7 +651,7 @@ void IndustryProductionCallback(Industry for (uint i = 0; i < group->num_output; i++) { int cargo_index = ind->GetCargoProducedIndex(group->cargo_output[i]); if (cargo_index < 0) continue; - ind->produced_cargo_waiting[cargo_index] = Clamp(ind->produced_cargo_waiting[cargo_index] + max(DerefIndProd(group->add_output[i], deref), 0) * multiplier, 0, 0xFFFF); + ind->produced_cargo_waiting[cargo_index] = Clamp(ind->produced_cargo_waiting[cargo_index] + std::max(DerefIndProd(group->add_output[i], deref), 0) * multiplier, 0, 0xFFFF); } }