Codechange: Remove min/max functions in favour of STL variants (#8502)

This commit is contained in:
Charles Pigott
2021-01-08 10:16:18 +00:00
committed by GitHub
parent c1fddb9a6a
commit 9b800a96ed
181 changed files with 900 additions and 954 deletions

View File

@@ -599,8 +599,8 @@ bool AfterLoadGame()
int dx = TileX(t) - TileX(st->train_station.tile);
int dy = TileY(t) - TileY(st->train_station.tile);
assert(dx >= 0 && dy >= 0);
st->train_station.w = max<uint>(st->train_station.w, dx + 1);
st->train_station.h = max<uint>(st->train_station.h, dy + 1);
st->train_station.w = std::max<uint>(st->train_station.w, dx + 1);
st->train_station.h = std::max<uint>(st->train_station.h, dy + 1);
}
}
@@ -2457,7 +2457,7 @@ bool AfterLoadGame()
uint per_proc = _me[t].m7;
_me[t].m7 = GB(_me[t].m6, 2, 6) | (GB(_m[t].m3, 5, 1) << 6);
SB(_m[t].m3, 5, 1, 0);
SB(_me[t].m6, 2, 6, min(per_proc, 63));
SB(_me[t].m6, 2, 6, std::min(per_proc, 63U));
}
break;
@@ -2713,7 +2713,7 @@ bool AfterLoadGame()
_settings_game.pf.reverse_at_signals = IsSavegameVersionBefore(SLV_100) || (_settings_game.pf.wait_oneway_signal != 255 && _settings_game.pf.wait_twoway_signal != 255 && _settings_game.pf.wait_for_pbs_path != 255);
for (Train *t : Train::Iterate()) {
_settings_game.vehicle.max_train_length = max<uint8>(_settings_game.vehicle.max_train_length, CeilDiv(t->gcache.cached_total_length, TILE_SIZE));
_settings_game.vehicle.max_train_length = std::max<uint8>(_settings_game.vehicle.max_train_length, CeilDiv(t->gcache.cached_total_length, TILE_SIZE));
}
}

View File

@@ -61,7 +61,7 @@ CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32 face)
uint lips = GB(face, 10, 4);
if (!HasBit(ge, GENDER_FEMALE) && lips < 4) {
SetCompanyManagerFaceBits(cmf, CMFV_HAS_MOUSTACHE, ge, true);
SetCompanyManagerFaceBits(cmf, CMFV_MOUSTACHE, ge, max(lips, 1U) - 1);
SetCompanyManagerFaceBits(cmf, CMFV_MOUSTACHE, ge, std::max(lips, 1U) - 1);
} else {
if (!HasBit(ge, GENDER_FEMALE)) {
lips = lips * 15 / 16;

View File

@@ -51,7 +51,7 @@ void ResetViewportAfterLoadGame()
w->viewport->dest_scrollpos_y = _saved_scrollpos_y;
Viewport *vp = w->viewport;
vp->zoom = (ZoomLevel)min(_saved_scrollpos_zoom, ZOOM_LVL_MAX);
vp->zoom = std::min(_saved_scrollpos_zoom, ZOOM_LVL_MAX);
vp->virtual_width = ScaleByZoom(vp->width, vp->zoom);
vp->virtual_height = ScaleByZoom(vp->height, vp->zoom);

View File

@@ -392,7 +392,7 @@ static bool FixTTOEngines()
for (uint i = 0; i < lengthof(_orig_ship_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_SHIP, i);
for (uint i = 0; i < lengthof(_orig_aircraft_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_AIRCRAFT, i);
Date aging_date = min(_date + DAYS_TILL_ORIGINAL_BASE_YEAR, ConvertYMDToDate(2050, 0, 1));
Date aging_date = std::min(_date + DAYS_TILL_ORIGINAL_BASE_YEAR, ConvertYMDToDate(2050, 0, 1));
for (EngineID i = 0; i < 256; i++) {
int oi = ttd_to_tto[i];
@@ -1823,7 +1823,7 @@ bool LoadTTOMain(LoadgameState *ls)
* "increase them to compensate for the faster time advance in TTD compared to TTO
* which otherwise would cause much less income while the annual running costs of
* the vehicles stay the same" */
_economy.inflation_payment = min(_economy.inflation_payment * 124 / 74, MAX_INFLATION);
_economy.inflation_payment = std::min(_economy.inflation_payment * 124 / 74, MAX_INFLATION);
DEBUG(oldloader, 3, "Finished converting game data");
DEBUG(oldloader, 1, "TTO savegame successfully converted");

View File

@@ -170,7 +170,7 @@ struct MemoryDumper {
size_t t = this->GetSize();
while (t > 0) {
size_t to_write = min(MEMORY_CHUNK_SIZE, t);
size_t to_write = std::min(MEMORY_CHUNK_SIZE, t);
writer->Write(this->blocks[i++], to_write);
t -= to_write;
@@ -856,7 +856,7 @@ static void SlSaveLoadConv(void *ptr, VarType conv)
static inline size_t SlCalcNetStringLen(const char *ptr, size_t length)
{
if (ptr == nullptr) return 0;
return min(strlen(ptr), length - 1);
return std::min(strlen(ptr), length - 1);
}
/**