Codechange: Use null pointer literal instead of the NULL macro
This commit is contained in:

committed by
Michael Lutz

parent
3b4f224c0b
commit
7c8e7c6b6e
@@ -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)) {
|
||||
|
Reference in New Issue
Block a user