summaryrefslogtreecommitdiff
path: root/src/town_cmd.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/town_cmd.cpp
parentc1fddb9a6ae5c3af6865461a7295788a341011a2 (diff)
downloadopenttd-9b800a96ed32720ff60b74e498a0e0a6351004f9.tar.xz
Codechange: Remove min/max functions in favour of STL variants (#8502)
Diffstat (limited to 'src/town_cmd.cpp')
-rw-r--r--src/town_cmd.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index ea13ff061..6bd78ff0d 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -813,7 +813,7 @@ static void TownTickHandler(Town *t)
i = t->growth_rate;
} else {
/* If growth failed wait a bit before retrying */
- i = min(t->growth_rate, TOWN_GROWTH_TICKS - 1);
+ i = std::min<uint16>(t->growth_rate, TOWN_GROWTH_TICKS - 1);
}
}
t->grow_counter = i;
@@ -2136,7 +2136,7 @@ bool GenerateTowns(TownLayout layout)
uint current_number = 0;
uint difficulty = (_game_mode != GM_EDITOR) ? _settings_game.difficulty.number_towns : 0;
uint total = (difficulty == (uint)CUSTOM_TOWN_NUMBER_DIFFICULTY) ? _settings_game.game_creation.custom_town_number : ScaleByMapSize(_num_initial_towns[difficulty] + (Random() & 7));
- total = min(TownPool::MAX_SIZE, total);
+ total = std::min<uint>(TownPool::MAX_SIZE, total);
uint32 townnameparts;
TownNames town_names;
@@ -3143,7 +3143,7 @@ static CommandCost TownActionFundBuildings(Town *t, DoCommandFlag flags)
* tick-perfect and gives player some time window where he can
* spam funding with the exact same efficiency.
*/
- t->grow_counter = min(t->grow_counter, 2 * TOWN_GROWTH_TICKS - (t->growth_rate - t->grow_counter) % TOWN_GROWTH_TICKS);
+ t->grow_counter = std::min<uint16>(t->grow_counter, 2 * TOWN_GROWTH_TICKS - (t->growth_rate - t->grow_counter) % TOWN_GROWTH_TICKS);
SetWindowDirty(WC_TOWN_VIEW, t->index);
}
@@ -3321,7 +3321,7 @@ static void UpdateTownRating(Town *t)
/* Increase company ratings if they're low */
for (const Company *c : Company::Iterate()) {
if (t->ratings[c->index] < RATING_GROWTH_MAXIMUM) {
- t->ratings[c->index] = min((int)RATING_GROWTH_MAXIMUM, t->ratings[c->index] + RATING_GROWTH_UP_STEP);
+ t->ratings[c->index] = std::min((int)RATING_GROWTH_MAXIMUM, t->ratings[c->index] + RATING_GROWTH_UP_STEP);
}
}
@@ -3329,12 +3329,12 @@ static void UpdateTownRating(Town *t)
if (st->time_since_load <= 20 || st->time_since_unload <= 20) {
if (Company::IsValidID(st->owner)) {
int new_rating = t->ratings[st->owner] + RATING_STATION_UP_STEP;
- t->ratings[st->owner] = min(new_rating, INT16_MAX); // do not let it overflow
+ t->ratings[st->owner] = std::min<int>(new_rating, INT16_MAX); // do not let it overflow
}
} else {
if (Company::IsValidID(st->owner)) {
int new_rating = t->ratings[st->owner] + RATING_STATION_DOWN_STEP;
- t->ratings[st->owner] = max(new_rating, INT16_MIN);
+ t->ratings[st->owner] = std::max(new_rating, INT16_MIN);
}
}
});
@@ -3358,7 +3358,7 @@ static void UpdateTownGrowCounter(Town *t, uint16 prev_growth_rate)
{
if (t->growth_rate == TOWN_GROWTH_RATE_NONE) return;
if (prev_growth_rate == TOWN_GROWTH_RATE_NONE) {
- t->grow_counter = min(t->growth_rate, t->grow_counter);
+ t->grow_counter = std::min<uint16>(t->growth_rate, t->grow_counter);
return;
}
t->grow_counter = RoundDivSU((uint32)t->grow_counter * (t->growth_rate + 1), prev_growth_rate + 1);
@@ -3399,7 +3399,7 @@ static uint GetNormalGrowthRate(Town *t)
};
int n = CountActiveStations(t);
- uint16 m = _grow_count_values[t->fund_buildings_months != 0 ? 0 : 1][min(n, 5)];
+ uint16 m = _grow_count_values[t->fund_buildings_months != 0 ? 0 : 1][std::min(n, 5)];
uint growth_multiplier = _settings_game.economy.town_growth_rate != 0 ? _settings_game.economy.town_growth_rate - 1 : 1;