Merge: Codechange: Use null pointer literal instead of the NULL macro

This commit is contained in:
Jonathan G Rennison
2019-04-11 18:14:13 +01:00
585 changed files with 6604 additions and 6604 deletions

View File

@@ -89,14 +89,14 @@ bool RoadVehicle::IsBus() const
/**
* Get the width of a road vehicle image in the GUI.
* @param offset Additional offset for positioning the sprite; set to NULL if not needed
* @param offset Additional offset for positioning the sprite; set to nullptr if not needed
* @return Width in pixels
*/
int RoadVehicle::GetDisplayImageWidth(Point *offset) const
{
int reference_width = ROADVEHINFO_DEFAULT_VEHICLE_WIDTH;
if (offset != NULL) {
if (offset != nullptr) {
offset->x = ScaleGUITrad(reference_width) / 2;
offset->y = 0;
}
@@ -193,7 +193,7 @@ static uint GetRoadVehLength(const RoadVehicle *v)
uint length = VEHICLE_LENGTH;
uint16 veh_len = CALLBACK_FAILED;
if (e->GetGRF() != NULL && e->GetGRF()->grf_version >= 8) {
if (e->GetGRF() != nullptr && e->GetGRF()->grf_version >= 8) {
/* Use callback 36 */
veh_len = GetVehicleProperty(v, PROP_ROADVEH_SHORTEN_FACTOR, CALLBACK_FAILED);
if (veh_len != CALLBACK_FAILED && veh_len >= VEHICLE_LENGTH) ErrorUnknownCallbackResult(e->GetGRFID(), CBID_VEHICLE_LENGTH, veh_len);
@@ -225,7 +225,7 @@ void RoadVehUpdateCache(RoadVehicle *v, bool same_length)
v->gcache.cached_total_length = 0;
Vehicle *last_vis_effect = v;
for (RoadVehicle *u = v; u != NULL; u = u->Next()) {
for (RoadVehicle *u = v; u != nullptr; u = u->Next()) {
/* Check the v->first cache. */
assert(u->First() == v);
@@ -323,7 +323,7 @@ CommandCost CmdBuildRoadVehicle(TileIndex tile, DoCommandFlag flags, const Engin
v->InvalidateNewGRFCacheOfChain();
/* Call various callbacks after the whole consist has been constructed */
for (RoadVehicle *u = v; u != NULL; u = u->Next()) {
for (RoadVehicle *u = v; u != nullptr; u = u->Next()) {
u->cargo_cap = u->GetEngine()->DetermineCapacity(u);
u->refit_cap = 0;
v->InvalidateNewGRFCache();
@@ -360,8 +360,8 @@ bool RoadVehicle::FindClosestDepot(TileIndex *location, DestinationID *destinati
FindDepotData rfdd = FindClosestRoadDepot(this, 0);
if (rfdd.best_length == UINT_MAX) return false;
if (location != NULL) *location = rfdd.tile;
if (destination != NULL) *destination = GetDepotIndex(rfdd.tile);
if (location != nullptr) *location = rfdd.tile;
if (destination != nullptr) *destination = GetDepotIndex(rfdd.tile);
return true;
}
@@ -378,7 +378,7 @@ bool RoadVehicle::FindClosestDepot(TileIndex *location, DestinationID *destinati
CommandCost CmdTurnRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
RoadVehicle *v = RoadVehicle::GetIfValid(p1);
if (v == NULL) return CMD_ERROR;
if (v == nullptr) return CMD_ERROR;
if (!v->IsPrimaryVehicle()) return CMD_ERROR;
@@ -406,7 +406,7 @@ CommandCost CmdTurnRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
void RoadVehicle::MarkDirty()
{
for (RoadVehicle *v = this; v != NULL; v = v->Next()) {
for (RoadVehicle *v = this; v != nullptr; v = v->Next()) {
v->colourmap = PAL_NONE;
v->cur_image_valid_dir = INVALID_DIR;
v->UpdateViewport(true, false);
@@ -466,7 +466,7 @@ inline int RoadVehicle::GetCurrentMaxSpeed() const
int max_speed = this->GetEffectiveMaxSpeed();
/* Limit speed to 50% while reversing, 75% in curves. */
for (const RoadVehicle *u = this; u != NULL; u = u->Next()) {
for (const RoadVehicle *u = this; u != nullptr; u = u->Next()) {
if (_settings_game.vehicle.roadveh_acceleration_model == AM_REALISTIC) {
if (this->state <= RVSB_TRACKDIR_MASK && IsReversingRoadTrackdir((Trackdir)this->state)) {
max_speed = this->vcache.cached_max_speed / 2;
@@ -493,8 +493,8 @@ static void DeleteLastRoadVeh(RoadVehicle *v)
{
RoadVehicle *first = v->First();
Vehicle *u = v;
for (; v->Next() != NULL; v = v->Next()) u = v;
u->SetNext(NULL);
for (; v->Next() != nullptr; v = v->Next()) u = v;
u->SetNext(nullptr);
v->last_station_visited = first->last_station_visited; // for PreDestructor
/* Only leave the road stop when we're really gone. */
@@ -514,7 +514,7 @@ static void RoadVehSetRandomDirection(RoadVehicle *v)
v->direction = ChangeDir(v->direction, delta[r & 3]);
v->UpdateViewport(true, true);
} while ((v = v->Next()) != NULL);
} while ((v = v->Next()) != nullptr);
}
/**
@@ -530,7 +530,7 @@ static bool RoadVehIsCrashed(RoadVehicle *v)
} else if (v->crashed_ctr <= 45) {
if ((v->tick_counter & 7) == 0) RoadVehSetRandomDirection(v);
} else if (v->crashed_ctr >= 2220 && !(v->tick_counter & 0x1F)) {
bool ret = v->Next() != NULL;
bool ret = v->Next() != nullptr;
DeleteLastRoadVeh(v);
return ret;
}
@@ -550,7 +550,7 @@ struct CheckRoadVehCrashTrainInfo {
* Check routine whether a road and a train vehicle have collided.
* @param v %Train vehicle to test.
* @param data Info including road vehicle to test.
* @return %Train vehicle if the vehicles collided, else \c NULL.
* @return %Train vehicle if the vehicles collided, else \c nullptr.
*/
static Vehicle *EnumCheckRoadVehCrashTrain(Vehicle *v, void *data)
{
@@ -565,7 +565,7 @@ static Vehicle *EnumCheckRoadVehCrashTrain(Vehicle *v, void *data)
TrainRoadVehicleCrashBreakdown(v);
return v;
} else {
return NULL;
return nullptr;
}
}
@@ -605,7 +605,7 @@ static void RoadVehCrash(RoadVehicle *v)
static bool RoadVehCheckTrainCrash(RoadVehicle *v)
{
for (RoadVehicle *u = v; u != NULL; u = u->Next()) {
for (RoadVehicle *u = v; u != nullptr; u = u->Next()) {
if (u->state == RVSB_WORMHOLE) continue;
TileIndex tile = u->tile;
@@ -684,7 +684,7 @@ static Vehicle *EnumCheckRoadVehClose(Vehicle *v, void *data)
}
}
return NULL;
return nullptr;
}
static RoadVehicle *RoadVehFindCloseTo(RoadVehicle *v, int x, int y, Direction dir, bool update_blocked_ctr = true)
@@ -692,7 +692,7 @@ static RoadVehicle *RoadVehFindCloseTo(RoadVehicle *v, int x, int y, Direction d
RoadVehFindData rvf;
RoadVehicle *front = v->First();
if (front->reverse_ctr != 0) return NULL;
if (front->reverse_ctr != 0) return nullptr;
rvf.x = x;
rvf.y = y;
@@ -713,13 +713,13 @@ static RoadVehicle *RoadVehFindCloseTo(RoadVehicle *v, int x, int y, Direction d
* It can be disabled. */
if (rvf.best_diff == UINT_MAX) {
front->blocked_ctr = 0;
return NULL;
return nullptr;
}
if (update_blocked_ctr && ++front->blocked_ctr > 1480) return NULL;
if (update_blocked_ctr && ++front->blocked_ctr > 1480) return nullptr;
RoadVehicle *rv = RoadVehicle::From(rvf.best);
if (rv != NULL && front->IsRoadVehicleOnLevelCrossing() && (rv->First()->cur_speed == 0 || rv->First()->IsRoadVehicleStopped())) return NULL;
if (rv != nullptr && front->IsRoadVehicleOnLevelCrossing() && (rv->First()->cur_speed == 0 || rv->First()->IsRoadVehicleStopped())) return nullptr;
return rv;
}
@@ -818,7 +818,7 @@ static Vehicle *EnumFindVehBlockingOvertake(Vehicle *v, void *data)
{
const OvertakeData *od = (OvertakeData*)data;
return (v->type == VEH_ROAD && v->First() == v && v != od->u && v != od->v) ? v : NULL;
return (v->type == VEH_ROAD && v->First() == v && v != od->u && v != od->v) ? v : nullptr;
}
/**
@@ -1055,7 +1055,7 @@ struct RoadDriveEntry {
static bool RoadVehLeaveDepot(RoadVehicle *v, bool first)
{
/* Don't leave unless v and following wagons are in the depot. */
for (const RoadVehicle *u = v; u != NULL; u = u->Next()) {
for (const RoadVehicle *u = v; u != nullptr; u = u->Next()) {
if (u->state != RVSB_IN_DEPOT || u->tile != v->tile) return false;
}
@@ -1075,7 +1075,7 @@ static bool RoadVehLeaveDepot(RoadVehicle *v, bool first)
return true;
}
if (RoadVehFindCloseTo(v, x, y, v->direction, false) != NULL) return true;
if (RoadVehFindCloseTo(v, x, y, v->direction, false) != nullptr) return true;
VehicleServiceInDepot(v);
@@ -1214,7 +1214,7 @@ bool IndividualRoadVehicleController(RoadVehicle *v, const RoadVehicle *prev)
if (v->IsFrontEngine()) {
const Vehicle *u = RoadVehFindCloseTo(v, gp.x, gp.y, v->direction);
if (u != NULL) {
if (u != nullptr) {
v->cur_speed = u->First()->cur_speed;
return false;
}
@@ -1301,7 +1301,7 @@ again:
return false;
}
};
if ((v->Previous() != NULL && v->Previous()->tile == tile) || (v->IsFrontEngine() && tile_turn_ok())) {
if ((v->Previous() != nullptr && v->Previous()->tile == tile) || (v->IsFrontEngine() && tile_turn_ok())) {
/*
* Taking the 'big' corner for trams only happens when:
* - The previous vehicle in this (articulated) tram chain is
@@ -1348,7 +1348,7 @@ again:
Direction new_dir = RoadVehGetSlidingDirection(v, x, y);
if (v->IsFrontEngine()) {
Vehicle *u = RoadVehFindCloseTo(v, x, y, new_dir);
if (u != NULL) {
if (u != nullptr) {
v->cur_speed = u->First()->cur_speed;
return false;
}
@@ -1451,7 +1451,7 @@ again:
int y = TileY(v->tile) * TILE_SIZE + rdp[turn_around_start_frame].y;
Direction new_dir = RoadVehGetSlidingDirection(v, x, y);
if (v->IsFrontEngine() && RoadVehFindCloseTo(v, x, y, new_dir) != NULL) return false;
if (v->IsFrontEngine() && RoadVehFindCloseTo(v, x, y, new_dir) != nullptr) return false;
uint32 r = VehicleEnterTile(v, v->tile, x, y);
if (HasBit(r, VETS_CANNOT_ENTER)) {
@@ -1478,7 +1478,7 @@ again:
/* This vehicle is not in a wormhole and it hasn't entered a new tile. If
* it's on a depot tile, check if it's time to activate the next vehicle in
* the chain yet. */
if (v->Next() != NULL && IsRoadDepotTile(v->tile)) {
if (v->Next() != nullptr && IsRoadDepotTile(v->tile)) {
if (v->frame == v->gcache.cached_veh_length + RVC_DEPOT_START_FRAME) {
RoadVehLeaveDepot(v->Next(), false);
}
@@ -1495,7 +1495,7 @@ again:
* Check for another vehicle to overtake */
RoadVehicle *u = RoadVehFindCloseTo(v, x, y, new_dir);
if (u != NULL) {
if (u != nullptr) {
u = u->First();
/* There is a vehicle in front overtake it if possible */
if (v->overtaking == 0) RoadVehCheckOvertake(v, u);
@@ -1652,7 +1652,7 @@ static bool RoadVehController(RoadVehicle *v)
j -= adv_spd;
RoadVehicle *u = v;
for (RoadVehicle *prev = NULL; u != NULL; prev = u, u = u->Next()) {
for (RoadVehicle *prev = nullptr; u != nullptr; prev = u, u = u->Next()) {
if (!IndividualRoadVehicleController(u, prev)) {
blocked = true;
break;
@@ -1669,7 +1669,7 @@ static bool RoadVehController(RoadVehicle *v)
v->SetLastSpeed();
for (RoadVehicle *u = v; u != NULL; u = u->Next()) {
for (RoadVehicle *u = v; u != nullptr; u = u->Next()) {
if (!(u->IsDrawn())) continue;
u->UpdateViewport(false, false);