summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
authorHenry Wilson <m3henry@googlemail.com>2019-04-10 22:07:06 +0100
committerMichael Lutz <michi@icosahedron.de>2019-04-10 23:22:20 +0200
commit7c8e7c6b6e16d4a26259a676db32d8776b99817e (patch)
tree99f134b7e66367cf11e10bc5061896eab4a3264f /src/saveload
parent3b4f224c0bc50e7248050d4bcbb6d83fd510c1cc (diff)
downloadopenttd-7c8e7c6b6e16d4a26259a676db32d8776b99817e.tar.xz
Codechange: Use null pointer literal instead of the NULL macro
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/afterload.cpp80
-rw-r--r--src/saveload/ai_sl.cpp10
-rw-r--r--src/saveload/airport_sl.cpp4
-rw-r--r--src/saveload/animated_tile_sl.cpp2
-rw-r--r--src/saveload/autoreplace_sl.cpp2
-rw-r--r--src/saveload/cargomonitor_sl.cpp4
-rw-r--r--src/saveload/cargopacket_sl.cpp2
-rw-r--r--src/saveload/cheat_sl.cpp2
-rw-r--r--src/saveload/company_sl.cpp32
-rw-r--r--src/saveload/depot_sl.cpp2
-rw-r--r--src/saveload/economy_sl.cpp16
-rw-r--r--src/saveload/engine_sl.cpp10
-rw-r--r--src/saveload/game_sl.cpp32
-rw-r--r--src/saveload/gamelog_sl.cpp8
-rw-r--r--src/saveload/goal_sl.cpp2
-rw-r--r--src/saveload/group_sl.cpp2
-rw-r--r--src/saveload/industry_sl.cpp10
-rw-r--r--src/saveload/labelmaps_sl.cpp2
-rw-r--r--src/saveload/linkgraph_sl.cpp8
-rw-r--r--src/saveload/map_sl.cpp22
-rw-r--r--src/saveload/misc_sl.cpp6
-rw-r--r--src/saveload/newgrf_sl.cpp6
-rw-r--r--src/saveload/object_sl.cpp4
-rw-r--r--src/saveload/oldloader.cpp20
-rw-r--r--src/saveload/oldloader.h14
-rw-r--r--src/saveload/oldloader_sl.cpp32
-rw-r--r--src/saveload/order_sl.cpp8
-rw-r--r--src/saveload/saveload.cpp122
-rw-r--r--src/saveload/saveload.h16
-rw-r--r--src/saveload/saveload_filter.h2
-rw-r--r--src/saveload/signs_sl.cpp2
-rw-r--r--src/saveload/station_sl.cpp20
-rw-r--r--src/saveload/storage_sl.cpp2
-rw-r--r--src/saveload/story_sl.cpp4
-rw-r--r--src/saveload/strings_sl.cpp8
-rw-r--r--src/saveload/subsidy_sl.cpp2
-rw-r--r--src/saveload/town_sl.cpp4
-rw-r--r--src/saveload/vehicle_sl.cpp62
-rw-r--r--src/saveload/waypoint_sl.cpp14
39 files changed, 300 insertions, 300 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index b4e3ce986..8d9b0ffa6 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -263,14 +263,14 @@ static void InitializeWindowsAndCaches()
/* Identify owners of persistent storage arrays */
Industry *i;
FOR_ALL_INDUSTRIES(i) {
- if (i->psa != NULL) {
+ if (i->psa != nullptr) {
i->psa->feature = GSF_INDUSTRIES;
i->psa->tile = i->location.tile;
}
}
Station *s;
FOR_ALL_STATIONS(s) {
- if (s->airport.psa != NULL) {
+ if (s->airport.psa != nullptr) {
s->airport.psa->feature = GSF_AIRPORTS;
s->airport.psa->tile = s->airport.tile;
}
@@ -303,9 +303,9 @@ static void InitializeWindowsAndCaches()
}
typedef void (CDECL *SignalHandlerPointer)(int);
-static SignalHandlerPointer _prev_segfault = NULL;
-static SignalHandlerPointer _prev_abort = NULL;
-static SignalHandlerPointer _prev_fpe = NULL;
+static SignalHandlerPointer _prev_segfault = nullptr;
+static SignalHandlerPointer _prev_abort = nullptr;
+static SignalHandlerPointer _prev_fpe = nullptr;
static void CDECL HandleSavegameLoadCrash(int signum);
@@ -375,7 +375,7 @@ static void CDECL HandleSavegameLoadCrash(int signum)
char *p = buffer;
p += seprintf(p, lastof(buffer), "Loading your savegame caused OpenTTD to crash.\n");
- for (const GRFConfig *c = _grfconfig; !_saveload_crash_with_missing_newgrfs && c != NULL; c = c->next) {
+ for (const GRFConfig *c = _grfconfig; !_saveload_crash_with_missing_newgrfs && c != nullptr; c = c->next) {
_saveload_crash_with_missing_newgrfs = HasBit(c->flags, GCF_COMPATIBLE) || c->status == GCS_NOT_FOUND;
}
@@ -393,7 +393,7 @@ static void CDECL HandleSavegameLoadCrash(int signum)
"Please load the savegame with the appropriate NewGRFs installed.\n"
"The missing/compatible NewGRFs are:\n");
- for (const GRFConfig *c = _grfconfig; c != NULL; c = c->next) {
+ for (const GRFConfig *c = _grfconfig; c != nullptr; c = c->next) {
if (HasBit(c->flags, GCF_COMPATIBLE)) {
const GRFIdentifier *replaced = GetOverriddenIdentifier(c);
char buf[40];
@@ -414,14 +414,14 @@ static void CDECL HandleSavegameLoadCrash(int signum)
ShowInfo(buffer);
- SignalHandlerPointer call = NULL;
+ SignalHandlerPointer call = nullptr;
switch (signum) {
case SIGSEGV: call = _prev_segfault; break;
case SIGABRT: call = _prev_abort; break;
case SIGFPE: call = _prev_fpe; break;
default: NOT_REACHED();
}
- if (call != NULL) call(signum);
+ if (call != nullptr) call(signum);
}
/**
@@ -434,7 +434,7 @@ static void FixOwnerOfRailTrack(TileIndex t)
assert(!Company::IsValidID(GetTileOwner(t)) && (IsLevelCrossingTile(t) || IsPlainRailTile(t)));
/* remove leftover rail piece from crossing (from very old savegames) */
- Train *v = NULL, *w;
+ Train *v = nullptr, *w;
FOR_ALL_TRAINS(w) {
if (w->tile == t) {
v = w;
@@ -442,7 +442,7 @@ static void FixOwnerOfRailTrack(TileIndex t)
}
}
- if (v != NULL) {
+ if (v != nullptr) {
/* when there is a train on crossing (it could happen in TTD), set owner of crossing to train owner */
SetTileOwner(t, v->owner);
return;
@@ -631,22 +631,22 @@ bool AfterLoadGame()
Company *c;
FOR_ALL_COMPANIES(c) {
c->name = CopyFromOldName(c->name_1);
- if (c->name != NULL) c->name_1 = STR_SV_UNNAMED;
+ if (c->name != nullptr) c->name_1 = STR_SV_UNNAMED;
c->president_name = CopyFromOldName(c->president_name_1);
- if (c->president_name != NULL) c->president_name_1 = SPECSTR_PRESIDENT_NAME;
+ if (c->president_name != nullptr) c->president_name_1 = SPECSTR_PRESIDENT_NAME;
}
Station *st;
FOR_ALL_STATIONS(st) {
st->name = CopyFromOldName(st->string_id);
/* generating new name would be too much work for little effect, use the station name fallback */
- if (st->name != NULL) st->string_id = STR_SV_STNAME_FALLBACK;
+ if (st->name != nullptr) st->string_id = STR_SV_STNAME_FALLBACK;
}
Town *t;
FOR_ALL_TOWNS(t) {
t->name = CopyFromOldName(t->townnametype);
- if (t->name != NULL) t->townnametype = SPECSTR_TOWNNAME_START + _settings_game.game_creation.town_name;
+ if (t->name != nullptr) t->townnametype = SPECSTR_TOWNNAME_START + _settings_game.game_creation.town_name;
}
}
@@ -676,7 +676,7 @@ bool AfterLoadGame()
/* Check if all NewGRFs are present, we are very strict in MP mode */
GRFListCompatibility gcf_res = IsGoodGRFConfigList(_grfconfig);
- for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) {
+ for (GRFConfig *c = _grfconfig; c != nullptr; c = c->next) {
if (c->status == GCS_NOT_FOUND) {
GamelogGRFRemove(c->ident.grfid);
} else if (HasBit(c->flags, GCF_COMPATIBLE)) {
@@ -787,7 +787,7 @@ bool AfterLoadGame()
{
Company *c;
FOR_ALL_COMPANIES(c) {
- if (c->is_ai && c->ai_instance == NULL) AI::StartNew(c->index);
+ if (c->is_ai && c->ai_instance == nullptr) AI::StartNew(c->index);
}
}
@@ -987,7 +987,7 @@ bool AfterLoadGame()
if (IsSavegameVersionBefore(SLV_16)) {
Company *c;
FOR_ALL_COMPANIES(c) {
- c->engine_renew_list = NULL;
+ c->engine_renew_list = nullptr;
c->settings.engine_renew = false;
c->settings.engine_renew_months = 6;
c->settings.engine_renew_money = 100000;
@@ -1000,7 +1000,7 @@ bool AfterLoadGame()
* companies are 'invalid'.
*/
c = Company::GetIfValid(COMPANY_FIRST);
- if (!_network_dedicated && c != NULL) {
+ if (!_network_dedicated && c != nullptr) {
c->settings = _settings_client.company;
}
}
@@ -1104,7 +1104,7 @@ bool AfterLoadGame()
}
if (!IsRoadDepot(t) && !HasTownOwnedRoad(t)) {
const Town *town = CalcClosestTownFromTile(t);
- if (town != NULL) SetTownIndex(t, town->index);
+ if (town != nullptr) SetTownIndex(t, town->index);
}
_m[t].m4 = 0;
break;
@@ -1711,9 +1711,9 @@ bool AfterLoadGame()
Vehicle *v;
FOR_ALL_VEHICLES(v) {
- if (v->orders.list != NULL && v->orders.list->GetFirstOrder() != NULL && v->orders.list->GetFirstOrder()->IsType(OT_NOTHING)) {
+ if (v->orders.list != nullptr && v->orders.list->GetFirstOrder() != nullptr && v->orders.list->GetFirstOrder()->IsType(OT_NOTHING)) {
v->orders.list->FreeChain();
- v->orders.list = NULL;
+ v->orders.list = nullptr;
}
v->current_order.ConvertFromOldSavegame();
@@ -2165,7 +2165,7 @@ bool AfterLoadGame()
FOR_ALL_DISASTERVEHICLES(v) {
if (v->subtype == 2 /* ST_SMALL_UFO */ && v->current_order.GetDestination() != 0) {
const Vehicle *u = Vehicle::GetIfValid(v->dest_tile);
- if (u == NULL || u->type != VEH_ROAD || !RoadVehicle::From(u)->IsFrontEngine()) {
+ if (u == nullptr || u->type != VEH_ROAD || !RoadVehicle::From(u)->IsFrontEngine()) {
delete v;
}
}
@@ -2186,7 +2186,7 @@ bool AfterLoadGame()
assert_compile(CargoPaymentPool::MAX_SIZE == VehiclePool::MAX_SIZE);
assert(CargoPayment::CanAllocateItem());
Vehicle *v = *iter;
- if (v->cargo_payment == NULL) v->cargo_payment = new CargoPayment(v);
+ if (v->cargo_payment == nullptr) v->cargo_payment = new CargoPayment(v);
}
}
}
@@ -2199,7 +2199,7 @@ bool AfterLoadGame()
for (auto tile = _animated_tiles.begin(); tile < _animated_tiles.end(); /* Nothing */) {
/* Remove if tile is not animated */
- bool remove = _tile_type_procs[GetTileType(*tile)]->animate_tile_proc == NULL;
+ bool remove = _tile_type_procs[GetTileType(*tile)]->animate_tile_proc == nullptr;
/* and remove if duplicate */
for (auto j = _animated_tiles.begin(); !remove && j < tile; j++) {
@@ -2271,7 +2271,7 @@ bool AfterLoadGame()
/* Town -> Town */
const Station *ss = Station::GetIfValid(s->src);
const Station *sd = Station::GetIfValid(s->dst);
- if (ss != NULL && sd != NULL && ss->owner == sd->owner &&
+ if (ss != nullptr && sd != nullptr && ss->owner == sd->owner &&
Company::IsValidID(ss->owner)) {
s->src_type = s->dst_type = ST_TOWN;
s->src = ss->town->index;
@@ -2438,13 +2438,13 @@ bool AfterLoadGame()
FOR_ALL_AIRCRAFT(v) {
if (!v->IsNormalAircraft()) continue;
Station *st = GetTargetAirportIfValid(v);
- if (st == NULL && v->state != FLYING) {
+ if (st == nullptr && v->state != FLYING) {
v->state = FLYING;
UpdateAircraftCache(v);
AircraftNextAirportPos_and_Order(v);
/* get aircraft back on running altitude */
if ((v->vehstatus & VS_CRASHED) == 0) {
- GetAircraftFlightLevelBounds(v, &v->z_pos, NULL);
+ GetAircraftFlightLevelBounds(v, &v->z_pos, nullptr);
SetAircraftPosition(v, v->x_pos, v->y_pos, GetAircraftFlightLevel(v));
}
}
@@ -2506,11 +2506,11 @@ bool AfterLoadGame()
* order they have in the pool. */
Waypoint *wp;
FOR_ALL_WAYPOINTS(wp) {
- if (wp->name != NULL) wp->town_cn = UINT16_MAX;
+ if (wp->name != nullptr) wp->town_cn = UINT16_MAX;
}
FOR_ALL_WAYPOINTS(wp) {
- if (wp->name != NULL) MakeDefaultName(wp);
+ if (wp->name != nullptr) MakeDefaultName(wp);
}
}
@@ -2742,7 +2742,7 @@ bool AfterLoadGame()
if (!IsSavegameVersionBefore(SLV_76)) {
Industry *ind;
FOR_ALL_INDUSTRIES(ind) {
- assert(ind->psa != NULL);
+ assert(ind->psa != nullptr);
/* Check if the old storage was empty. */
bool is_empty = true;
@@ -2757,7 +2757,7 @@ bool AfterLoadGame()
ind->psa->grfid = _industry_mngr.GetGRFID(ind->type);
} else {
delete ind->psa;
- ind->psa = NULL;
+ ind->psa = nullptr;
}
}
}
@@ -2766,7 +2766,7 @@ bool AfterLoadGame()
Station *st;
FOR_ALL_STATIONS(st) {
if (!(st->facilities & FACIL_AIRPORT)) continue;
- assert(st->airport.psa != NULL);
+ assert(st->airport.psa != nullptr);
/* Check if the old storage was empty. */
bool is_empty = true;
@@ -2781,7 +2781,7 @@ bool AfterLoadGame()
st->airport.psa->grfid = _airport_mngr.GetGRFID(st->airport.type);
} else {
delete st->airport.psa;
- st->airport.psa = NULL;
+ st->airport.psa = nullptr;
}
}
@@ -2821,12 +2821,12 @@ bool AfterLoadGame()
/* Set the default cargo requirement for town growth */
switch (_settings_game.game_creation.landscape) {
case LT_ARCTIC:
- if (FindFirstCargoWithTownEffect(TE_FOOD) != NULL) t->goal[TE_FOOD] = TOWN_GROWTH_WINTER;
+ if (FindFirstCargoWithTownEffect(TE_FOOD) != nullptr) t->goal[TE_FOOD] = TOWN_GROWTH_WINTER;
break;
case LT_TROPIC:
- if (FindFirstCargoWithTownEffect(TE_FOOD) != NULL) t->goal[TE_FOOD] = TOWN_GROWTH_DESERT;
- if (FindFirstCargoWithTownEffect(TE_WATER) != NULL) t->goal[TE_WATER] = TOWN_GROWTH_DESERT;
+ if (FindFirstCargoWithTownEffect(TE_FOOD) != nullptr) t->goal[TE_FOOD] = TOWN_GROWTH_DESERT;
+ if (FindFirstCargoWithTownEffect(TE_WATER) != nullptr) t->goal[TE_WATER] = TOWN_GROWTH_DESERT;
break;
}
}
@@ -2946,7 +2946,7 @@ bool AfterLoadGame()
TileIndex prev_tile = v->tile;
uint prev_tile_skip = 0;
uint cur_skip = 0;
- for (RoadVehicle *u = v; u != NULL; u = u->Next()) {
+ for (RoadVehicle *u = v; u != nullptr; u = u->Next()) {
if (u->tile != prev_tile) {
prev_tile_skip = cur_skip;
prev_tile = u->tile;
@@ -2980,7 +2980,7 @@ bool AfterLoadGame()
}
while (cur_skip > skip_frames[0]) {
RoadVehicle *u = v;
- RoadVehicle *prev = NULL;
+ RoadVehicle *prev = nullptr;
for (uint sf : skip_frames) {
extern bool IndividualRoadVehicleController(RoadVehicle *v, const RoadVehicle *prev);
if (sf >= cur_skip) IndividualRoadVehicleController(u, prev);
@@ -3111,7 +3111,7 @@ bool AfterLoadGame()
} else {
/* Link neutral station back to industry, as this is not saved. */
Industry *ind;
- FOR_ALL_INDUSTRIES(ind) if (ind->neutral_station != NULL) ind->neutral_station->industry = ind;
+ FOR_ALL_INDUSTRIES(ind) if (ind->neutral_station != nullptr) ind->neutral_station->industry = ind;
}
if (IsSavegameVersionBefore(SLV_TREES_WATER_CLASS)) {
diff --git a/src/saveload/ai_sl.cpp b/src/saveload/ai_sl.cpp
index 2492bb666..336c773d5 100644
--- a/src/saveload/ai_sl.cpp
+++ b/src/saveload/ai_sl.cpp
@@ -53,7 +53,7 @@ static void SaveReal_AIPL(int *index_ptr)
_ai_saveload_settings[0] = '\0';
config->SettingsToString(_ai_saveload_settings, lastof(_ai_saveload_settings));
- SlObject(NULL, _ai_company);
+ SlObject(nullptr, _ai_company);
/* If the AI was active, store his data too */
if (Company::IsValidAiID(index)) AI::Save(index);
}
@@ -62,7 +62,7 @@ static void Load_AIPL()
{
/* Free all current data */
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
- AIConfig::GetConfig(c, AIConfig::SSS_FORCE_GAME)->Change(NULL);
+ AIConfig::GetConfig(c, AIConfig::SSS_FORCE_GAME)->Change(nullptr);
}
CompanyID index;
@@ -71,7 +71,7 @@ static void Load_AIPL()
_ai_saveload_is_random = 0;
_ai_saveload_version = -1;
- SlObject(NULL, _ai_company);
+ SlObject(nullptr, _ai_company);
if (_networking && !_network_server) {
if (Company::IsValidAiID(index)) AIInstance::LoadEmpty();
@@ -81,7 +81,7 @@ static void Load_AIPL()
AIConfig *config = AIConfig::GetConfig(index, AIConfig::SSS_FORCE_GAME);
if (StrEmpty(_ai_saveload_name)) {
/* A random AI. */
- config->Change(NULL, -1, false, true);
+ config->Change(nullptr, -1, false, true);
} else {
config->Change(_ai_saveload_name, _ai_saveload_version, false, _ai_saveload_is_random);
if (!config->HasScript()) {
@@ -125,5 +125,5 @@ static void Save_AIPL()
}
extern const ChunkHandler _ai_chunk_handlers[] = {
- { 'AIPL', Save_AIPL, Load_AIPL, NULL, NULL, CH_ARRAY | CH_LAST},
+ { 'AIPL', Save_AIPL, Load_AIPL, nullptr, nullptr, CH_ARRAY | CH_LAST},
};
diff --git a/src/saveload/airport_sl.cpp b/src/saveload/airport_sl.cpp
index 1172d2593..ef207bacb 100644
--- a/src/saveload/airport_sl.cpp
+++ b/src/saveload/airport_sl.cpp
@@ -37,6 +37,6 @@ static void Load_ATID()
}
extern const ChunkHandler _airport_chunk_handlers[] = {
- { 'ATID', Save_ATID, Load_ATID, NULL, NULL, CH_ARRAY },
- { 'APID', Save_APID, Load_APID, NULL, NULL, CH_ARRAY | CH_LAST },
+ { 'ATID', Save_ATID, Load_ATID, nullptr, nullptr, CH_ARRAY },
+ { 'APID', Save_APID, Load_APID, nullptr, nullptr, CH_ARRAY | CH_LAST },
};
diff --git a/src/saveload/animated_tile_sl.cpp b/src/saveload/animated_tile_sl.cpp
index f82950c50..aab06f667 100644
--- a/src/saveload/animated_tile_sl.cpp
+++ b/src/saveload/animated_tile_sl.cpp
@@ -58,5 +58,5 @@ static void Load_ANIT()
* the animated tile table.
*/
extern const ChunkHandler _animated_tile_chunk_handlers[] = {
- { 'ANIT', Save_ANIT, Load_ANIT, NULL, NULL, CH_RIFF | CH_LAST},
+ { 'ANIT', Save_ANIT, Load_ANIT, nullptr, nullptr, CH_RIFF | CH_LAST},
};
diff --git a/src/saveload/autoreplace_sl.cpp b/src/saveload/autoreplace_sl.cpp
index 1798df1ad..6493b6f45 100644
--- a/src/saveload/autoreplace_sl.cpp
+++ b/src/saveload/autoreplace_sl.cpp
@@ -63,5 +63,5 @@ static void Ptrs_ERNW()
}
extern const ChunkHandler _autoreplace_chunk_handlers[] = {
- { 'ERNW', Save_ERNW, Load_ERNW, Ptrs_ERNW, NULL, CH_ARRAY | CH_LAST},
+ { 'ERNW', Save_ERNW, Load_ERNW, Ptrs_ERNW, nullptr, CH_ARRAY | CH_LAST},
};
diff --git a/src/saveload/cargomonitor_sl.cpp b/src/saveload/cargomonitor_sl.cpp
index 9a313970f..97acc435e 100644
--- a/src/saveload/cargomonitor_sl.cpp
+++ b/src/saveload/cargomonitor_sl.cpp
@@ -121,6 +121,6 @@ static void LoadPickup()
/** Chunk definition of the cargomonitoring maps. */
extern const ChunkHandler _cargomonitor_chunk_handlers[] = {
- { 'CMDL', SaveDelivery, LoadDelivery, NULL, NULL, CH_ARRAY},
- { 'CMPU', SavePickup, LoadPickup, NULL, NULL, CH_ARRAY | CH_LAST},
+ { 'CMDL', SaveDelivery, LoadDelivery, nullptr, nullptr, CH_ARRAY},
+ { 'CMPU', SavePickup, LoadPickup, nullptr, nullptr, CH_ARRAY | CH_LAST},
};
diff --git a/src/saveload/cargopacket_sl.cpp b/src/saveload/cargopacket_sl.cpp
index e3f372e9a..51cdf1cf1 100644
--- a/src/saveload/cargopacket_sl.cpp
+++ b/src/saveload/cargopacket_sl.cpp
@@ -139,5 +139,5 @@ static void Load_CAPA()
/** Chunk handlers related to cargo packets. */
extern const ChunkHandler _cargopacket_chunk_handlers[] = {
- { 'CAPA', Save_CAPA, Load_CAPA, NULL, NULL, CH_ARRAY | CH_LAST},
+ { 'CAPA', Save_CAPA, Load_CAPA, nullptr, nullptr, CH_ARRAY | CH_LAST},
};
diff --git a/src/saveload/cheat_sl.cpp b/src/saveload/cheat_sl.cpp
index 4616b7e85..e7b4735a9 100644
--- a/src/saveload/cheat_sl.cpp
+++ b/src/saveload/cheat_sl.cpp
@@ -51,5 +51,5 @@ static void Load_CHTS()
/** Chunk handlers related to cheats. */
extern const ChunkHandler _cheat_chunk_handlers[] = {
- { 'CHTS', Save_CHTS, Load_CHTS, NULL, NULL, CH_RIFF | CH_LAST},
+ { 'CHTS', Save_CHTS, Load_CHTS, nullptr, nullptr, CH_RIFF | CH_LAST},
};
diff --git a/src/saveload/company_sl.cpp b/src/saveload/company_sl.cpp
index a51f8081b..6c88db727 100644
--- a/src/saveload/company_sl.cpp
+++ b/src/saveload/company_sl.cpp
@@ -111,7 +111,7 @@ void AfterLoadCompanyStats()
switch (GetTileType(tile)) {
case MP_RAILWAY:
c = Company::GetIfValid(GetTileOwner(tile));
- if (c != NULL) {
+ if (c != nullptr) {
uint pieces = 1;
if (IsPlainRail(tile)) {
TrackBits bits = GetTrackBits(tile);
@@ -127,7 +127,7 @@ void AfterLoadCompanyStats()
case MP_ROAD: {
if (IsLevelCrossing(tile)) {
c = Company::GetIfValid(GetTileOwner(tile));
- if (c != NULL) c->infrastructure.rail[GetRailType(tile)] += LEVELCROSSING_TRACKBIT_FACTOR;
+ if (c != nullptr) c->infrastructure.rail[GetRailType(tile)] += LEVELCROSSING_TRACKBIT_FACTOR;
}
/* Iterate all present road types as each can have a different owner. */
@@ -135,19 +135,19 @@ void AfterLoadCompanyStats()
FOR_EACH_SET_ROADTYPE(rt, GetRoadTypes(tile)) {
c = Company::GetIfValid(IsRoadDepot(tile) ? GetTileOwner(tile) : GetRoadOwner(tile, rt));
/* A level crossings and depots have two road bits. */
- if (c != NULL) c->infrastructure.road[rt] += IsNormalRoad(tile) ? CountBits(GetRoadBits(tile, rt)) : 2;
+ if (c != nullptr) c->infrastructure.road[rt] += IsNormalRoad(tile) ? CountBits(GetRoadBits(tile, rt)) : 2;
}
break;
}
case MP_STATION:
c = Company::GetIfValid(GetTileOwner(tile));
- if (c != NULL && GetStationType(tile) != STATION_AIRPORT && !IsBuoy(tile)) c->infrastructure.station++;
+ if (c != nullptr && GetStationType(tile) != STATION_AIRPORT && !IsBuoy(tile)) c->infrastructure.station++;
switch (GetStationType(tile)) {
case STATION_RAIL:
case STATION_WAYPOINT:
- if (c != NULL && !IsStationTileBlocked(tile)) c->infrastructure.rail[GetRailType(tile)]++;
+ if (c != nullptr && !IsStationTileBlocked(tile)) c->infrastructure.rail[GetRailType(tile)]++;
break;
case STATION_BUS:
@@ -156,7 +156,7 @@ void AfterLoadCompanyStats()
RoadType rt;
FOR_EACH_SET_ROADTYPE(rt, GetRoadTypes(tile)) {
c = Company::GetIfValid(GetRoadOwner(tile, rt));
- if (c != NULL) c->infrastructure.road[rt] += 2; // A road stop has two road bits.
+ if (c != nullptr) c->infrastructure.road[rt] += 2; // A road stop has two road bits.
}
break;
}
@@ -164,7 +164,7 @@ void AfterLoadCompanyStats()
case STATION_DOCK:
case STATION_BUOY:
if (GetWaterClass(tile) == WATER_CLASS_CANAL) {
- if (c != NULL) c->infrastructure.water++;
+ if (c != nullptr) c->infrastructure.water++;
}
break;
@@ -176,7 +176,7 @@ void AfterLoadCompanyStats()
case MP_WATER:
if (IsShipDepot(tile) || IsLock(tile)) {
c = Company::GetIfValid(GetTileOwner(tile));
- if (c != NULL) {
+ if (c != nullptr) {
if (IsShipDepot(tile)) c->infrastructure.water += LOCK_DEPOT_TILE_FACTOR;
if (IsLock(tile) && GetLockPart(tile) == LOCK_PART_MIDDLE) {
/* The middle tile specifies the owner of the lock. */
@@ -190,7 +190,7 @@ void AfterLoadCompanyStats()
case MP_OBJECT:
if (GetWaterClass(tile) == WATER_CLASS_CANAL) {
c = Company::GetIfValid(GetTileOwner(tile));
- if (c != NULL) c->infrastructure.water++;
+ if (c != nullptr) c->infrastructure.water++;
}
break;
@@ -205,7 +205,7 @@ void AfterLoadCompanyStats()
switch (GetTunnelBridgeTransportType(tile)) {
case TRANSPORT_RAIL:
c = Company::GetIfValid(GetTileOwner(tile));
- if (c != NULL) c->infrastructure.rail[GetRailType(tile)] += len;
+ if (c != nullptr) c->infrastructure.rail[GetRailType(tile)] += len;
break;
case TRANSPORT_ROAD: {
@@ -213,14 +213,14 @@ void AfterLoadCompanyStats()
RoadType rt;
FOR_EACH_SET_ROADTYPE(rt, GetRoadTypes(tile)) {
c = Company::GetIfValid(GetRoadOwner(tile, rt));
- if (c != NULL) c->infrastructure.road[rt] += len * 2; // A full diagonal road has two road bits.
+ if (c != nullptr) c->infrastructure.road[rt] += len * 2; // A full diagonal road has two road bits.
}
break;
}
case TRANSPORT_WATER:
c = Company::GetIfValid(GetTileOwner(tile));
- if (c != NULL) c->infrastructure.water += len;
+ if (c != nullptr) c->infrastructure.water += len;
break;
default:
@@ -414,7 +414,7 @@ static void SaveLoad_PLYR_common(Company *c, CompanyProperties *cprops)
int i;
SlObject(cprops, _company_desc);
- if (c != NULL) {
+ if (c != nullptr) {
SlObject(c, _company_settings_desc);
} else {
char nothing;
@@ -444,7 +444,7 @@ static void SaveLoad_PLYR_common(Company *c, CompanyProperties *cprops)
/* Write each livery entry. */
int num_liveries = IsSavegameVersionBefore(SLV_63) ? LS_END - 4 : (IsSavegameVersionBefore(SLV_85) ? LS_END - 2: LS_END);
bool update_in_use = IsSavegameVersionBefore(SLV_GROUP_LIVERIES);
- if (c != NULL) {
+ if (c != nullptr) {
for (i = 0; i < num_liveries; i++) {
SlObject(&c->livery[i], _company_livery_desc);
if (update_in_use && i != LS_DEFAULT) {
@@ -507,7 +507,7 @@ static void Check_PLYR()
int index;
while ((index = SlIterateArray()) != -1) {
CompanyProperties *cprops = new CompanyProperties();
- SaveLoad_PLYR_common(NULL, cprops);
+ SaveLoad_PLYR_common(nullptr, cprops);
/* We do not load old custom names */
if (IsSavegameVersionBefore(SLV_84)) {
@@ -520,7 +520,7 @@ static void Check_PLYR()
}
}
- if (cprops->name == NULL && !IsInsideMM(cprops->name_1, SPECSTR_COMPANY_NAME_START, SPECSTR_COMPANY_NAME_LAST + 1) &&
+ if (cprops->name == nullptr && !IsInsideMM(cprops->name_1, SPECSTR_COMPANY_NAME_START, SPECSTR_COMPANY_NAME_LAST + 1) &&
cprops->name_1 != STR_GAME_SAVELOAD_NOT_AVAILABLE && cprops->name_1 != STR_SV_UNNAMED &&
cprops->name_1 != SPECSTR_ANDCO_NAME && cprops->name_1 != SPECSTR_PRESIDENT_NAME &&
cprops->name_1 != SPECSTR_SILLY_NAME) {
diff --git a/src/saveload/depot_sl.cpp b/src/saveload/depot_sl.cpp
index b92417693..74559f923 100644
--- a/src/saveload/depot_sl.cpp
+++ b/src/saveload/depot_sl.cpp
@@ -64,5 +64,5 @@ static void Ptrs_DEPT()
}
extern const ChunkHandler _depot_chunk_handlers[] = {
- { 'DEPT', Save_DEPT, Load_DEPT, Ptrs_DEPT, NULL, CH_ARRAY | CH_LAST},
+ { 'DEPT', Save_DEPT, Load_DEPT, Ptrs_DEPT, nullptr, CH_ARRAY | CH_LAST},
};
diff --git a/src/saveload/economy_sl.cpp b/src/saveload/economy_sl.cpp
index 0ddab1351..6161f668f 100644
--- a/src/saveload/economy_sl.cpp
+++ b/src/saveload/economy_sl.cpp
@@ -22,8 +22,8 @@ static void Load_PRIC()
{
/* Old games store 49 base prices, very old games store them as int32 */
int vt = IsSavegameVersionBefore(SLV_65) ? SLE_FILE_I32 : SLE_FILE_I64;
- SlArray(NULL, 49, vt | SLE_VAR_NULL);
- SlArray(NULL, 49, SLE_FILE_U16 | SLE_VAR_NULL);
+ SlArray(nullptr, 49, vt | SLE_VAR_NULL);
+ SlArray(nullptr, 49, SLE_FILE_U16 | SLE_VAR_NULL);
}
/** Cargo payment rates in pre 126 savegames */
@@ -31,8 +31,8 @@ static void Load_CAPR()
{
uint num_cargo = IsSavegameVersionBefore(SLV_55) ? 12 : IsSavegameVersionBefore(SLV_EXTEND_CARGOTYPES) ? 32 : NUM_CARGO;
int vt = IsSavegameVersionBefore(SLV_65) ? SLE_FILE_I32 : SLE_FILE_I64;
- SlArray(NULL, num_cargo, vt | SLE_VAR_NULL);
- SlArray(NULL, num_cargo, SLE_FILE_U16 | SLE_VAR_NULL);
+ SlArray(nullptr, num_cargo, vt | SLE_VAR_NULL);
+ SlArray(nullptr, num_cargo, SLE_FILE_U16 | SLE_VAR_NULL);
}
static const SaveLoad _economy_desc[] = {
@@ -101,8 +101,8 @@ static void Ptrs_CAPY()
extern const ChunkHandler _economy_chunk_handlers[] = {
- { 'CAPY', Save_CAPY, Load_CAPY, Ptrs_CAPY, NULL, CH_ARRAY},
- { 'PRIC', NULL, Load_PRIC, NULL, NULL, CH_RIFF | CH_AUTO_LENGTH},
- { 'CAPR', NULL, Load_CAPR, NULL, NULL, CH_RIFF | CH_AUTO_LENGTH},
- { 'ECMY', Save_ECMY, Load_ECMY, NULL, NULL, CH_RIFF | CH_LAST},
+ { 'CAPY', Save_CAPY, Load_CAPY, Ptrs_CAPY, nullptr, CH_ARRAY},
+ { 'PRIC', nullptr, Load_PRIC, nullptr, nullptr, CH_RIFF | CH_AUTO_LENGTH},
+ { 'CAPR', nullptr, Load_CAPR, nullptr, nullptr, CH_RIFF | CH_AUTO_LENGTH},
+ { 'ECMY', Save_ECMY, Load_ECMY, nullptr, nullptr, CH_RIFF | CH_LAST},
};
diff --git a/src/saveload/engine_sl.cpp b/src/saveload/engine_sl.cpp
index 891e30783..0fe190a0f 100644
--- a/src/saveload/engine_sl.cpp
+++ b/src/saveload/engine_sl.cpp
@@ -68,7 +68,7 @@ static Engine* CallocEngine()
*/
static void FreeEngine(Engine *e)
{
- if (e != NULL) {
+ if (e != nullptr) {
e->~Engine();
free(e);
}
@@ -141,7 +141,7 @@ void CopyTempEngineData()
e->preview_wait = se->preview_wait;
e->company_avail = se->company_avail;
e->company_hidden = se->company_hidden;
- if (se->name != NULL) e->name = stredup(se->name);
+ if (se->name != nullptr) e->name = stredup(se->name);
}
/* Get rid of temporary data */
@@ -197,7 +197,7 @@ static void Load_EIDS()
}
extern const ChunkHandler _engine_chunk_handlers[] = {
- { 'EIDS', Save_EIDS, Load_EIDS, NULL, NULL, CH_ARRAY },
- { 'ENGN', Save_ENGN, Load_ENGN, NULL, NULL, CH_ARRAY },
- { 'ENGS', NULL, Load_ENGS, NULL, NULL, CH_RIFF | CH_LAST },
+ { 'EIDS', Save_EIDS, Load_EIDS, nullptr, nullptr, CH_ARRAY },
+ { 'ENGN', Save_ENGN, Load_ENGN, nullptr, nullptr, CH_ARRAY },
+ { 'ENGS', nullptr, Load_ENGS, nullptr, nullptr, CH_RIFF | CH_LAST },
};
diff --git a/src/saveload/game_sl.cpp b/src/saveload/game_sl.cpp
index 52e8ac521..3602f0f29 100644
--- a/src/saveload/game_sl.cpp
+++ b/src/saveload/game_sl.cpp
@@ -52,19 +52,19 @@ static void SaveReal_GSDT(int *index_ptr)
_game_saveload_settings[0] = '\0';
config->SettingsToString(_game_saveload_settings, lastof(_game_saveload_settings));
- SlObject(NULL, _game_script);
+ SlObject(nullptr, _game_script);
Game::Save();
}
static void Load_GSDT()
{
/* Free all current data */
- GameConfig::GetConfig(GameConfig::SSS_FORCE_GAME)->Change(NULL);
+ GameConfig::GetConfig(GameConfig::SSS_FORCE_GAME)->Change(nullptr);
if ((CompanyID)SlIterateArray() == (CompanyID)-1) return;
_game_saveload_version = -1;
- SlObject(NULL, _game_script);
+ SlObject(nullptr, _game_script);
if (_networking && !_network_server) {
GameInstance::LoadEmpty();
@@ -110,7 +110,7 @@ static void Load_GSDT()
static void Save_GSDT()
{
SlSetArrayIndex(0);
- SlAutolength((AutolengthProc *)SaveReal_GSDT, NULL);
+ SlAutolength((AutolengthProc *)SaveReal_GSDT, nullptr);
}
extern GameStrings *_current_data;
@@ -134,10 +134,10 @@ static void SaveReal_GSTR(const LanguageStrings *ls)
_game_saveload_string = ls->language;
_game_saveload_strings = (uint)ls->lines.size();
- SlObject(NULL, _game_language_header);
+ SlObject(nullptr, _game_language_header);
for (const auto &i : ls->lines) {
_game_saveload_string = i.c_str();
- SlObject(NULL, _game_language_string);
+ SlObject(nullptr, _game_language_string);
}
}
@@ -147,22 +147,22 @@ static void Load_GSTR()
_current_data = new GameStrings();
while (SlIterateArray() != -1) {
- _game_saveload_string = NULL;
- SlObject(NULL, _game_language_header);
+ _game_saveload_string = nullptr;
+ SlObject(nullptr, _game_language_header);
- std::unique_ptr<LanguageStrings> ls(new LanguageStrings(_game_saveload_string != NULL ? _game_saveload_string : ""));
+ std::unique_ptr<LanguageStrings> ls(new LanguageStrings(_game_saveload_string != nullptr ? _game_saveload_string : ""));
for (uint i = 0; i < _game_saveload_strings; i++) {
- SlObject(NULL, _game_language_string);
- ls->lines.emplace_back(_game_saveload_string != NULL ? _game_saveload_string : "");
+ SlObject(nullptr, _game_language_string);
+ ls->lines.emplace_back(_game_saveload_string != nullptr ? _game_saveload_string : "");
}
_current_data->raw_strings.push_back(std::move(ls));
}
- /* If there were no strings in the savegame, set GameStrings to NULL */
+ /* If there were no strings in the savegame, set GameStrings to nullptr */
if (_current_data->raw_strings.size() == 0) {
delete _current_data;
- _current_data = NULL;
+ _current_data = nullptr;
return;
}
@@ -172,7 +172,7 @@ static void Load_GSTR()
static void Save_GSTR()
{
- if (_current_data == NULL) return;
+ if (_current_data == nullptr) return;
for (uint i = 0; i < _current_data->raw_strings.size(); i++) {
SlSetArrayIndex(i);
@@ -181,6 +181,6 @@ static void Save_GSTR()
}
extern const ChunkHandler _game_chunk_handlers[] = {
- { 'GSTR', Save_GSTR, Load_GSTR, NULL, NULL, CH_ARRAY },
- { 'GSDT', Save_GSDT, Load_GSDT, NULL, NULL, CH_ARRAY | CH_LAST},
+ { 'GSTR', Save_GSTR, Load_GSTR, nullptr, nullptr, CH_ARRAY },
+ { 'GSDT', Save_GSDT, Load_GSDT, nullptr, nullptr, CH_ARRAY | CH_LAST},
};
diff --git a/src/saveload/gamelog_sl.cpp b/src/saveload/gamelog_sl.cpp
index d1c502d3b..812d716ec 100644
--- a/src/saveload/gamelog_sl.cpp
+++ b/src/saveload/gamelog_sl.cpp
@@ -106,7 +106,7 @@ assert_compile(lengthof(_glog_desc) == GLCT_END);
static void Load_GLOG_common(LoggedAction *&gamelog_action, uint &gamelog_actions)
{
- assert(gamelog_action == NULL);
+ assert(gamelog_action == nullptr);
assert(gamelog_actions == 0);
GamelogActionType at;
@@ -117,7 +117,7 @@ static void Load_GLOG_common(LoggedAction *&gamelog_action, uint &gamelog_action
la->at = at;
SlObject(la, _glog_action_desc); // has to be saved after 'DATE'!
- la->change = NULL;
+ la->change = nullptr;
la->changes = 0;
GamelogChangeType ct;
@@ -125,7 +125,7 @@ static void Load_GLOG_common(LoggedAction *&gamelog_action, uint &gamelog_action
la->change = ReallocT(la->change, la->changes + 1);
LoggedChange *lc = &la->change[la->changes++];
- /* for SLE_STR, pointer has to be valid! so make it NULL */
+ /* for SLE_STR, pointer has to be valid! so make it nullptr */
memset(lc, 0, sizeof(*lc));
lc->ct = ct;
@@ -179,5 +179,5 @@ static void Check_GLOG()
}
extern const ChunkHandler _gamelog_chunk_handlers[] = {
- { 'GLOG', Save_GLOG, Load_GLOG, NULL, Check_GLOG, CH_RIFF | CH_LAST }
+ { 'GLOG', Save_GLOG, Load_GLOG, nullptr, Check_GLOG, CH_RIFF | CH_LAST }
};
diff --git a/src/saveload/goal_sl.cpp b/src/saveload/goal_sl.cpp
index a8cdc2305..b636dcf6a 100644
--- a/src/saveload/goal_sl.cpp
+++ b/src/saveload/goal_sl.cpp
@@ -45,5 +45,5 @@ static void Load_GOAL()
}
extern const ChunkHandler _goal_chunk_handlers[] = {
- { 'GOAL', Save_GOAL, Load_GOAL, NULL, NULL, CH_ARRAY | CH_LAST},
+ { 'GOAL', Save_GOAL, Load_GOAL, nullptr, nullptr, CH_ARRAY | CH_LAST},
};
diff --git a/src/saveload/group_sl.cpp b/src/saveload/group_sl.cpp
index 025c8ee3a..e43140132 100644
--- a/src/saveload/group_sl.cpp
+++ b/src/saveload/group_sl.cpp
@@ -61,5 +61,5 @@ static void Load_GRPS()
}
extern const ChunkHandler _group_chunk_handlers[] = {
- { 'GRPS', Save_GRPS, Load_GRPS, NULL, NULL, CH_ARRAY | CH_LAST},
+ { 'GRPS', Save_GRPS, Load_GRPS, nullptr, nullptr, CH_ARRAY | CH_LAST},
};
diff --git a/src/saveload/industry_sl.cpp b/src/saveload/industry_sl.cpp
index e5a0b74a3..391e5fbc3 100644
--- a/src/saveload/industry_sl.cpp
+++ b/src/saveload/industry_sl.cpp
@@ -183,9 +183,9 @@ static void Load_ITBL()
}
extern const ChunkHandler _industry_chunk_handlers[] = {
- { 'INDY', Save_INDY, Load_INDY, Ptrs_INDY, NULL, CH_ARRAY},
- { 'IIDS', Save_IIDS, Load_IIDS, NULL, NULL, CH_ARRAY},
- { 'TIDS', Save_TIDS, Load_TIDS, NULL, NULL, CH_ARRAY},
- { 'IBLD', LoadSave_IBLD, LoadSave_IBLD, NULL, NULL, CH_RIFF},
- { 'ITBL', Save_ITBL, Load_ITBL, NULL, NULL, CH_ARRAY | CH_LAST},
+ { 'INDY', Save_INDY, Load_INDY, Ptrs_INDY, nullptr, CH_ARRAY},
+ { 'IIDS', Save_IIDS, Load_IIDS, nullptr, nullptr, CH_ARRAY},
+ { 'TIDS', Save_TIDS, Load_TIDS, nullptr, nullptr, CH_ARRAY},
+ { 'IBLD', LoadSave_IBLD, LoadSave_IBLD, nullptr, nullptr, CH_RIFF},
+ { 'ITBL', Save_ITBL, Load_ITBL, nullptr, nullptr, CH_ARRAY | CH_LAST},
};
diff --git a/src/saveload/labelmaps_sl.cpp b/src/saveload/labelmaps_sl.cpp
index dd71f1c3e..6236e190e 100644
--- a/src/saveload/labelmaps_sl.cpp
+++ b/src/saveload/labelmaps_sl.cpp
@@ -119,6 +119,6 @@ static void Load_RAIL()
}
extern const ChunkHandler _labelmaps_chunk_handlers[] = {
- { 'RAIL', Save_RAIL, Load_RAIL, NULL, NULL, CH_ARRAY | CH_LAST},
+ { 'RAIL', Save_RAIL, Load_RAIL, nullptr, nullptr, CH_ARRAY | CH_LAST},
};
diff --git a/src/saveload/linkgraph_sl.cpp b/src/saveload/linkgraph_sl.cpp
index 90c056eba..172025dce 100644
--- a/src/saveload/linkgraph_sl.cpp
+++ b/src/saveload/linkgraph_sl.cpp
@@ -64,7 +64,7 @@ const SaveLoad *GetLinkGraphJobDesc()
int setting = 0;
const SettingDesc *desc = GetSettingDescription(setting);
while (desc->save.cmd != SL_END) {
- if (desc->desc.name != NULL && strncmp(desc->desc.name, prefix, prefixlen) == 0) {
+ if (desc->desc.name != nullptr && strncmp(desc->desc.name, prefix, prefixlen) == 0) {
SaveLoad sl = desc->save;
char *&address = reinterpret_cast<char *&>(sl.address);
address -= offset_gamesettings;
@@ -290,7 +290,7 @@ static void Ptrs_LGRS()
}
extern const ChunkHandler _linkgraph_chunk_handlers[] = {
- { 'LGRP', Save_LGRP, Load_LGRP, NULL, NULL, CH_ARRAY },
- { 'LGRJ', Save_LGRJ, Load_LGRJ, NULL, NULL, CH_ARRAY },
- { 'LGRS', Save_LGRS, Load_LGRS, Ptrs_LGRS, NULL, CH_LAST }
+ { 'LGRP', Save_LGRP, Load_LGRP, nullptr, nullptr, CH_ARRAY },
+ { 'LGRJ', Save_LGRJ, Load_LGRJ, nullptr, nullptr, CH_ARRAY },
+ { 'LGRS', Save_LGRS, Load_LGRS, Ptrs_LGRS, nullptr, CH_LAST }
};
diff --git a/src/saveload/map_sl.cpp b/src/saveload/map_sl.cpp
index 5402ecc0d..18c135117 100644
--- a/src/saveload/map_sl.cpp
+++ b/src/saveload/map_sl.cpp
@@ -297,15 +297,15 @@ static void Save_MAP8()
extern const ChunkHandler _map_chunk_handlers[] = {
- { 'MAPS', Save_MAPS, Load_MAPS, NULL, Check_MAPS, CH_RIFF },
- { 'MAPT', Save_MAPT, Load_MAPT, NULL, NULL, CH_RIFF },
- { 'MAPH', Save_MAPH, Load_MAPH, NULL, NULL, CH_RIFF },
- { 'MAPO', Save_MAP1, Load_MAP1, NULL, NULL, CH_RIFF },
- { 'MAP2', Save_MAP2, Load_MAP2, NULL, NULL, CH_RIFF },
- { 'M3LO', Save_MAP3, Load_MAP3, NULL, NULL, CH_RIFF },
- { 'M3HI', Save_MAP4, Load_MAP4, NULL, NULL, CH_RIFF },
- { 'MAP5', Save_MAP5, Load_MAP5, NULL, NULL, CH_RIFF },
- { 'MAPE', Save_MAP6, Load_MAP6, NULL, NULL, CH_RIFF },
- { 'MAP7', Save_MAP7, Load_MAP7, NULL, NULL, CH_RIFF },
- { 'MAP8', Save_MAP8, Load_MAP8, NULL, NULL, CH_RIFF | CH_LAST },
+ { 'MAPS', Save_MAPS, Load_MAPS, nullptr, Check_MAPS, CH_RIFF },
+ { 'MAPT', Save_MAPT, Load_MAPT, nullptr, nullptr, CH_RIFF },
+ { 'MAPH', Save_MAPH, Load_MAPH, nullptr, nullptr, CH_RIFF },
+ { 'MAPO', Save_MAP1, Load_MAP1, nullptr, nullptr, CH_RIFF },
+ { 'MAP2', Save_MAP2, Load_MAP2, nullptr, nullptr, CH_RIFF },
+ { 'M3LO', Save_MAP3, Load_MAP3, nullptr, nullptr, CH_RIFF },
+ { 'M3HI', Save_MAP4, Load_MAP4, nullptr, nullptr, CH_RIFF },
+ { 'MAP5', Save_MAP5, Load_MAP5, nullptr, nullptr, CH_RIFF },
+ { 'MAPE', Save_MAP6, Load_MAP6, nullptr, nullptr, CH_RIFF },
+ { 'MAP7', Save_MAP7, Load_MAP7, nullptr, nullptr, CH_RIFF },
+ { 'MAP8', Save_MAP8, Load_MAP8, nullptr, nullptr, CH_RIFF | CH_LAST },
};
diff --git a/src/saveload/misc_sl.cpp b/src/saveload/misc_sl.cpp
index cca3365b5..9755f74e1 100644
--- a/src/saveload/misc_sl.cpp
+++ b/src/saveload/misc_sl.cpp
@@ -36,7 +36,7 @@ void SaveViewportBeforeSaveGame()
{
const Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
- if (w != NULL) {
+ if (w != nullptr) {
_saved_scrollpos_x = w->viewport->scrollpos_x;
_saved_scrollpos_y = w->viewport->scrollpos_y;
_saved_scrollpos_zoom = w->viewport->zoom;
@@ -151,6 +151,6 @@ static void SaveLoad_VIEW()
}
extern const ChunkHandler _misc_chunk_handlers[] = {
- { 'DATE', SaveLoad_DATE, SaveLoad_DATE, NULL, Check_DATE, CH_RIFF},
- { 'VIEW', SaveLoad_VIEW, SaveLoad_VIEW, NULL, NULL, CH_RIFF | CH_LAST},
+ { 'DATE', SaveLoad_DATE, SaveLoad_DATE, nullptr, Check_DATE, CH_RIFF},
+ { 'VIEW', SaveLoad_VIEW, SaveLoad_VIEW, nullptr, nullptr, CH_RIFF | CH_LAST},
};
diff --git a/src/saveload/newgrf_sl.cpp b/src/saveload/newgrf_sl.cpp
index e40b45926..2f7dfb356 100644
--- a/src/saveload/newgrf_sl.cpp
+++ b/src/saveload/newgrf_sl.cpp
@@ -73,7 +73,7 @@ static void Save_NGRF()
{
int index = 0;
- for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) {
+ for (GRFConfig *c = _grfconfig; c != nullptr; c = c->next) {
if (HasBit(c->flags, GCF_STATIC)) continue;
SlSetArrayIndex(index++);
SlObject(c, _grfconfig_desc);
@@ -98,7 +98,7 @@ static void Load_NGRF()
if (_game_mode == GM_MENU) {
/* Intro game must not have NewGRF. */
- if (_grfconfig != NULL) SlErrorCorrupt("The intro game must not use NewGRF");
+ if (_grfconfig != nullptr) SlErrorCorrupt("The intro game must not use NewGRF");
/* Activate intro NewGRFs (townnames) */
ResetGRFConfig(false);
@@ -114,5 +114,5 @@ static void Check_NGRF()
}
extern const ChunkHandler _newgrf_chunk_handlers[] = {
- { 'NGRF', Save_NGRF, Load_NGRF, NULL, Check_NGRF, CH_ARRAY | CH_LAST }
+ { 'NGRF', Save_NGRF, Load_NGRF, nullptr, Check_NGRF, CH_ARRAY | CH_LAST }
};
diff --git a/src/saveload/object_sl.cpp b/src/saveload/object_sl.cpp
index 6b0b99e47..2ec996664 100644
--- a/src/saveload/object_sl.cpp
+++ b/src/saveload/object_sl.cpp
@@ -74,6 +74,6 @@ static void Load_OBID()
}
extern const ChunkHandler _object_chunk_handlers[] = {
- { 'OBID', Save_OBID, Load_OBID, NULL, NULL, CH_ARRAY },
- { 'OBJS', Save_OBJS, Load_OBJS, Ptrs_OBJS, NULL, CH_ARRAY | CH_LAST},
+ { 'OBID', Save_OBID, Load_OBID, nullptr, nullptr, CH_ARRAY },
+ { 'OBJS', Save_OBJS, Load_OBJS, Ptrs_OBJS, nullptr, CH_ARRAY | CH_LAST},
};
diff --git a/src/saveload/oldloader.cpp b/src/saveload/oldloader.cpp
index e0ad0e732..9b24750d2 100644
--- a/src/saveload/oldloader.cpp
+++ b/src/saveload/oldloader.cpp
@@ -154,11 +154,11 @@ bool LoadChunk(LoadgameState *ls, void *base, const OldChunks *chunks)
default: NOT_REACHED();
}
- /* When both pointers are NULL, we are just skipping data */
- if (base_ptr == NULL && chunk->ptr == NULL) continue;
+ /* When both pointers are nullptr, we are just skipping data */
+ if (base_ptr == nullptr && chunk->ptr == nullptr) continue;
/* Writing to the var: bits 8 to 15 have the VAR type */
- if (chunk->ptr == NULL) ptr = base_ptr + chunk->offset;
+ if (chunk->ptr == nullptr) ptr = base_ptr + chunk->offset;
/* Write the data */
switch (GetOldChunkVarType(chunk->type)) {
@@ -174,7 +174,7 @@ bool LoadChunk(LoadgameState *ls, void *base, const OldChunks *chunks)
}
/* Increase pointer base for arrays when looping */
- if (chunk->amount > 1 && chunk->ptr != NULL) ptr += CalcOldVarLen(chunk->type);
+ if (chunk->amount > 1 && chunk->ptr != nullptr) ptr += CalcOldVarLen(chunk->type);
}
}
}
@@ -259,7 +259,7 @@ static SavegameType DetermineOldSavegameType(FILE *f, char *title, const char *l
}
}
- if (title != NULL) {
+ if (title != nullptr) {
switch (type) {
case SGT_TTO: title = strecpy(title, "(TTO) ", last); break;
case SGT_TTD: title = strecpy(title, "(TTD) ", last); break;
@@ -284,14 +284,14 @@ bool LoadOldSaveGame(const char *file)
/* Open file */
ls.file = FioFOpenFile(file, "rb", NO_DIRECTORY);
- if (ls.file == NULL) {
+ if (ls.file == nullptr) {
DEBUG(oldloader, 0, "Cannot open file '%s'", file);
return false;
}
- SavegameType type = DetermineOldSavegameType(ls.file, NULL, NULL);
+ SavegameType type = DetermineOldSavegameType(ls.file, nullptr, nullptr);
- LoadOldMainProc *proc = NULL;
+ LoadOldMainProc *proc = nullptr;
switch (type) {
case SGT_TTO: proc = &LoadTTOMain; break;
@@ -303,7 +303,7 @@ bool LoadOldSaveGame(const char *file)
bool game_loaded;
try {
- game_loaded = proc != NULL && proc(&ls);
+ game_loaded = proc != nullptr && proc(&ls);
} catch (...) {
game_loaded = false;
}
@@ -323,7 +323,7 @@ void GetOldSaveGameName(const char *file, char *title, const char *last)
{
FILE *f = FioFOpenFile(file, "rb", NO_DIRECTORY);
- if (f == NULL) {
+ if (f == nullptr) {
*title = '\0';
return;
}
diff --git a/src/saveload/oldloader.h b/src/saveload/oldloader.h
index 5483440ea..a2953196b 100644
--- a/src/saveload/oldloader.h
+++ b/src/saveload/oldloader.h
@@ -90,7 +90,7 @@ struct OldChunks {
uint32 amount; ///< Amount of fields
void *ptr; ///< Pointer where to save the data (may only be set if offset is 0)
- uint offset; ///< Offset from basepointer (may only be set if ptr is NULL)
+ uint offset; ///< Offset from basepointer (may only be set if ptr is nullptr)
OldChunkProc *proc; ///< Pointer to function that is called with OC_CHUNK
};
@@ -125,12 +125,12 @@ static inline uint32 ReadUint32(LoadgameState *ls)
* - OCL_CHUNK: load another proc to load a part of the savegame, 'amount' times
* - OCL_ASSERT: to check if we are really at the place we expect to be.. because old savegames are too binary to be sure ;)
*/
-#define OCL_SVAR(type, base, offset) { type, 1, NULL, (uint)cpp_offsetof(base, offset), NULL }
-#define OCL_VAR(type, amount, pointer) { type, amount, pointer, 0, NULL }
-#define OCL_END() { OC_END, 0, NULL, 0, NULL }
-#define OCL_CNULL(type, amount) { OC_NULL | type, amount, NULL, 0, NULL }
-#define OCL_CCHUNK(type, amount, proc) { OC_CHUNK | type, amount, NULL, 0, proc }
-#define OCL_ASSERT(type, size) { OC_ASSERT | type, 1, NULL, size, NULL }
+#define OCL_SVAR(type, base, offset) { type, 1, nullptr, (uint)cpp_offsetof(base, offset), nullptr }
+#define OCL_VAR(type, amount, pointer) { type, amount, pointer, 0, nullptr }
+#define OCL_END() { OC_END, 0, nullptr, 0, nullptr }
+#define OCL_CNULL(type, amount) { OC_NULL | type, amount, nullptr, 0, nullptr }
+#define OCL_CCHUNK(type, amount, proc) { OC_CHUNK | type, amount, nullptr, 0, proc }
+#define OCL_ASSERT(type, size) { OC_ASSERT | type, 1, nullptr, size, nullptr }
#define OCL_NULL(amount) OCL_CNULL((OldChunkType)0, amount)
#define OCL_CHUNK(amount, proc) OCL_CCHUNK((OldChunkType)0, amount, proc)
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp
index a93006f1f..663934103 100644
--- a/src/saveload/oldloader_sl.cpp
+++ b/src/saveload/oldloader_sl.cpp
@@ -178,7 +178,7 @@ void FixOldVehicles()
FOR_ALL_VEHICLES(v) {
if ((size_t)v->next == 0xFFFF) {
- v->next = NULL;
+ v->next = nullptr;
} else {
v->next = Vehicle::GetIfValid((size_t)v->next);
}
@@ -452,7 +452,7 @@ static bool FixTTOEngines()
e->preview_company = INVALID_COMPANY;
e->preview_asked = (CompanyMask)-1;
e->preview_wait = 0;
- e->name = NULL;
+ e->name = nullptr;
}
return true;
@@ -621,7 +621,7 @@ static const OldChunks order_chunk[] = {
static bool LoadOldOrder(LoadgameState *ls, int num)
{
- if (!LoadChunk(ls, NULL, order_chunk)) return false;
+ if (!LoadChunk(ls, nullptr, order_chunk)) return false;
Order *o = new (num) Order();
o->AssignOrder(UnpackOldOrder(_old_order));
@@ -632,7 +632,7 @@ static bool LoadOldOrder(LoadgameState *ls, int num)
/* Relink the orders to each other (in the orders for one vehicle are behind each other,
* with an invalid order (OT_NOTHING) as indication that it is the last order */
Order *prev = Order::GetIfValid(num - 1);
- if (prev != NULL) prev->next = o;
+ if (prev != nullptr) prev->next = o;
}
return true;
@@ -646,7 +646,7 @@ static bool LoadOldAnimTileList(LoadgameState *ls, int num)
OCL_END ()
};
- if (!LoadChunk(ls, NULL, anim_chunk)) return false;
+ if (!LoadChunk(ls, nullptr, anim_chunk)) return false;
/* The first zero in the loaded array indicates the end of the list. */
for (int i = 0; i < 256; i++) {
@@ -671,7 +671,7 @@ static bool LoadOldDepot(LoadgameState *ls, int num)
if (d->xy != 0) {
/* In some cases, there could be depots referencing invalid town. */
Town *t = Town::GetIfValid(RemapTownIndex(_old_town_index));
- if (t == NULL) t = Town::GetRandom();
+ if (t == nullptr) t = Town::GetRandom();
d->town = t;
} else {
delete d;
@@ -876,7 +876,7 @@ static bool LoadOldCompanyYearly(LoadgameState *ls, int num)
if (_savegame_type == SGT_TTO && i == 6) {
_old_yearly = 0; // property maintenance
} else {
- if (!LoadChunk(ls, NULL, _company_yearly_chunk)) return false;
+ if (!LoadChunk(ls, nullptr, _company_yearly_chunk)) return false;
}
c->yearly_expenses[num][i] = _old_yearly;
@@ -1106,8 +1106,8 @@ static bool LoadOldVehicleUnion(LoadgameState *ls, int num)
uint temp = ls->total_read;
bool res;
- if (v == NULL) {
- res = LoadChunk(ls, NULL, vehicle_empty_chunk);
+ if (v == nullptr) {
+ res = LoadChunk(ls, nullptr, vehicle_empty_chunk);
} else {
switch (v->type) {
default: SlErrorCorrupt("Invalid vehicle type");
@@ -1240,7 +1240,7 @@ bool LoadOldVehicle(LoadgameState *ls, int num)
uint type = ReadByte(ls);
switch (type) {
default: return false;
- case 0x00 /* VEH_INVALID */: v = NULL; break;
+ case 0x00 /* VEH_INVALID */: v = nullptr; break;
case 0x25 /* MONORAIL */:
case 0x20 /* VEH_TRAIN */: v = new (_current_vehicle_id) Train(); break;
case 0x21 /* VEH_ROAD */: v = new (_current_vehicle_id) RoadVehicle(); break;
@@ -1251,7 +1251,7 @@ bool LoadOldVehicle(LoadgameState *ls, int num)
}
if (!LoadChunk(ls, v, vehicle_chunk)) return false;
- if (v == NULL) continue;
+ if (v == nullptr) continue;
v->refit_cap = v->cargo_cap;
SpriteID sprite = v->sprite_seq.seq[0].sprite;
@@ -1318,7 +1318,7 @@ bool LoadOldVehicle(LoadgameState *ls, int num)
/* Read the vehicle type and allocate the right vehicle */
switch (ReadByte(ls)) {
default: SlErrorCorrupt("Invalid vehicle type");
- case 0x00 /* VEH_INVALID */: v = NULL; break;
+ case 0x00 /* VEH_INVALID */: v = nullptr; break;
case 0x10 /* VEH_TRAIN */: v = new (_current_vehicle_id) Train(); break;
case 0x11 /* VEH_ROAD */: v = new (_current_vehicle_id) RoadVehicle(); break;
case 0x12 /* VEH_SHIP */: v = new (_current_vehicle_id) Ship(); break;
@@ -1328,7 +1328,7 @@ bool LoadOldVehicle(LoadgameState *ls, int num)
}
if (!LoadChunk(ls, v, vehicle_chunk)) return false;
- if (v == NULL) continue;
+ if (v == nullptr) continue;
_old_vehicle_names[_current_vehicle_id] = RemapOldStringID(_old_string_id);
@@ -1756,9 +1756,9 @@ bool LoadTTDMain(LoadgameState *ls)
/* Load the biggest chunk */
SmallStackSafeStackAlloc<byte, OLD_MAP_SIZE * 2> map3;
_old_map3 = map3.data;
- _old_vehicle_names = NULL;
+ _old_vehicle_names = nullptr;
try {
- if (!LoadChunk(ls, NULL, main_chunk)) {
+ if (!LoadChunk(ls, nullptr, main_chunk)) {
DEBUG(oldloader, 0, "Loading failed");
free(_old_vehicle_names);
return false;
@@ -1803,7 +1803,7 @@ bool LoadTTOMain(LoadgameState *ls)
_old_vehicle_names = vehnames.data;
/* Load the biggest chunk */
- if (!LoadChunk(ls, NULL, main_chunk)) {
+ if (!LoadChunk(ls, nullptr, main_chunk)) {
DEBUG(oldloader, 0, "Loading failed");
return false;
}
diff --git a/src/saveload/order_sl.cpp b/src/saveload/order_sl.cpp
index b89514d47..c21782de5 100644
--- a/src/saveload/order_sl.cpp
+++ b/src/saveload/order_sl.cpp
@@ -178,7 +178,7 @@ static void Load_ORDR()
/* The orders were built like this:
* While the order is valid, set the previous will get its next pointer set */
Order *prev = Order::GetIfValid(order_index - 1);
- if (prev != NULL) prev->next = o;
+ if (prev != nullptr) prev->next = o;
}
} else {
int index;
@@ -306,7 +306,7 @@ static void Ptrs_BKOR()
}
extern const ChunkHandler _order_chunk_handlers[] = {
- { 'BKOR', Save_BKOR, Load_BKOR, Ptrs_BKOR, NULL, CH_ARRAY},
- { 'ORDR', Save_ORDR, Load_ORDR, Ptrs_ORDR, NULL, CH_ARRAY},
- { 'ORDL', Save_ORDL, Load_ORDL, Ptrs_ORDL, NULL, CH_ARRAY | CH_LAST},
+ { 'BKOR', Save_BKOR, Load_BKOR, Ptrs_BKOR, nullptr, CH_ARRAY},
+ { 'ORDR', Save_ORDR, Load_ORDR, Ptrs_ORDR, nullptr, CH_ARRAY},
+ { 'ORDL', Save_ORDL, Load_ORDL, Ptrs_ORDL, nullptr, CH_ARRAY | CH_LAST},
};
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index f03e3d659..bab1e894f 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -95,7 +95,7 @@ struct ReadBuffer {
* Initialise our variables.
* @param reader The filter to actually read data.
*/
- ReadBuffer(LoadFilter *reader) : bufp(NULL), bufe(NULL), reader(reader), read(0)
+ ReadBuffer(LoadFilter *reader) : bufp(nullptr), bufe(nullptr), reader(reader), read(0)
{
}
@@ -131,7 +131,7 @@ struct MemoryDumper {
byte *bufe; ///< End of the buffer we write to.
/** Initialise our variables. */
- MemoryDumper() : buf(NULL), bufe(NULL)
+ MemoryDumper() : buf(nullptr), bufe(nullptr)
{
}
@@ -247,7 +247,7 @@ extern const ChunkHandler _airport_chunk_handlers[];
extern const ChunkHandler _object_chunk_handlers[];
extern const ChunkHandler _persistent_storage_chunk_handlers[];
-/** Array of all chunks in a savegame, \c NULL terminated. */
+/** Array of all chunks in a savegame, \c nullptr terminated. */
static const ChunkHandler * const _chunk_handlers[] = {
_gamelog_chunk_handlers,
_map_chunk_handlers,
@@ -282,7 +282,7 @@ static const ChunkHandler * const _chunk_handlers[] = {
_airport_chunk_handlers,
_object_chunk_handlers,
_persistent_storage_chunk_handlers,
- NULL,
+ nullptr,
};
/**
@@ -290,10 +290,10 @@ static const ChunkHandler * const _chunk_handlers[] = {
* @param ch the chunk handler iterator
*/
#define FOR_ALL_CHUNK_HANDLERS(ch) \
- for (const ChunkHandler * const *chsc = _chunk_handlers; *chsc != NULL; chsc++) \
- for (const ChunkHandler *ch = *chsc; ch != NULL; ch = (ch->flags & CH_LAST) ? NULL : ch + 1)
+ for (const ChunkHandler * const *chsc = _chunk_handlers; *chsc != nullptr; chsc++) \
+ for (const ChunkHandler *ch = *chsc; ch != nullptr; ch = (ch->flags & CH_LAST) ? nullptr : ch + 1)
-/** Null all pointers (convert index -> NULL) */
+/** Null all pointers (convert index -> nullptr) */
static void SlNullPointers()
{
_sl.action = SLA_NULL;
@@ -306,7 +306,7 @@ static void SlNullPointers()
DEBUG(sl, 1, "Nulling pointers");
FOR_ALL_CHUNK_HANDLERS(ch) {
- if (ch->ptrs_proc != NULL) {
+ if (ch->ptrs_proc != nullptr) {
DEBUG(sl, 2, "Nulling pointers for %c%c%c%c", ch->id >> 24, ch->id >> 16, ch->id >> 8, ch->id);
ch->ptrs_proc();
}
@@ -331,14 +331,14 @@ void NORETURN SlError(StringID string, const char *extra_msg)
if (_sl.action == SLA_LOAD_CHECK) {
_load_check_data.error = string;
free(_load_check_data.error_data);
- _load_check_data.error_data = (extra_msg == NULL) ? NULL : stredup(extra_msg);
+ _load_check_data.error_data = (extra_msg == nullptr) ? nullptr : stredup(extra_msg);
} else {
_sl.error_str = string;
free(_sl.extra_msg);
- _sl.extra_msg = (extra_msg == NULL) ? NULL : stredup(extra_msg);
+ _sl.extra_msg = (extra_msg == nullptr) ? nullptr : stredup(extra_msg);
}
- /* We have to NULL all pointers here; we might be in a state where
+ /* We have to nullptr all pointers here; we might be in a state where
* the pointers are actually filled with indices, which means that
* when we access them during cleaning the pool dereferences of
* those indices will be made with segmentation faults as result. */
@@ -389,7 +389,7 @@ static std::thread _save_thread; ///< The thread we'r
static void SetAsyncSaveFinish(AsyncSaveFinishProc proc)
{
if (_exit_game) return;
- while (_async_save_finish.load(std::memory_order_acquire) != NULL) CSleep(10);
+ while (_async_save_finish.load(std::memory_order_acquire) != nullptr) CSleep(10);
_async_save_finish.store(proc, std::memory_order_release);
}
@@ -399,8 +399,8 @@ static void SetAsyncSaveFinish(AsyncSaveFinishProc proc)
*/
void ProcessAsyncSaveFinish()
{
- AsyncSaveFinishProc proc = _async_save_finish.exchange(NULL, std::memory_order_acq_rel);
- if (proc == NULL) return;
+ AsyncSaveFinishProc proc = _async_save_finish.exchange(nullptr, std::memory_order_acq_rel);
+ if (proc == nullptr) return;
proc();
@@ -863,7 +863,7 @@ static void SlSaveLoadConv(void *ptr, VarType conv)
*/
static inline size_t SlCalcNetStringLen(const char *ptr, size_t length)
{
- if (ptr == NULL) return 0;
+ if (ptr == nullptr) return 0;
return min(strlen(ptr), length - 1);
}
@@ -948,7 +948,7 @@ static void SlString(void *ptr, size_t length, VarType conv)
case SLE_VAR_STRQ: // Malloc'd string, free previous incarnation, and allocate
free(*(char **)ptr);
if (len == 0) {
- *(char **)ptr = NULL;
+ *(char **)ptr = nullptr;
return;
} else {
*(char **)ptr = MallocT<char>(len + 1); // terminating '\0'
@@ -1043,7 +1043,7 @@ void SlArray(void *array, size_t length, VarType conv)
* Pointers cannot be saved to a savegame, so this functions gets
* the index of the item, and if not available, it hussles with
* pointers (looks really bad :()
- * Remember that a NULL item has value 0, and all
+ * Remember that a nullptr item has value 0, and all
* indices have +1, so vehicle 0 is saved as index 1.
* @param obj The object that we want to get the index of
* @param rt SLRefType type of the object the index is being sought of
@@ -1053,7 +1053,7 @@ static size_t ReferenceToInt(const void *obj, SLRefType rt)
{
assert(_sl.action == SLA_SAVE);
- if (obj == NULL) return 0;
+ if (obj == nullptr) return 0;
switch (rt) {
case REF_VEHICLE_OLD: // Old vehicles we save as new ones
@@ -1076,7 +1076,7 @@ static size_t ReferenceToInt(const void *obj, SLRefType rt)
* Pointers cannot be loaded from a savegame, so this function
* gets the index from the savegame and returns the appropriate
* pointer from the already loaded base.
- * Remember that an index of 0 is a NULL pointer so all indices
+ * Remember that an index of 0 is a nullptr pointer so all indices
* are +1 so vehicle 0 is saved as 1.
* @param index The index that is being converted to a pointer
* @param rt SLRefType type of the object the pointer is sought of
@@ -1094,8 +1094,8 @@ static void *IntToReference(size_t index, SLRefType rt)
rt = REF_VEHICLE;
}
- /* No need to look up NULL pointers, just return immediately */
- if (index == (rt == REF_VEHICLE_OLD ? 0xFFFF : 0)) return NULL;
+ /* No need to look up nullptr pointers, just return immediately */
+ if (index == (rt == REF_VEHICLE_OLD ? 0xFFFF : 0)) return nullptr;
/* Correct index. Old vehicles were saved differently:
* invalid vehicle was 0xFFFF, now we use 0x0000 for everything invalid. */
@@ -1109,7 +1109,7 @@ static void *IntToReference(size_t index, SLRefType rt)
case REF_ORDER:
if (Order::IsValidID(index)) return Order::Get(index);
/* in old versions, invalid order was used to mark end of order list */
- if (IsSavegameVersionBefore(SLV_5, 2)) return NULL;
+ if (IsSavegameVersionBefore(SLV_5, 2)) return nullptr;
SlErrorCorrupt("Referencing invalid Order");
case REF_VEHICLE_OLD:
@@ -1499,7 +1499,7 @@ bool SlObjectMember(void *ptr, const SaveLoad *sld)
*(void **)ptr = IntToReference(*(size_t *)ptr, (SLRefType)conv);
break;
case SLA_NULL:
- *(void **)ptr = NULL;
+ *(void **)ptr = nullptr;
break;
default: NOT_REACHED();
}
@@ -1565,7 +1565,7 @@ void SlObject(void *object, const SaveLoad *sld)
*/
void SlGlobList(const SaveLoadGlobVarList *sldg)
{
- SlObject(NULL, (const SaveLoad*)sldg);
+ SlObject(nullptr, (const SaveLoad*)sldg);
}
/**
@@ -1637,7 +1637,7 @@ static void SlLoadChunk(const ChunkHandler *ch)
/**
* Load a chunk of data for checking savegames.
- * If the chunkhandler is NULL, the chunk is skipped.
+ * If the chunkhandler is nullptr, the chunk is skipped.
* @param ch The chunkhandler that will be used for the operation
*/
static void SlLoadCheckChunk(const ChunkHandler *ch)
@@ -1708,7 +1708,7 @@ static inline void SlStubSaveProc2(void *arg)
*/
static void SlStubSaveProc()
{
- SlAutolength(SlStubSaveProc2, NULL);
+ SlAutolength(SlStubSaveProc2, nullptr);
}
/**
@@ -1721,7 +1721,7 @@ static void SlSaveChunk(const ChunkHandler *ch)
ChunkSaveLoadProc *proc = ch->save_proc;
/* Don't save any chunk information if there is no save handler. */
- if (proc == NULL) return;
+ if (proc == nullptr) return;
SlWriteUint32(ch->id);
DEBUG(sl, 2, "Saving chunk %c%c%c%c", ch->id >> 24, ch->id >> 16, ch->id >> 8, ch->id);
@@ -1773,7 +1773,7 @@ static void SlSaveChunks()
static const ChunkHandler *SlFindChunkHandler(uint32 id)
{
FOR_ALL_CHUNK_HANDLERS(ch) if (ch->id == id) return ch;
- return NULL;
+ return nullptr;
}
/** Load all chunks */
@@ -1786,7 +1786,7 @@ static void SlLoadChunks()
DEBUG(sl, 2, "Loading chunk %c%c%c%c", id >> 24, id >> 16, id >> 8, id);
ch = SlFindChunkHandler(id);
- if (ch == NULL) SlErrorCorrupt("Unknown chunk type");
+ if (ch == nullptr) SlErrorCorrupt("Unknown chunk type");
SlLoadChunk(ch);
}
}
@@ -1801,7 +1801,7 @@ static void SlLoadCheckChunks()
DEBUG(sl, 2, "Loading chunk %c%c%c%c", id >> 24, id >> 16, id >> 8, id);
ch = SlFindChunkHandler(id);
- if (ch == NULL) SlErrorCorrupt("Unknown chunk type");
+ if (ch == nullptr) SlErrorCorrupt("Unknown chunk type");
SlLoadCheckChunk(ch);
}
}
@@ -1814,7 +1814,7 @@ static void SlFixPointers()
DEBUG(sl, 1, "Fixing pointers");
FOR_ALL_CHUNK_HANDLERS(ch) {
- if (ch->ptrs_proc != NULL) {
+ if (ch->ptrs_proc != nullptr) {
DEBUG(sl, 2, "Fixing pointers for %c%c%c%c", ch->id >> 24, ch->id >> 16, ch->id >> 8, ch->id);
ch->ptrs_proc();
}
@@ -1835,24 +1835,24 @@ struct FileReader : LoadFilter {
* Create the file reader, so it reads from a specific file.
* @param file The file to read from.
*/
- FileReader(FILE *file) : LoadFilter(NULL), file(file), begin(ftell(file))
+ FileReader(FILE *file) : LoadFilter(nullptr), file(file), begin(ftell(file))
{
}
/** Make sure everything is cleaned up. */
~FileReader()
{
- if (this->file != NULL) fclose(this->file);
- this->file = NULL;
+ if (this->file != nullptr) fclose(this->file);
+ this->file = nullptr;
/* Make sure we don't double free. */
- _sl.sf = NULL;
+ _sl.sf = nullptr;
}
size_t Read(byte *buf, size_t size) override
{
/* We're in the process of shutting down, i.e. in "failure" mode. */
- if (this->file == NULL) return 0;
+ if (this->file == nullptr) return 0;
return fread(buf, 1, size, this->file);
}
@@ -1874,7 +1874,7 @@ struct FileWriter : SaveFilter {
* Create the file writer, so it writes to a specific file.
* @param file The file to write to.
*/
- FileWriter(FILE *file) : SaveFilter(NULL), file(file)
+ FileWriter(FILE *file) : SaveFilter(nullptr), file(file)
{
}
@@ -1884,21 +1884,21 @@ struct FileWriter : SaveFilter {
this->Finish();
/* Make sure we don't double free. */
- _sl.sf = NULL;
+ _sl.sf = nullptr;
}
void Write(byte *buf, size_t size) override
{
/* We're in the process of shutting down, i.e. in "failure" mode. */
- if (this->file == NULL) return;
+ if (this->file == nullptr) return;
if (fwrite(buf, 1, size, this->file) != size) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_WRITEABLE);
}
void Finish() override
{
- if (this->file != NULL) fclose(this->file);
- this->file = NULL;
+ if (this->file != nullptr) fclose(this->file);
+ this->file = nullptr;
}
};
@@ -1953,7 +1953,7 @@ struct LZOLoadFilter : LoadFilter {
if (tmp[0] != lzo_adler32(0, out, size + sizeof(uint32))) SlErrorCorrupt("Bad checksum");
/* Decompress */
- int ret = lzo1x_decompress_safe(out + sizeof(uint32) * 1, size, buf, &len, NULL);
+ int ret = lzo1x_decompress_safe(out + sizeof(uint32) * 1, size, buf, &len, nullptr);
if (ret != LZO_E_OK) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE);
return len;
}
@@ -2147,7 +2147,7 @@ struct ZlibSaveFilter : SaveFilter {
void Finish() override
{
- this->WriteLoop(NULL, 0, Z_FINISH);
+ this->WriteLoop(nullptr, 0, Z_FINISH);
this->chain->Finish();
}
};
@@ -2266,7 +2266,7 @@ struct LZMASaveFilter : SaveFilter {
void Finish() override
{
- this->WriteLoop(NULL, 0, LZMA_FINISH);
+ this->WriteLoop(nullptr, 0, LZMA_FINISH);
this->chain->Finish();
}
};
@@ -2296,7 +2296,7 @@ static const SaveLoadFormat _saveload_formats[] = {
/* Roughly 75% larger than zlib level 6 at only ~7% of the CPU usage. */
{"lzo", TO_BE32X('OTTD'), CreateLoadFilter<LZOLoadFilter>, CreateSaveFilter<LZOSaveFilter>, 0, 0, 0},
#else
- {"lzo", TO_BE32X('OTTD'), NULL, NULL, 0, 0, 0},
+ {"lzo", TO_BE32X('OTTD'), nullptr, nullptr, 0, 0, 0},
#endif
/* Roughly 5 times larger at only 1% of the CPU usage over zlib level 6. */
{"none", TO_BE32X('OTTN'), CreateLoadFilter<NoCompLoadFilter>, CreateSaveFilter<NoCompSaveFilter>, 0, 0, 0},
@@ -2306,7 +2306,7 @@ static const SaveLoadFormat _saveload_formats[] = {
* 1 is "only" 3 times as fast. Level 0 results in uncompressed savegames at about 8 times the cost of "none". */
{"zlib", TO_BE32X('OTTZ'), CreateLoadFilter<ZlibLoadFilter>, CreateSaveFilter<ZlibSaveFilter>, 0, 6, 9},
#else
- {"zlib", TO_BE32X('OTTZ'), NULL, NULL, 0, 0, 0},
+ {"zlib", TO_BE32X('OTTZ'), nullptr, nullptr, 0, 0, 0},
#endif
#if defined(WITH_LIBLZMA)
/* Level 2 compression is speed wise as fast as zlib level 6 compression (old default), but results in ~10% smaller saves.
@@ -2316,14 +2316,14 @@ static const SaveLoadFormat _saveload_formats[] = {
* It's OTTX and not e.g. OTTL because liblzma is part of xz-utils and .tar.xz is preferred over .tar.lzma. */
{"lzma", TO_BE32X('OTTX'), CreateLoadFilter<LZMALoadFilter>, CreateSaveFilter<LZMASaveFilter>, 0, 2, 9},
#else
- {"lzma", TO_BE32X('OTTX'), NULL, NULL, 0, 0, 0},
+ {"lzma", TO_BE32X('OTTX'), nullptr, nullptr, 0, 0, 0},
#endif
};
/**
* Return the savegameformat of the game. Whether it was created with ZLIB compression
* uncompressed, or another type
- * @param s Name of the savegame format. If NULL it picks the first available one
+ * @param s Name of the savegame format. If nullptr it picks the first available one
* @param compression_level Output for telling what compression level we want.
* @return Pointer to SaveLoadFormat struct giving all characteristics of this type of savegame
*/
@@ -2337,12 +2337,12 @@ static const SaveLoadFormat *GetSavegameFormat(char *s, byte *compression_level)
if (!StrEmpty(s)) {
/* Get the ":..." of the compression level out of the way */
char *complevel = strrchr(s, ':');
- if (complevel != NULL) *complevel = '\0';
+ if (complevel != nullptr) *complevel = '\0';
for (const SaveLoadFormat *slf = &_saveload_formats[0]; slf != endof(_saveload_formats); slf++) {
- if (slf->init_write != NULL && strcmp(s, slf->name) == 0) {
+ if (slf->init_write != nullptr && strcmp(s, slf->name) == 0) {
*compression_level = slf->default_compression;
- if (complevel != NULL) {
+ if (complevel != nullptr) {
/* There is a compression level in the string.
* First restore the : we removed to do proper name matching,
* then move the the begin of the actual version. */
@@ -2368,7 +2368,7 @@ static const SaveLoadFormat *GetSavegameFormat(char *s, byte *compression_level)
ShowErrorMessage(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_SAVEGAME_COMPRESSION_ALGORITHM, WL_CRITICAL);
/* Restore the string by adding the : back */
- if (complevel != NULL) *complevel = ':';
+ if (complevel != nullptr) *complevel = ':';
}
*compression_level = def->default_compression;
return def;
@@ -2385,16 +2385,16 @@ extern bool LoadOldSaveGame(const char *file);
static inline void ClearSaveLoadState()
{
delete _sl.dumper;
- _sl.dumper = NULL;
+ _sl.dumper = nullptr;
delete _sl.sf;
- _sl.sf = NULL;
+ _sl.sf = nullptr;
delete _sl.reader;
- _sl.reader = NULL;
+ _sl.reader = nullptr;
delete _sl.lf;
- _sl.lf = NULL;
+ _sl.lf = nullptr;
}
/**
@@ -2614,7 +2614,7 @@ static SaveOrLoadResult DoLoad(LoadFilter *reader, bool load_check)
}
/* loader for this savegame type is not implemented? */
- if (fmt->init_load == NULL) {
+ if (fmt->init_load == nullptr) {
char err_str[64];
seprintf(err_str, lastof(err_str), "Loader for '%s' is not available.", fmt->name);
SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, err_str);
@@ -2769,11 +2769,11 @@ SaveOrLoadResult SaveOrLoad(const char *filename, SaveLoadOperation fop, Detaile
FILE *fh = (fop == SLO_SAVE) ? FioFOpenFile(filename, "wb", sb) : FioFOpenFile(filename, "rb", sb);
/* Make it a little easier to load savegames from the console */
- if (fh == NULL && fop != SLO_SAVE) fh = FioFOpenFile(filename, "rb", SAVE_DIR);
- if (fh == NULL && fop != SLO_SAVE) fh = FioFOpenFile(filename, "rb", BASE_DIR);
- if (fh == NULL && fop != SLO_SAVE) fh = FioFOpenFile(filename, "rb", SCENARIO_DIR);
+ if (fh == nullptr && fop != SLO_SAVE) fh = FioFOpenFile(filename, "rb", SAVE_DIR);
+ if (fh == nullptr && fop != SLO_SAVE) fh = FioFOpenFile(filename, "rb", BASE_DIR);
+ if (fh == nullptr && fop != SLO_SAVE) fh = FioFOpenFile(filename, "rb", SCENARIO_DIR);
- if (fh == NULL) {
+ if (fh == nullptr) {
SlError(fop == SLO_SAVE ? STR_GAME_SAVELOAD_ERROR_FILE_NOT_WRITEABLE : STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE);
}
diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h
index 07d45fafd..966de0c8a 100644
--- a/src/saveload/saveload.h
+++ b/src/saveload/saveload.h
@@ -641,11 +641,11 @@ typedef SaveLoad SaveLoadGlobVarList;
/** Translate values ingame to different values in the savegame and vv. */
#define SLE_WRITEBYTE(base, variable) SLE_GENERAL(SL_WRITEBYTE, base, variable, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION)
-#define SLE_VEH_INCLUDE() {false, SL_VEH_INCLUDE, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, NULL, 0}
-#define SLE_ST_INCLUDE() {false, SL_ST_INCLUDE, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, NULL, 0}
+#define SLE_VEH_INCLUDE() {false, SL_VEH_INCLUDE, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, nullptr, 0}
+#define SLE_ST_INCLUDE() {false, SL_ST_INCLUDE, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, nullptr, 0}
/** End marker of a struct/class save or load. */
-#define SLE_END() {false, SL_END, 0, 0, SL_MIN_VERSION, SL_MIN_VERSION, NULL, 0}
+#define SLE_END() {false, SL_END, 0, 0, SL_MIN_VERSION, SL_MIN_VERSION, nullptr, 0}
/**
* Storage of global simple variables, references (pointers), and arrays.
@@ -746,10 +746,10 @@ typedef SaveLoad SaveLoadGlobVarList;
* @param from First savegame version that has the empty space.
* @param to Last savegame version that has the empty space.
*/
-#define SLEG_CONDNULL(length, from, to) {true, SL_ARR, SLE_FILE_U8 | SLE_VAR_NULL | SLF_NOT_IN_CONFIG, length, from, to, (void*)NULL}
+#define SLEG_CONDNULL(length, from, to) {true, SL_ARR, SLE_FILE_U8 | SLE_VAR_NULL | SLF_NOT_IN_CONFIG, length, from, to, (void*)nullptr}
/** End marker of global variables save or load. */
-#define SLEG_END() {true, SL_END, 0, 0, SL_MIN_VERSION, SL_MIN_VERSION, NULL, 0}
+#define SLEG_END() {true, SL_END, 0, 0, SL_MIN_VERSION, SL_MIN_VERSION, nullptr, 0}
/**
* Checks whether the savegame is below \a major.\a minor.
@@ -813,13 +813,13 @@ static inline bool IsNumericType(VarType conv)
/**
* Get the address of the variable. Which one to pick depends on the object
- * pointer. If it is NULL we are dealing with global variables so the address
+ * pointer. If it is nullptr we are dealing with global variables so the address
* is taken. If non-null only the offset is stored in the union and we need
* to add this to the address of the object
*/
static inline void *GetVariableAddress(const void *object, const SaveLoad *sld)
{
- return const_cast<byte *>((const byte*)(sld->global ? NULL : object) + (ptrdiff_t)sld->address);
+ return const_cast<byte *>((const byte*)(sld->global ? nullptr : object) + (ptrdiff_t)sld->address);
}
int64 ReadValue(const void *ptr, VarType conv);
@@ -841,7 +841,7 @@ void SlGlobList(const SaveLoadGlobVarList *sldg);
void SlArray(void *array, size_t length, VarType conv);
void SlObject(void *object, const SaveLoad *sld);
bool SlObjectMember(void *object, const SaveLoad *sld);
-void NORETURN SlError(StringID string, const char *extra_msg = NULL);
+void NORETURN SlError(StringID string, const char *extra_msg = nullptr);
void NORETURN SlErrorCorrupt(const char *msg);
void NORETURN SlErrorCorruptFmt(const char *format, ...);
diff --git a/src/saveload/saveload_filter.h b/src/saveload/saveload_filter.h
index 0cb5c8695..ace9182d3 100644
--- a/src/saveload/saveload_filter.h
+++ b/src/saveload/saveload_filter.h
@@ -89,7 +89,7 @@ struct SaveFilter {
*/
virtual void Finish()
{
- if (this->chain != NULL) this->chain->Finish();
+ if (this->chain != nullptr) this->chain->Finish();
}
};
diff --git a/src/saveload/signs_sl.cpp b/src/saveload/signs_sl.cpp
index 545c628b3..f2ec21d94 100644
--- a/src/saveload/signs_sl.cpp
+++ b/src/saveload/signs_sl.cpp
@@ -68,5 +68,5 @@ static void Load_SIGN()
/** Chunk handlers related to signs. */
extern const ChunkHandler _sign_chunk_handlers[] = {
- { 'SIGN', Save_SIGN, Load_SIGN, NULL, NULL, CH_ARRAY | CH_LAST},
+ { 'SIGN', Save_SIGN, Load_SIGN, nullptr, nullptr, CH_ARRAY | CH_LAST},
};
diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp
index 995483ee6..40b5fb0e9 100644
--- a/src/saveload/station_sl.cpp
+++ b/src/saveload/station_sl.cpp
@@ -47,7 +47,7 @@ void MoveBuoysToWaypoints()
VehicleType vt = ol->GetFirstSharedVehicle()->type;
if (vt != VEH_SHIP && vt != VEH_TRAIN) continue;
- for (Order *o = ol->GetFirstOrder(); o != NULL; o = o->next) UpdateWaypointOrder(o);
+ for (Order *o = ol->GetFirstOrder(); o != nullptr; o = o->next) UpdateWaypointOrder(o);
}
Vehicle *v;
@@ -68,7 +68,7 @@ void MoveBuoysToWaypoints()
Town *town = st->town;
StringID string_id = st->string_id;
char *name = st->name;
- st->name = NULL;
+ st->name = nullptr;
Date build_date = st->build_date;
/* TTDPatch could use "buoys with rail station" for rail waypoints */
bool train = st->train_station.tile != INVALID_TILE;
@@ -116,13 +116,13 @@ void AfterLoadStations()
for (uint i = 0; i < st->num_specs; i++) {
if (st->speclist[i].grfid == 0) continue;
- st->speclist[i].spec = StationClass::GetByGrf(st->speclist[i].grfid, st->speclist[i].localidx, NULL);
+ st->speclist[i].spec = StationClass::GetByGrf(st->speclist[i].grfid, st->speclist[i].localidx, nullptr);
}
if (Station::IsExpected(st)) {
Station *sta = Station::From(st);
- for (const RoadStop *rs = sta->bus_stops; rs != NULL; rs = rs->next) sta->bus_station.Add(rs->xy);
- for (const RoadStop *rs = sta->truck_stops; rs != NULL; rs = rs->next) sta->truck_station.Add(rs->xy);
+ for (const RoadStop *rs = sta->bus_stops; rs != nullptr; rs = rs->next) sta->bus_station.Add(rs->xy);
+ for (const RoadStop *rs = sta->truck_stops; rs != nullptr; rs = rs->next) sta->truck_station.Add(rs->xy);
}
StationUpdateCachedTriggers(st);
@@ -544,11 +544,11 @@ static void Load_STNN()
for (CargoID i = 0; i < num_cargo; i++) {
SlObject(&st->goods[i], GetGoodsDesc());
FlowSaveLoad flow;
- FlowStat *fs = NULL;
+ FlowStat *fs = nullptr;
StationID prev_source = INVALID_STATION;
for (uint32 j = 0; j < _num_flows; ++j) {
SlObject(&flow, _flow_desc);
- if (fs == NULL || prev_source != flow.source) {
+ if (fs == nullptr || prev_source != flow.source) {
fs = &(st->goods[i].flows.insert(std::make_pair(flow.source, FlowStat(flow.via, flow.share, flow.restricted))).first->second);
} else {
fs->AppendShare(flow.via, flow.share, flow.restricted);
@@ -638,7 +638,7 @@ static void Ptrs_ROADSTOP()
}
extern const ChunkHandler _station_chunk_handlers[] = {
- { 'STNS', NULL, Load_STNS, Ptrs_STNS, NULL, CH_ARRAY },
- { 'STNN', Save_STNN, Load_STNN, Ptrs_STNN, NULL, CH_ARRAY },
- { 'ROAD', Save_ROADSTOP, Load_ROADSTOP, Ptrs_ROADSTOP, NULL, CH_ARRAY | CH_LAST},
+ { 'STNS', nullptr, Load_STNS, Ptrs_STNS, nullptr, CH_ARRAY },
+ { 'STNN', Save_STNN, Load_STNN, Ptrs_STNN, nullptr, CH_ARRAY },
+ { 'ROAD', Save_ROADSTOP, Load_ROADSTOP, Ptrs_ROADSTOP, nullptr, CH_ARRAY | CH_LAST},
};
diff --git a/src/saveload/storage_sl.cpp b/src/saveload/storage_sl.cpp
index 1396d25ae..fafc35cb1 100644
--- a/src/saveload/storage_sl.cpp
+++ b/src/saveload/storage_sl.cpp
@@ -50,5 +50,5 @@ static void Save_PSAC()
/** Chunk handler for persistent storages. */
extern const ChunkHandler _persistent_storage_chunk_handlers[] = {
- { 'PSAC', Save_PSAC, Load_PSAC, NULL, NULL, CH_ARRAY | CH_LAST},
+ { 'PSAC', Save_PSAC, Load_PSAC, nullptr, nullptr, CH_ARRAY | CH_LAST},
};
diff --git a/src/saveload/story_sl.cpp b/src/saveload/story_sl.cpp
index f9bbf34b9..8cca9aed7 100644
--- a/src/saveload/story_sl.cpp
+++ b/src/saveload/story_sl.cpp
@@ -102,6 +102,6 @@ static void Load_STORY_PAGE()
}
extern const ChunkHandler _story_page_chunk_handlers[] = {
- { 'STPE', Save_STORY_PAGE_ELEMENT, Load_STORY_PAGE_ELEMENT, NULL, NULL, CH_ARRAY},
- { 'STPA', Save_STORY_PAGE, Load_STORY_PAGE, NULL, NULL, CH_ARRAY | CH_LAST},
+ { 'STPE', Save_STORY_PAGE_ELEMENT, Load_STORY_PAGE_ELEMENT, nullptr, nullptr, CH_ARRAY},
+ { 'STPA', Save_STORY_PAGE, Load_STORY_PAGE, nullptr, nullptr, CH_ARRAY | CH_LAST},
};
diff --git a/src/saveload/strings_sl.cpp b/src/saveload/strings_sl.cpp
index d8fe81d11..9e0351ae0 100644
--- a/src/saveload/strings_sl.cpp
+++ b/src/saveload/strings_sl.cpp
@@ -49,7 +49,7 @@ StringID RemapOldStringID(StringID s)
}
/** Location to load the old names to. */
-char *_old_name_array = NULL;
+char *_old_name_array = nullptr;
/**
* Copy and convert old custom names to UTF-8.
@@ -61,7 +61,7 @@ char *_old_name_array = NULL;
char *CopyFromOldName(StringID id)
{
/* Is this name an (old) custom name? */
- if (GetStringTab(id) != TEXT_TAB_OLD_CUSTOM) return NULL;
+ if (GetStringTab(id) != TEXT_TAB_OLD_CUSTOM) return nullptr;
if (IsSavegameVersionBefore(SLV_37)) {
/* Allow for expansion when converted to UTF-8. */
@@ -109,7 +109,7 @@ char *CopyFromOldName(StringID id)
void ResetOldNames()
{
free(_old_name_array);
- _old_name_array = NULL;
+ _old_name_array = nullptr;
}
/**
@@ -140,5 +140,5 @@ static void Load_NAME()
/** Chunk handlers related to strings. */
extern const ChunkHandler _name_chunk_handlers[] = {
- { 'NAME', NULL, Load_NAME, NULL, NULL, CH_ARRAY | CH_LAST},
+ { 'NAME', nullptr, Load_NAME, nullptr, nullptr, CH_ARRAY | CH_LAST},
};
diff --git a/src/saveload/subsidy_sl.cpp b/src/saveload/subsidy_sl.cpp
index 6f10ec8d0..536ec2145 100644
--- a/src/saveload/subsidy_sl.cpp
+++ b/src/saveload/subsidy_sl.cpp
@@ -48,5 +48,5 @@ static void Load_SUBS()
}
extern const ChunkHandler _subsidy_chunk_handlers[] = {
- { 'SUBS', Save_SUBS, Load_SUBS, NULL, NULL, CH_ARRAY | CH_LAST},
+ { 'SUBS', Save_SUBS, Load_SUBS, nullptr, nullptr, CH_ARRAY | CH_LAST},
};
diff --git a/src/saveload/town_sl.cpp b/src/saveload/town_sl.cpp
index bc2ed8be6..c85bb4a82 100644
--- a/src/saveload/town_sl.cpp
+++ b/src/saveload/town_sl.cpp
@@ -321,6 +321,6 @@ static void Ptrs_TOWN()
/** Chunk handler for towns. */
extern const ChunkHandler _town_chunk_handlers[] = {
- { 'HIDS', Save_HIDS, Load_HIDS, NULL, NULL, CH_ARRAY },
- { 'CITY', Save_TOWN, Load_TOWN, Ptrs_TOWN, NULL, CH_ARRAY | CH_LAST},
+ { 'HIDS', Save_HIDS, Load_HIDS, nullptr, nullptr, CH_ARRAY },
+ { 'CITY', Save_TOWN, Load_TOWN, Ptrs_TOWN, nullptr, CH_ARRAY | CH_LAST},
};
diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp
index 058587139..c42e3938f 100644
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -36,7 +36,7 @@ void ConnectMultiheadedTrains()
Train *v;
FOR_ALL_TRAINS(v) {
- v->other_multiheaded_part = NULL;
+ v->other_multiheaded_part = nullptr;
}
FOR_ALL_TRAINS(v) {
@@ -56,8 +56,8 @@ void ConnectMultiheadedTrains()
bool sequential_matching = v->IsFrontEngine();
- for (Train *u = v; u != NULL; u = u->GetNextVehicle()) {
- if (u->other_multiheaded_part != NULL) continue; // we already linked this one
+ for (Train *u = v; u != nullptr; u = u->GetNextVehicle()) {
+ if (u->other_multiheaded_part != nullptr) continue; // we already linked this one
if (u->IsMultiheaded()) {
if (!u->IsEngine()) {
@@ -70,8 +70,8 @@ void ConnectMultiheadedTrains()
EngineID eid = u->engine_type;
Train *w;
if (sequential_matching) {
- for (w = u->GetNextVehicle(); w != NULL; w = w->GetNextVehicle()) {
- if (w->engine_type != eid || w->other_multiheaded_part != NULL || !w->IsMultiheaded()) continue;
+ for (w = u->GetNextVehicle(); w != nullptr; w = w->GetNextVehicle()) {
+ if (w->engine_type != eid || w->other_multiheaded_part != nullptr || !w->IsMultiheaded()) continue;
/* we found a car to partner with this engine. Now we will make sure it face the right way */
if (w->IsEngine()) {
@@ -82,8 +82,8 @@ void ConnectMultiheadedTrains()
}
} else {
uint stack_pos = 0;
- for (w = u->GetNextVehicle(); w != NULL; w = w->GetNextVehicle()) {
- if (w->engine_type != eid || w->other_multiheaded_part != NULL || !w->IsMultiheaded()) continue;
+ for (w = u->GetNextVehicle(); w != nullptr; w = w->GetNextVehicle()) {
+ if (w->engine_type != eid || w->other_multiheaded_part != nullptr || !w->IsMultiheaded()) continue;
if (w->IsEngine()) {
stack_pos++;
@@ -94,7 +94,7 @@ void ConnectMultiheadedTrains()
}
}
- if (w != NULL) {
+ if (w != nullptr) {
w->other_multiheaded_part = u;
u->other_multiheaded_part = w;
} else {
@@ -118,7 +118,7 @@ void ConvertOldMultiheadToNew()
FOR_ALL_TRAINS(t) {
if (HasBit(t->subtype, 7) && ((t->subtype & ~0x80) == 0 || (t->subtype & ~0x80) == 4)) {
- for (Train *u = t; u != NULL; u = u->Next()) {
+ for (Train *u = t; u != nullptr; u = u->Next()) {
const RailVehicleInfo *rvi = RailVehInfo(u->engine_type);
ClrBit(u->subtype, 7);
@@ -200,7 +200,7 @@ void UpdateOldAircraft()
if (a->subtype == AIR_HELICOPTER) a->Next()->Next()->cur_speed = 32;
/* set new position x,y,z */
- GetAircraftFlightLevelBounds(a, &a->z_pos, NULL);
+ GetAircraftFlightLevelBounds(a, &a->z_pos, nullptr);
SetAircraftPosition(a, gp.x, gp.y, GetAircraftFlightLevel(a));
}
}
@@ -252,11 +252,11 @@ void AfterLoadVehicles(bool part_of_load)
FOR_ALL_VEHICLES(v) {
/* Reinstate the previous pointer */
- if (v->Next() != NULL) v->Next()->previous = v;
- if (v->NextShared() != NULL) v->NextShared()->previous_shared = v;
+ if (v->Next() != nullptr) v->Next()->previous = v;
+ if (v->NextShared() != nullptr) v->NextShared()->previous_shared = v;
if (part_of_load) v->fill_percent_te_id = INVALID_TE_ID;
- v->first = NULL;
+ v->first = nullptr;
if (v->IsGroundVehicle()) v->GetGroundVehicleCache()->first_engine = INVALID_ENGINE;
}
@@ -272,9 +272,9 @@ void AfterLoadVehicles(bool part_of_load)
std::map<Order*, OrderList*> mapping;
FOR_ALL_VEHICLES(v) {
- if (v->orders.old != NULL) {
+ if (v->orders.old != nullptr) {
if (IsSavegameVersionBefore(SLV_105)) { // Pre-105 didn't save an OrderList
- if (mapping[v->orders.old] == NULL) {
+ if (mapping[v->orders.old] == nullptr) {
/* This adds the whole shared vehicle chain for case b */
/* Creating an OrderList here is safe because the number of vehicles
@@ -290,7 +290,7 @@ void AfterLoadVehicles(bool part_of_load)
}
}
} else { // OrderList was saved as such, only recalculate not saved values
- if (v->PreviousShared() == NULL) {
+ if (v->PreviousShared() == nullptr) {
v->orders.list->Initialize(v->orders.list->first, v);
}
}
@@ -300,8 +300,8 @@ void AfterLoadVehicles(bool part_of_load)
FOR_ALL_VEHICLES(v) {
/* Fill the first pointers */
- if (v->Previous() == NULL) {
- for (Vehicle *u = v; u != NULL; u = u->Next()) {
+ if (v->Previous() == nullptr) {
+ for (Vehicle *u = v; u != nullptr; u = u->Next()) {
u->first = v;
}
}
@@ -311,12 +311,12 @@ void AfterLoadVehicles(bool part_of_load)
if (IsSavegameVersionBefore(SLV_105)) {
/* Before 105 there was no order for shared orders, thus it messed up horribly */
FOR_ALL_VEHICLES(v) {
- if (v->First() != v || v->orders.list != NULL || v->previous_shared != NULL || v->next_shared == NULL) continue;
+ if (v->First() != v || v->orders.list != nullptr || v->previous_shared != nullptr || v->next_shared == nullptr) continue;
/* As above, allocating OrderList here is safe. */
assert(OrderList::CanAllocateItem());
- v->orders.list = new OrderList(NULL, v);
- for (Vehicle *u = v; u != NULL; u = u->next_shared) {
+ v->orders.list = new OrderList(nullptr, v);
+ for (Vehicle *u = v; u != nullptr; u = u->next_shared) {
u->orders.list = v->orders.list;
}
}
@@ -392,9 +392,9 @@ void AfterLoadVehicles(bool part_of_load)
CheckValidVehicles();
FOR_ALL_VEHICLES(v) {
- assert(v->first != NULL);
+ assert(v->first != nullptr);
- v->trip_occupancy = CalcPercentVehicleFilled(v, NULL);
+ v->trip_occupancy = CalcPercentVehicleFilled(v, nullptr);
switch (v->type) {
case VEH_TRAIN: {
@@ -502,7 +502,7 @@ void FixupTrainLengths()
/* The vehicle center is now more to the front depending on vehicle length,
* so we need to move all vehicles forward to cover the difference to the
* old center, otherwise wagon spacing in trains would be broken upon load. */
- for (Train *u = Train::From(v); u != NULL; u = u->Next()) {
+ for (Train *u = Train::From(v); u != nullptr; u = u->Next()) {
if (u->track == TRACK_BIT_DEPOT || (u->vehstatus & VS_CRASHED)) continue;
Train *next = u->Next();
@@ -514,7 +514,7 @@ void FixupTrainLengths()
if (!TrainController(u, next, false)) break;
}
- if (next != NULL && done < diff && u->IsFrontEngine()) {
+ if (next != nullptr && done < diff && u->IsFrontEngine()) {
/* Pulling the front vehicle forwards failed, we either encountered a dead-end
* or a red signal. To fix this, we try to move the whole train the required
* space backwards and re-do the fix up of the front vehicle. */
@@ -530,14 +530,14 @@ void FixupTrainLengths()
/* We moved the first vehicle which is now the last. Move it back to the
* original position as we will fix up the last vehicle later in the loop. */
- for (int i = 0; i < done; i++) TrainController(u->Last(), NULL);
+ for (int i = 0; i < done; i++) TrainController(u->Last(), nullptr);
/* Move the train backwards to get space for the first vehicle. As the stopping
* distance from a line end is rounded up, move the train one unit more to cater
* for front vehicles with odd lengths. */
int moved;
for (moved = 0; moved < diff + 1; moved++) {
- if (!TrainController(u, NULL, false)) break;
+ if (!TrainController(u, nullptr, false)) break;
}
/* Swap start<>end, start+1<>end-1, ... again. */
@@ -556,17 +556,17 @@ void FixupTrainLengths()
/* We moved one unit more backwards than needed for even-length front vehicles,
* try to move that unit forward again. We don't care if this step fails. */
- TrainController(u, NULL, false);
+ TrainController(u, nullptr, false);
}
/* If the next wagon is still in a depot, check if it shouldn't be outside already. */
- if (next != NULL && next->track == TRACK_BIT_DEPOT) {
+ if (next != nullptr && next->track == TRACK_BIT_DEPOT) {
int d = TicksToLeaveDepot(u);
if (d <= 0) {
/* Next vehicle should have left the depot already, show it and pull forward. */
next->vehstatus &= ~VS_HIDDEN;
next->track = TrackToTrackBits(GetRailDepotTrack(next->tile));
- for (int i = 0; i >= d; i--) TrainController(next, NULL);
+ for (int i = 0; i >= d; i--) TrainController(next, nullptr);
}
}
}
@@ -960,5 +960,5 @@ static void Ptrs_VEHS()
}
extern const ChunkHandler _veh_chunk_handlers[] = {
- { 'VEHS', Save_VEHS, Load_VEHS, Ptrs_VEHS, NULL, CH_SPARSE_ARRAY | CH_LAST},
+ { 'VEHS', Save_VEHS, Load_VEHS, Ptrs_VEHS, nullptr, CH_SPARSE_ARRAY | CH_LAST},
};
diff --git a/src/saveload/waypoint_sl.cpp b/src/saveload/waypoint_sl.cpp
index 167086467..66ef145fc 100644
--- a/src/saveload/waypoint_sl.cpp
+++ b/src/saveload/waypoint_sl.cpp
@@ -88,7 +88,7 @@ void MoveWaypointsToBaseStations()
StationClass* stclass = StationClass::Get(STAT_CLASS_WAYP);
for (uint i = 0; i < stclass->GetSpecCount(); i++) {
const StationSpec *statspec = stclass->GetSpec(i);
- if (statspec != NULL && statspec->grf_prop.grffile->grfid == wp.grfid && statspec->grf_prop.local_id == wp.localidx) {
+ if (statspec != nullptr && statspec->grf_prop.grffile->grfid == wp.grfid && statspec->grf_prop.local_id == wp.localidx) {
wp.spec = statspec;
break;
}
@@ -122,7 +122,7 @@ void MoveWaypointsToBaseStations()
SetRailStationReservation(t, reserved);
- if (wp.spec != NULL) {
+ if (wp.spec != nullptr) {
SetCustomStationSpecIndex(t, AllocateSpecToStation(wp.spec, new_wp, true));
}
new_wp->rect.BeforeAddTile(t, StationRect::ADD_FORCE);
@@ -136,7 +136,7 @@ void MoveWaypointsToBaseStations()
FOR_ALL_ORDER_LISTS(ol) {
if (ol->GetFirstSharedVehicle()->type != VEH_TRAIN) continue;
- for (Order *o = ol->GetFirstOrder(); o != NULL; o = o->next) UpdateWaypointOrder(o);
+ for (Order *o = ol->GetFirstOrder(); o != nullptr; o = o->next) UpdateWaypointOrder(o);
}
Vehicle *v;
@@ -199,10 +199,10 @@ static void Ptrs_WAYP()
/* Only for versions 12 .. 122 */
if (!Town::IsValidID(wp.town_index)) {
/* Upon a corrupted waypoint we'll likely get here. The next step will be to
- * loop over all Ptrs procs to NULL the pointers. However, we don't know
- * whether we're in the NULL or "normal" Ptrs proc. So just clear the list
+ * loop over all Ptrs procs to nullptr the pointers. However, we don't know
+ * whether we're in the nullptr or "normal" Ptrs proc. So just clear the list
* of old waypoints we constructed and then this waypoint (and the other
- * possibly corrupt ones) will not be queried in the NULL Ptrs proc run. */
+ * possibly corrupt ones) will not be queried in the nullptr Ptrs proc run. */
_old_waypoints.clear();
SlErrorCorrupt("Referencing invalid Town");
}
@@ -215,5 +215,5 @@ static void Ptrs_WAYP()
}
extern const ChunkHandler _waypoint_chunk_handlers[] = {
- { 'CHKP', NULL, Load_WAYP, Ptrs_WAYP, NULL, CH_ARRAY | CH_LAST},
+ { 'CHKP', nullptr, Load_WAYP, Ptrs_WAYP, nullptr, CH_ARRAY | CH_LAST},
};