summaryrefslogtreecommitdiff
path: root/src/newgrf_industries.cpp
diff options
context:
space:
mode:
authorCharles Pigott <charlespigott@googlemail.com>2021-01-08 10:16:18 +0000
committerGitHub <noreply@github.com>2021-01-08 11:16:18 +0100
commit9b800a96ed32720ff60b74e498a0e0a6351004f9 (patch)
tree3f287d339e15c4902ee415556475fd9b2918d33c /src/newgrf_industries.cpp
parentc1fddb9a6ae5c3af6865461a7295788a341011a2 (diff)
downloadopenttd-9b800a96ed32720ff60b74e498a0e0a6351004f9.tar.xz
Codechange: Remove min/max functions in favour of STL variants (#8502)
Diffstat (limited to 'src/newgrf_industries.cpp')
-rw-r--r--src/newgrf_industries.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp
index 2dbe907de..6579c5b09 100644
--- a/src/newgrf_industries.cpp
+++ b/src/newgrf_industries.cpp
@@ -94,7 +94,7 @@ static uint32 GetClosestIndustry(TileIndex tile, IndustryType type, const Indust
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 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
/* 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<uint>(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 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
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 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
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 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
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<uint16>(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<uint16>(this->industry->incoming_cargo_waiting[variable - 0x40], 0xFFFFu);
}
} else {
return 0;
@@ -283,11 +283,11 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
/* 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, int reason)
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 *ind, int reason)
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);
}
}