summaryrefslogtreecommitdiff
path: root/src/saveload
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/saveload
parentc1fddb9a6ae5c3af6865461a7295788a341011a2 (diff)
downloadopenttd-9b800a96ed32720ff60b74e498a0e0a6351004f9.tar.xz
Codechange: Remove min/max functions in favour of STL variants (#8502)
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/afterload.cpp8
-rw-r--r--src/saveload/company_sl.cpp2
-rw-r--r--src/saveload/misc_sl.cpp2
-rw-r--r--src/saveload/oldloader_sl.cpp4
-rw-r--r--src/saveload/saveload.cpp4
5 files changed, 10 insertions, 10 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 329152ab2..c3aef307b 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -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));
}
}
diff --git a/src/saveload/company_sl.cpp b/src/saveload/company_sl.cpp
index 6f98c7afa..fb2742a18 100644
--- a/src/saveload/company_sl.cpp
+++ b/src/saveload/company_sl.cpp
@@ -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;
diff --git a/src/saveload/misc_sl.cpp b/src/saveload/misc_sl.cpp
index f17883eb4..0d760c9d5 100644
--- a/src/saveload/misc_sl.cpp
+++ b/src/saveload/misc_sl.cpp
@@ -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);
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp
index ff4e6191e..d9926aa60 100644
--- a/src/saveload/oldloader_sl.cpp
+++ b/src/saveload/oldloader_sl.cpp
@@ -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");
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 1b79ad926..18f7a17b1 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -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);
}
/**