Merge: Codechange: Use null pointer literal instead of the NULL macro
This commit is contained in:
276
src/vehicle.cpp
276
src/vehicle.cpp
@@ -176,10 +176,10 @@ bool Vehicle::NeedsAutorenewing(const Company *c, bool use_renew_setting) const
|
||||
*/
|
||||
void VehicleServiceInDepot(Vehicle *v)
|
||||
{
|
||||
assert(v != NULL);
|
||||
assert(v != nullptr);
|
||||
const Engine *e = Engine::Get(v->engine_type);
|
||||
if (v->type == VEH_TRAIN) {
|
||||
if (v->Next() != NULL) VehicleServiceInDepot(v->Next());
|
||||
if (v->Next() != nullptr) VehicleServiceInDepot(v->Next());
|
||||
if (!(Train::From(v)->IsEngine()) && !(Train::From(v)->IsRearDualheaded())) return;
|
||||
ClrBit(Train::From(v)->flags, VRF_NEED_REPAIR);
|
||||
ClrBit(Train::From(v)->flags, VRF_HAS_HIT_RV);
|
||||
@@ -209,7 +209,7 @@ void VehicleServiceInDepot(Vehicle *v)
|
||||
v->breakdown_chance = 0;
|
||||
v->breakdown_ctr = 0;
|
||||
v = v->Next();
|
||||
} while (v != NULL && v->HasEngineType());
|
||||
} while (v != nullptr && v->HasEngineType());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,7 +253,7 @@ bool Vehicle::NeedsServicing() const
|
||||
Money needed_money = c->settings.engine_renew_money;
|
||||
if (needed_money > c->money) return false;
|
||||
|
||||
for (const Vehicle *v = this; v != NULL; v = (v->type == VEH_TRAIN) ? Train::From(v)->GetNextUnit() : NULL) {
|
||||
for (const Vehicle *v = this; v != nullptr; v = (v->type == VEH_TRAIN) ? Train::From(v)->GetNextUnit() : nullptr) {
|
||||
bool replace_when_old = false;
|
||||
EngineID new_engine = EngineReplacementForCompany(c, v->engine_type, v->group_id, &replace_when_old);
|
||||
|
||||
@@ -305,13 +305,13 @@ bool Vehicle::NeedsAutomaticServicing() const
|
||||
uint Vehicle::Crash(bool flooded)
|
||||
{
|
||||
assert((this->vehstatus & VS_CRASHED) == 0);
|
||||
assert(this->Previous() == NULL); // IsPrimaryVehicle fails for free-wagon-chains
|
||||
assert(this->Previous() == nullptr); // IsPrimaryVehicle fails for free-wagon-chains
|
||||
|
||||
uint pass = 0;
|
||||
/* Stop the vehicle. */
|
||||
if (this->IsPrimaryVehicle()) this->vehstatus |= VS_STOPPED;
|
||||
/* crash all wagons, and count passengers */
|
||||
for (Vehicle *v = this; v != NULL; v = v->Next()) {
|
||||
for (Vehicle *v = this; v != nullptr; v = v->Next()) {
|
||||
/* We do not transfer reserver cargo back, so TotalCount() instead of StoredCount() */
|
||||
if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) pass += v->cargo.TotalCount();
|
||||
v->vehstatus |= VS_CRASHED;
|
||||
@@ -328,7 +328,7 @@ uint Vehicle::Crash(bool flooded)
|
||||
SetWindowDirty(WC_VEHICLE_DEPOT, this->tile);
|
||||
|
||||
delete this->cargo_payment;
|
||||
assert(this->cargo_payment == NULL); // cleared by ~CargoPayment
|
||||
assert(this->cargo_payment == nullptr); // cleared by ~CargoPayment
|
||||
|
||||
return RandomRange(pass + 1); // Randomise deceased passengers.
|
||||
}
|
||||
@@ -359,7 +359,7 @@ void ShowNewGrfVehicleError(EngineID engine, StringID part1, StringID part2, GRF
|
||||
GRFConfig *grfconfig = GetGRFConfig(e->GetGRFID());
|
||||
|
||||
/* Missing GRF. Nothing useful can be done in this situation. */
|
||||
if (grfconfig == NULL) return;
|
||||
if (grfconfig == nullptr) return;
|
||||
|
||||
if (!HasBit(grfconfig->grf_bugs, bug_type)) {
|
||||
SetBit(grfconfig->grf_bugs, bug_type);
|
||||
@@ -444,16 +444,16 @@ static Vehicle *VehicleFromTileHash(int xl, int yl, int xu, int yu, void *data,
|
||||
for (int y = yl; ; y = (y + (1 << HASH_BITS)) & (HASH_MASK << HASH_BITS)) {
|
||||
for (int x = xl; ; x = (x + 1) & HASH_MASK) {
|
||||
Vehicle *v = _vehicle_tile_hash[(x + y) & TOTAL_HASH_MASK];
|
||||
for (; v != NULL; v = v->hash_tile_next) {
|
||||
for (; v != nullptr; v = v->hash_tile_next) {
|
||||
Vehicle *a = proc(v, data);
|
||||
if (find_first && a != NULL) return a;
|
||||
if (find_first && a != nullptr) return a;
|
||||
}
|
||||
if (x == xu) break;
|
||||
}
|
||||
if (y == yu) break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -502,18 +502,18 @@ void FindVehicleOnPosXY(int x, int y, void *data, VehicleFromPosProc *proc)
|
||||
|
||||
/**
|
||||
* Checks whether a vehicle in on a specific location. It will call proc for
|
||||
* vehicles until it returns non-NULL.
|
||||
* vehicles until it returns non-nullptr.
|
||||
* @note Use FindVehicleOnPosXY when you have the intention that all vehicles
|
||||
* should be iterated over.
|
||||
* @param x The X location on the map
|
||||
* @param y The Y location on the map
|
||||
* @param data Arbitrary data passed to proc
|
||||
* @param proc The proc that determines whether a vehicle will be "found".
|
||||
* @return True if proc returned non-NULL.
|
||||
* @return True if proc returned non-nullptr.
|
||||
*/
|
||||
bool HasVehicleOnPosXY(int x, int y, void *data, VehicleFromPosProc *proc)
|
||||
{
|
||||
return VehicleFromPosXY(x, y, data, proc, true) != NULL;
|
||||
return VehicleFromPosXY(x, y, data, proc, true) != nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -532,14 +532,14 @@ static Vehicle *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *p
|
||||
int y = GB(TileY(tile), HASH_RES, HASH_BITS) << HASH_BITS;
|
||||
|
||||
Vehicle *v = _vehicle_tile_hash[(x + y) & TOTAL_HASH_MASK];
|
||||
for (; v != NULL; v = v->hash_tile_next) {
|
||||
for (; v != nullptr; v = v->hash_tile_next) {
|
||||
if (v->tile != tile) continue;
|
||||
|
||||
Vehicle *a = proc(v, data);
|
||||
if (find_first && a != NULL) return a;
|
||||
if (find_first && a != nullptr) return a;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -562,31 +562,31 @@ void FindVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
|
||||
|
||||
/**
|
||||
* Checks whether a vehicle is on a specific location. It will call \a proc for
|
||||
* vehicles until it returns non-NULL.
|
||||
* vehicles until it returns non-nullptr.
|
||||
* @note Use #FindVehicleOnPos when you have the intention that all vehicles
|
||||
* should be iterated over.
|
||||
* @param tile The location on the map
|
||||
* @param data Arbitrary data passed to \a proc.
|
||||
* @param proc The \a proc that determines whether a vehicle will be "found".
|
||||
* @return True if proc returned non-NULL.
|
||||
* @return True if proc returned non-nullptr.
|
||||
*/
|
||||
bool HasVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
|
||||
{
|
||||
return VehicleFromPos(tile, data, proc, true) != NULL;
|
||||
return VehicleFromPos(tile, data, proc, true) != nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback that returns 'real' vehicles lower or at height \c *(int*)data .
|
||||
* @param v Vehicle to examine.
|
||||
* @param data Pointer to height data.
|
||||
* @return \a v if conditions are met, else \c NULL.
|
||||
* @return \a v if conditions are met, else \c nullptr.
|
||||
*/
|
||||
static Vehicle *EnsureNoVehicleProcZ(Vehicle *v, void *data)
|
||||
{
|
||||
int z = *(int*)data;
|
||||
|
||||
if (v->type == VEH_DISASTER || (v->type == VEH_AIRCRAFT && v->subtype == AIR_SHADOW)) return NULL;
|
||||
if (v->z_pos > z) return NULL;
|
||||
if (v->type == VEH_DISASTER || (v->type == VEH_AIRCRAFT && v->subtype == AIR_SHADOW)) return nullptr;
|
||||
if (v->z_pos > z) return nullptr;
|
||||
|
||||
return v;
|
||||
}
|
||||
@@ -605,7 +605,7 @@ CommandCost EnsureNoVehicleOnGround(TileIndex tile)
|
||||
* Such a message does not affect MP synchronisation.
|
||||
*/
|
||||
Vehicle *v = VehicleFromPos(tile, &z, &EnsureNoVehicleProcZ, true);
|
||||
if (v != NULL) return_cmd_error(STR_ERROR_TRAIN_IN_THE_WAY + v->type);
|
||||
if (v != nullptr) return_cmd_error(STR_ERROR_TRAIN_IN_THE_WAY + v->type);
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
@@ -613,14 +613,14 @@ CommandCost EnsureNoVehicleOnGround(TileIndex tile)
|
||||
* Callback that returns 'real' vehicles lower or at height \c *(int*)data, for road vehicles.
|
||||
* @param v Vehicle to examine.
|
||||
* @param data Pointer to height data.
|
||||
* @return \a v if conditions are met, else \c NULL.
|
||||
* @return \a v if conditions are met, else \c nullptr.
|
||||
*/
|
||||
static Vehicle *EnsureNoRoadVehicleProcZ(Vehicle *v, void *data)
|
||||
{
|
||||
int z = *(int*)data;
|
||||
|
||||
if (v->type != VEH_ROAD) return NULL;
|
||||
if (v->z_pos > z) return NULL;
|
||||
if (v->type != VEH_ROAD) return nullptr;
|
||||
if (v->z_pos > z) return nullptr;
|
||||
|
||||
return v;
|
||||
}
|
||||
@@ -639,7 +639,7 @@ CommandCost EnsureNoRoadVehicleOnGround(TileIndex tile)
|
||||
* Such a message does not affect MP synchronisation.
|
||||
*/
|
||||
Vehicle *v = VehicleFromPos(tile, &z, &EnsureNoRoadVehicleProcZ, true);
|
||||
if (v != NULL) return_cmd_error(STR_ERROR_ROAD_VEHICLE_IN_THE_WAY);
|
||||
if (v != nullptr) return_cmd_error(STR_ERROR_ROAD_VEHICLE_IN_THE_WAY);
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
@@ -653,12 +653,12 @@ struct GetVehicleTunnelBridgeProcData {
|
||||
static Vehicle *GetVehicleTunnelBridgeProc(Vehicle *v, void *data)
|
||||
{
|
||||
const GetVehicleTunnelBridgeProcData *info = (GetVehicleTunnelBridgeProcData*) data;
|
||||
if (v->type != VEH_TRAIN && v->type != VEH_ROAD && v->type != VEH_SHIP) return NULL;
|
||||
if (v == info->v) return NULL;
|
||||
if (v->type != VEH_TRAIN && v->type != VEH_ROAD && v->type != VEH_SHIP) return nullptr;
|
||||
if (v == info->v) return nullptr;
|
||||
|
||||
if (v->type == VEH_TRAIN && info->across_only && IsBridge(info->t)) {
|
||||
TrackBits vehicle_track = Train::From(v)->track;
|
||||
if (!(vehicle_track & TRACK_BIT_WORMHOLE) && !(GetAcrossBridgePossibleTrackBits(info->t) & vehicle_track)) return NULL;
|
||||
if (!(vehicle_track & TRACK_BIT_WORMHOLE) && !(GetAcrossBridgePossibleTrackBits(info->t) & vehicle_track)) return nullptr;
|
||||
}
|
||||
|
||||
return v;
|
||||
@@ -683,12 +683,12 @@ CommandCost TunnelBridgeIsFree(TileIndex tile, TileIndex endtile, const Vehicle
|
||||
data.t = tile;
|
||||
data.across_only = across_only;
|
||||
Vehicle *v = VehicleFromPos(tile, &data, &GetVehicleTunnelBridgeProc, true);
|
||||
if (v == NULL) {
|
||||
if (v == nullptr) {
|
||||
data.t = endtile;
|
||||
v = VehicleFromPos(endtile, &data, &GetVehicleTunnelBridgeProc, true);
|
||||
}
|
||||
|
||||
if (v != NULL) return_cmd_error(STR_ERROR_TRAIN_IN_THE_WAY + v->type);
|
||||
if (v != nullptr) return_cmd_error(STR_ERROR_TRAIN_IN_THE_WAY + v->type);
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
@@ -696,16 +696,16 @@ static Vehicle *EnsureNoTrainOnTrackProc(Vehicle *v, void *data)
|
||||
{
|
||||
TrackBits rail_bits = *(TrackBits *)data;
|
||||
|
||||
if (v->type != VEH_TRAIN) return NULL;
|
||||
if (v->type != VEH_TRAIN) return nullptr;
|
||||
|
||||
Train *t = Train::From(v);
|
||||
if (rail_bits & TRACK_BIT_WORMHOLE) {
|
||||
if (t->track & TRACK_BIT_WORMHOLE) return v;
|
||||
rail_bits &= ~TRACK_BIT_WORMHOLE;
|
||||
} else if (t->track & TRACK_BIT_WORMHOLE) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if ((t->track != rail_bits) && !TracksOverlap(t->track | rail_bits)) return NULL;
|
||||
if ((t->track != rail_bits) && !TracksOverlap(t->track | rail_bits)) return nullptr;
|
||||
|
||||
return v;
|
||||
}
|
||||
@@ -725,7 +725,7 @@ CommandCost EnsureNoTrainOnTrackBits(TileIndex tile, TrackBits track_bits)
|
||||
* Such a message does not affect MP synchronisation.
|
||||
*/
|
||||
Vehicle *v = VehicleFromPos(tile, &track_bits, &EnsureNoTrainOnTrackProc, true);
|
||||
if (v != NULL) return_cmd_error(STR_ERROR_TRAIN_IN_THE_WAY + v->type);
|
||||
if (v != nullptr) return_cmd_error(STR_ERROR_TRAIN_IN_THE_WAY + v->type);
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
@@ -735,7 +735,7 @@ static void UpdateVehicleTileHash(Vehicle *v, bool remove)
|
||||
Vehicle **new_hash;
|
||||
|
||||
if (remove) {
|
||||
new_hash = NULL;
|
||||
new_hash = nullptr;
|
||||
} else {
|
||||
int x = GB(TileX(v->tile), HASH_RES, HASH_BITS);
|
||||
int y = GB(TileY(v->tile), HASH_RES, HASH_BITS) << HASH_BITS;
|
||||
@@ -745,15 +745,15 @@ static void UpdateVehicleTileHash(Vehicle *v, bool remove)
|
||||
if (old_hash == new_hash) return;
|
||||
|
||||
/* Remove from the old position in the hash table */
|
||||
if (old_hash != NULL) {
|
||||
if (v->hash_tile_next != NULL) v->hash_tile_next->hash_tile_prev = v->hash_tile_prev;
|
||||
if (old_hash != nullptr) {
|
||||
if (v->hash_tile_next != nullptr) v->hash_tile_next->hash_tile_prev = v->hash_tile_prev;
|
||||
*v->hash_tile_prev = v->hash_tile_next;
|
||||
}
|
||||
|
||||
/* Insert vehicle at beginning of the new position in the hash table */
|
||||
if (new_hash != NULL) {
|
||||
if (new_hash != nullptr) {
|
||||
v->hash_tile_next = *new_hash;
|
||||
if (v->hash_tile_next != NULL) v->hash_tile_next->hash_tile_prev = &v->hash_tile_next;
|
||||
if (v->hash_tile_next != nullptr) v->hash_tile_next->hash_tile_prev = &v->hash_tile_next;
|
||||
v->hash_tile_prev = new_hash;
|
||||
*new_hash = v;
|
||||
}
|
||||
@@ -770,21 +770,21 @@ static void UpdateVehicleViewportHash(Vehicle *v, int x, int y)
|
||||
int old_x = v->coord.left;
|
||||
int old_y = v->coord.top;
|
||||
|
||||
new_hash = (x == INVALID_COORD) ? NULL : &_vehicle_viewport_hash[GEN_HASH(x, y)];
|
||||
old_hash = (old_x == INVALID_COORD) ? NULL : &_vehicle_viewport_hash[GEN_HASH(old_x, old_y)];
|
||||
new_hash = (x == INVALID_COORD) ? nullptr : &_vehicle_viewport_hash[GEN_HASH(x, y)];
|
||||
old_hash = (old_x == INVALID_COORD) ? nullptr : &_vehicle_viewport_hash[GEN_HASH(old_x, old_y)];
|
||||
|
||||
if (old_hash == new_hash) return;
|
||||
|
||||
/* remove from hash table? */
|
||||
if (old_hash != NULL) {
|
||||
if (v->hash_viewport_next != NULL) v->hash_viewport_next->hash_viewport_prev = v->hash_viewport_prev;
|
||||
if (old_hash != nullptr) {
|
||||
if (v->hash_viewport_next != nullptr) v->hash_viewport_next->hash_viewport_prev = v->hash_viewport_prev;
|
||||
*v->hash_viewport_prev = v->hash_viewport_next;
|
||||
}
|
||||
|
||||
/* insert into hash table? */
|
||||
if (new_hash != NULL) {
|
||||
if (new_hash != nullptr) {
|
||||
v->hash_viewport_next = *new_hash;
|
||||
if (v->hash_viewport_next != NULL) v->hash_viewport_next->hash_viewport_prev = &v->hash_viewport_next;
|
||||
if (v->hash_viewport_next != nullptr) v->hash_viewport_next->hash_viewport_prev = &v->hash_viewport_next;
|
||||
v->hash_viewport_prev = new_hash;
|
||||
*new_hash = v;
|
||||
}
|
||||
@@ -793,7 +793,7 @@ static void UpdateVehicleViewportHash(Vehicle *v, int x, int y)
|
||||
void ResetVehicleHash()
|
||||
{
|
||||
Vehicle *v;
|
||||
FOR_ALL_VEHICLES(v) { v->hash_tile_current = NULL; }
|
||||
FOR_ALL_VEHICLES(v) { v->hash_tile_current = nullptr; }
|
||||
memset(_vehicle_viewport_hash, 0, sizeof(_vehicle_viewport_hash));
|
||||
memset(_vehicle_tile_hash, 0, sizeof(_vehicle_tile_hash));
|
||||
}
|
||||
@@ -828,7 +828,7 @@ void InitializeVehicles()
|
||||
uint CountVehiclesInChain(const Vehicle *v)
|
||||
{
|
||||
uint count = 0;
|
||||
do count++; while ((v = v->Next()) != NULL);
|
||||
do count++; while ((v = v->Next()) != nullptr);
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -942,7 +942,7 @@ void Vehicle::PreDestructor()
|
||||
HideFillingPercent(&this->fill_percent_te_id);
|
||||
this->CancelReservation(INVALID_STATION, st);
|
||||
delete this->cargo_payment;
|
||||
assert(this->cargo_payment == NULL); // cleared by ~CargoPayment
|
||||
assert(this->cargo_payment == nullptr); // cleared by ~CargoPayment
|
||||
}
|
||||
|
||||
if (this->IsEngineCountable()) {
|
||||
@@ -962,7 +962,7 @@ void Vehicle::PreDestructor()
|
||||
if (this->type == VEH_AIRCRAFT && this->IsPrimaryVehicle()) {
|
||||
Aircraft *a = Aircraft::From(this);
|
||||
Station *st = GetTargetAirportIfValid(a);
|
||||
if (st != NULL) {
|
||||
if (st != nullptr) {
|
||||
const AirportFTA *layout = st->airport.GetFTA()->layout;
|
||||
CLRBITS(st->airport.flags, layout[a->previous_pos].block | layout[a->pos].block);
|
||||
}
|
||||
@@ -982,7 +982,7 @@ void Vehicle::PreDestructor()
|
||||
ClrBit(Train::From(this)->flags, VRF_HAVE_SLOT);
|
||||
}
|
||||
|
||||
if (this->Previous() == NULL) {
|
||||
if (this->Previous() == nullptr) {
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, this->tile);
|
||||
}
|
||||
|
||||
@@ -1035,7 +1035,7 @@ Vehicle::~Vehicle()
|
||||
}
|
||||
|
||||
Vehicle *v = this->Next();
|
||||
this->SetNext(NULL);
|
||||
this->SetNext(nullptr);
|
||||
|
||||
delete v;
|
||||
|
||||
@@ -1054,7 +1054,7 @@ void VehicleEnteredDepotThisTick(Vehicle *v)
|
||||
/* Template Replacement Setup stuff */
|
||||
bool stayInDepot = v->current_order.GetDepotActionType();
|
||||
TemplateReplacement *tr = GetTemplateReplacementByGroupID(v->group_id);
|
||||
if (tr != NULL) {
|
||||
if (tr != nullptr) {
|
||||
_vehicles_to_templatereplace[(Train*) v] = stayInDepot;
|
||||
} else {
|
||||
/* Moved the assignment for auto replacement here to prevent auto replacement
|
||||
@@ -1082,11 +1082,11 @@ static void RunVehicleDayProc()
|
||||
if (_game_mode != GM_NORMAL) return;
|
||||
|
||||
/* Run the day_proc for every DAY_TICKS vehicle starting at _date_fract. */
|
||||
Vehicle *v = NULL;
|
||||
Vehicle *v = nullptr;
|
||||
SCOPE_INFO_FMT([&v], "RunVehicleDayProc: %s", scope_dumper().VehicleInfo(v));
|
||||
for (size_t i = _date_fract; i < Vehicle::GetPoolSize(); i += DAY_TICKS) {
|
||||
v = Vehicle::Get(i);
|
||||
if (v == NULL) continue;
|
||||
if (v == nullptr) continue;
|
||||
|
||||
/* Call the 32-day callback if needed */
|
||||
if ((v->day_counter & 0x1F) == 0 && v->HasEngineType()) {
|
||||
@@ -1157,7 +1157,7 @@ void RemoveFromOtherVehicleTickCache(const Vehicle *v)
|
||||
|
||||
void RebuildVehicleTickCaches()
|
||||
{
|
||||
Vehicle *v = NULL;
|
||||
Vehicle *v = nullptr;
|
||||
SCOPE_INFO_FMT([&v], "RebuildVehicleTickCaches: %s", scope_dumper().VehicleInfo(v));
|
||||
|
||||
ClearVehicleTickCaches();
|
||||
@@ -1244,7 +1244,7 @@ void CallVehicleTicks()
|
||||
|
||||
if (!_tick_caches_valid) RebuildVehicleTickCaches();
|
||||
|
||||
Vehicle *v = NULL;
|
||||
Vehicle *v = nullptr;
|
||||
SCOPE_INFO_FMT([&v], "CallVehicleTicks: %s", scope_dumper().VehicleInfo(v));
|
||||
{
|
||||
for (EffectVehicle *u : _tick_effect_veh_cache) {
|
||||
@@ -1315,7 +1315,7 @@ void CallVehicleTicks()
|
||||
u->Tick();
|
||||
}
|
||||
}
|
||||
v = NULL;
|
||||
v = nullptr;
|
||||
|
||||
/* do Template Replacement */
|
||||
Backup<CompanyByte> sell_cur_company(_current_company, FILE_LINE);
|
||||
@@ -1549,7 +1549,7 @@ void ViewportAddVehicles(DrawPixelInfo *dpi)
|
||||
for (int x = vhb.xl;; x = (x + 1) & 0x3F) {
|
||||
const Vehicle *v = _vehicle_viewport_hash[x + y]; // already masked & 0xFFF
|
||||
|
||||
while (v != NULL) {
|
||||
while (v != nullptr) {
|
||||
if (v->IsDrawn() &&
|
||||
l <= v->coord.right &&
|
||||
t <= v->coord.bottom &&
|
||||
@@ -1585,7 +1585,7 @@ void ViewportMapDrawVehicles(DrawPixelInfo *dpi)
|
||||
for (int x = vhb.xl;; x = (x + 1) & 0x3F) {
|
||||
const Vehicle *v = _vehicle_viewport_hash[x + y]; // already masked & 0xFFF
|
||||
|
||||
while (v != NULL) {
|
||||
while (v != nullptr) {
|
||||
if (!(v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) && (v->type != VEH_EFFECT)) {
|
||||
Point pt = RemapCoords(v->x_pos, v->y_pos, v->z_pos);
|
||||
const int pixel_x = UnScaleByZoomLower(pt.x - dpi->left, dpi->zoom);
|
||||
@@ -1610,14 +1610,14 @@ void ViewportMapDrawVehicles(DrawPixelInfo *dpi)
|
||||
* @param vp Viewport clicked in.
|
||||
* @param x X coordinate in the viewport.
|
||||
* @param y Y coordinate in the viewport.
|
||||
* @return Closest vehicle, or \c NULL if none found.
|
||||
* @return Closest vehicle, or \c nullptr if none found.
|
||||
*/
|
||||
Vehicle *CheckClickOnVehicle(const ViewPort *vp, int x, int y)
|
||||
{
|
||||
Vehicle *found = NULL, *v;
|
||||
Vehicle *found = nullptr, *v;
|
||||
uint dist, best_dist = UINT_MAX;
|
||||
|
||||
if ((uint)(x -= vp->left) >= (uint)vp->width || (uint)(y -= vp->top) >= (uint)vp->height) return NULL;
|
||||
if ((uint)(x -= vp->left) >= (uint)vp->width || (uint)(y -= vp->top) >= (uint)vp->height) return nullptr;
|
||||
|
||||
x = ScaleByZoom(x, vp->zoom) + vp->virtual_left;
|
||||
y = ScaleByZoom(y, vp->zoom) + vp->virtual_top;
|
||||
@@ -1845,7 +1845,7 @@ bool Vehicle::HandleBreakdown()
|
||||
if(this->breakdown_type == BREAKDOWN_AIRCRAFT_SPEED ||
|
||||
(this->current_order.IsType(OT_GOTO_DEPOT) &&
|
||||
(this->current_order.GetDepotOrderType() & ODTFB_BREAKDOWN) &&
|
||||
GetTargetAirportIfValid(Aircraft::From(this)) != NULL)) return false;
|
||||
GetTargetAirportIfValid(Aircraft::From(this)) != nullptr)) return false;
|
||||
FindBreakdownDestination(Aircraft::From(this));
|
||||
} else if (this->type == VEH_TRAIN) {
|
||||
if (this->breakdown_type == BREAKDOWN_LOW_POWER ||
|
||||
@@ -1863,7 +1863,7 @@ bool Vehicle::HandleBreakdown()
|
||||
}
|
||||
if (!(this->vehstatus & VS_HIDDEN) && !HasBit(EngInfo(this->engine_type)->misc_flags, EF_NO_BREAKDOWN_SMOKE) && this->breakdown_delay > 0) {
|
||||
EffectVehicle *u = CreateEffectVehicleRel(this, 4, 4, 5, EV_BREAKDOWN_SMOKE);
|
||||
if (u != NULL) u->animation_state = this->breakdown_delay * 2;
|
||||
if (u != nullptr) u->animation_state = this->breakdown_delay * 2;
|
||||
}
|
||||
/* Max Speed reduction*/
|
||||
if (_settings_game.vehicle.improved_breakdowns) {
|
||||
@@ -1901,7 +1901,7 @@ bool Vehicle::HandleBreakdown()
|
||||
if ((!(this->vehstatus & VS_HIDDEN)) && (this->breakdown_type == BREAKDOWN_LOW_SPEED || this->breakdown_type == BREAKDOWN_LOW_POWER)
|
||||
&& !HasBit(EngInfo(this->engine_type)->misc_flags, EF_NO_BREAKDOWN_SMOKE)) {
|
||||
EffectVehicle *u = CreateEffectVehicleRel(this, 0, 0, 2, EV_BREAKDOWN_SMOKE); //some grey clouds to indicate a broken engine
|
||||
if (u != NULL) u->animation_state = 25;
|
||||
if (u != nullptr) u->animation_state = 25;
|
||||
}
|
||||
} else {
|
||||
switch (this->breakdown_type) {
|
||||
@@ -1911,7 +1911,7 @@ bool Vehicle::HandleBreakdown()
|
||||
}
|
||||
if (!(this->vehstatus & VS_HIDDEN) && !HasBit(EngInfo(this->engine_type)->misc_flags, EF_NO_BREAKDOWN_SMOKE) && this->breakdown_delay > 0) {
|
||||
EffectVehicle *u = CreateEffectVehicleRel(this, 4, 4, 5, EV_BREAKDOWN_SMOKE);
|
||||
if (u != NULL) u->animation_state = this->breakdown_delay * 2;
|
||||
if (u != nullptr) u->animation_state = this->breakdown_delay * 2;
|
||||
}
|
||||
if (_settings_game.vehicle.improved_breakdowns) {
|
||||
if (this->type == VEH_ROAD) {
|
||||
@@ -1934,7 +1934,7 @@ bool Vehicle::HandleBreakdown()
|
||||
(this->breakdown_type == BREAKDOWN_LOW_SPEED || this->breakdown_type == BREAKDOWN_LOW_POWER)) {
|
||||
/* Some gray clouds to indicate a broken RV */
|
||||
EffectVehicle *u = CreateEffectVehicleRel(this, 0, 0, 2, EV_BREAKDOWN_SMOKE);
|
||||
if (u != NULL) u->animation_state = 25;
|
||||
if (u != nullptr) u->animation_state = 25;
|
||||
}
|
||||
this->First()->MarkDirty();
|
||||
SetWindowDirty(WC_VEHICLE_VIEW, this->index);
|
||||
@@ -1994,7 +1994,7 @@ void AgeVehicle(Vehicle *v)
|
||||
SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
|
||||
|
||||
/* Don't warn about non-primary or not ours vehicles or vehicles that are crashed */
|
||||
if (v->Previous() != NULL || v->owner != _local_company || (v->vehstatus & VS_CRASHED) != 0) return;
|
||||
if (v->Previous() != nullptr || v->owner != _local_company || (v->vehstatus & VS_CRASHED) != 0) return;
|
||||
|
||||
const Company *c = Company::Get(v->owner);
|
||||
/* Don't warn if a renew is active */
|
||||
@@ -2036,18 +2036,18 @@ uint8 CalcPercentVehicleFilled(const Vehicle *front, StringID *colour)
|
||||
|
||||
bool is_loading = front->current_order.IsType(OT_LOADING);
|
||||
|
||||
/* The station may be NULL when the (colour) string does not need to be set. */
|
||||
/* The station may be nullptr when the (colour) string does not need to be set. */
|
||||
const Station *st = Station::GetIfValid(front->last_station_visited);
|
||||
assert(colour == NULL || (st != NULL && is_loading));
|
||||
assert(colour == nullptr || (st != nullptr && is_loading));
|
||||
|
||||
bool order_no_load = is_loading && (front->current_order.GetLoadType() & OLFB_NO_LOAD);
|
||||
bool order_full_load = is_loading && (front->current_order.GetLoadType() & OLFB_FULL_LOAD);
|
||||
|
||||
/* Count up max and used */
|
||||
for (const Vehicle *v = front; v != NULL; v = v->Next()) {
|
||||
for (const Vehicle *v = front; v != nullptr; v = v->Next()) {
|
||||
count += v->cargo.StoredCount();
|
||||
max += v->cargo_cap;
|
||||
if (v->cargo_cap != 0 && colour != NULL) {
|
||||
if (v->cargo_cap != 0 && colour != nullptr) {
|
||||
unloading += HasBit(v->vehicle_flags, VF_CARGO_UNLOADING) ? 1 : 0;
|
||||
loading |= !order_no_load &&
|
||||
(order_full_load || st->goods[v->cargo_type].HasRating()) &&
|
||||
@@ -2056,7 +2056,7 @@ uint8 CalcPercentVehicleFilled(const Vehicle *front, StringID *colour)
|
||||
}
|
||||
}
|
||||
|
||||
if (colour != NULL) {
|
||||
if (colour != nullptr) {
|
||||
if (unloading == 0 && loading) {
|
||||
*colour = STR_PERCENT_UP;
|
||||
} else if (unloading == 0 && !loading) {
|
||||
@@ -2156,7 +2156,7 @@ void VehicleEnterDepot(Vehicle *v)
|
||||
/* Test whether we are heading for this depot. If not, do nothing.
|
||||
* Note: The target depot for nearest-/manual-depot-orders is only updated on junctions, but we want to accept every depot. */
|
||||
if ((v->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) &&
|
||||
real_order != NULL && !(real_order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) &&
|
||||
real_order != nullptr && !(real_order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) &&
|
||||
(v->type == VEH_AIRCRAFT ? v->current_order.GetDestination() != GetStationIndex(v->tile) : v->dest_tile != v->tile)) {
|
||||
/* We are heading for another depot, keep driving. */
|
||||
return;
|
||||
@@ -2356,7 +2356,7 @@ VehicleEnterTileStatus VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y
|
||||
* @param type type of vehicle
|
||||
* @param owner owner of vehicles
|
||||
*/
|
||||
FreeUnitIDGenerator::FreeUnitIDGenerator(VehicleType type, CompanyID owner) : cache(NULL), maxid(0), curid(0)
|
||||
FreeUnitIDGenerator::FreeUnitIDGenerator(VehicleType type, CompanyID owner) : cache(nullptr), maxid(0), curid(0)
|
||||
{
|
||||
/* Find maximum */
|
||||
const Vehicle *v;
|
||||
@@ -2468,17 +2468,17 @@ bool CanBuildVehicleInfrastructure(VehicleType type)
|
||||
* Determines the #LiveryScheme for a vehicle.
|
||||
* @param engine_type Engine of the vehicle.
|
||||
* @param parent_engine_type Engine of the front vehicle, #INVALID_ENGINE if vehicle is at front itself.
|
||||
* @param v the vehicle, \c NULL if in purchase list etc.
|
||||
* @param v the vehicle, \c nullptr if in purchase list etc.
|
||||
* @return livery scheme to use.
|
||||
*/
|
||||
LiveryScheme GetEngineLiveryScheme(EngineID engine_type, EngineID parent_engine_type, const Vehicle *v)
|
||||
{
|
||||
CargoID cargo_type = v == NULL ? (CargoID)CT_INVALID : v->cargo_type;
|
||||
CargoID cargo_type = v == nullptr ? (CargoID)CT_INVALID : v->cargo_type;
|
||||
const Engine *e = Engine::Get(engine_type);
|
||||
switch (e->type) {
|
||||
default: NOT_REACHED();
|
||||
case VEH_TRAIN:
|
||||
if (v != NULL && parent_engine_type != INVALID_ENGINE && (UsesWagonOverride(v) || (v->IsArticulatedPart() && e->u.rail.railveh_type != RAILVEH_WAGON))) {
|
||||
if (v != nullptr && parent_engine_type != INVALID_ENGINE && (UsesWagonOverride(v) || (v->IsArticulatedPart() && e->u.rail.railveh_type != RAILVEH_WAGON))) {
|
||||
/* Wagonoverrides use the colour scheme of the front engine.
|
||||
* Articulated parts use the colour scheme of the first part. (Not supported for articulated wagons) */
|
||||
engine_type = parent_engine_type;
|
||||
@@ -2521,7 +2521,7 @@ LiveryScheme GetEngineLiveryScheme(EngineID engine_type, EngineID parent_engine_
|
||||
|
||||
case VEH_ROAD:
|
||||
/* Always use the livery of the front */
|
||||
if (v != NULL && parent_engine_type != INVALID_ENGINE) {
|
||||
if (v != nullptr && parent_engine_type != INVALID_ENGINE) {
|
||||
engine_type = parent_engine_type;
|
||||
e = Engine::Get(engine_type);
|
||||
cargo_type = v->First()->cargo_type;
|
||||
@@ -2558,7 +2558,7 @@ LiveryScheme GetEngineLiveryScheme(EngineID engine_type, EngineID parent_engine_
|
||||
* @param engine_type EngineID of the vehicle
|
||||
* @param company Owner of the vehicle
|
||||
* @param parent_engine_type EngineID of the front vehicle. INVALID_VEHICLE if vehicle is at front itself.
|
||||
* @param v the vehicle. NULL if in purchase list etc.
|
||||
* @param v the vehicle. nullptr if in purchase list etc.
|
||||
* @param livery_setting The livery settings to use for acquiring the livery information.
|
||||
* @return livery to use
|
||||
*/
|
||||
@@ -2568,9 +2568,9 @@ const Livery *GetEngineLivery(EngineID engine_type, CompanyID company, EngineID
|
||||
LiveryScheme scheme = LS_DEFAULT;
|
||||
|
||||
if (livery_setting == LIT_ALL || (livery_setting == LIT_COMPANY && company == _local_company)) {
|
||||
if (v != NULL) {
|
||||
if (v != nullptr) {
|
||||
const Group *g = Group::GetIfValid(v->First()->group_id);
|
||||
if (g != NULL) {
|
||||
if (g != nullptr) {
|
||||
/* Traverse parents until we find a livery or reach the top */
|
||||
while (g->livery.in_use == 0 && g->parent != INVALID_GROUP) {
|
||||
g = Group::Get(g->parent);
|
||||
@@ -2593,7 +2593,7 @@ const Livery *GetEngineLivery(EngineID engine_type, CompanyID company, EngineID
|
||||
|
||||
static PaletteID GetEngineColourMap(EngineID engine_type, CompanyID company, EngineID parent_engine_type, const Vehicle *v)
|
||||
{
|
||||
PaletteID map = (v != NULL) ? v->colourmap : PAL_NONE;
|
||||
PaletteID map = (v != nullptr) ? v->colourmap : PAL_NONE;
|
||||
|
||||
/* Return cached value if any */
|
||||
if (map != PAL_NONE) return map;
|
||||
@@ -2611,7 +2611,7 @@ static PaletteID GetEngineColourMap(EngineID engine_type, CompanyID company, Eng
|
||||
* map else it's returned as-is. */
|
||||
if (!HasBit(callback, 14)) {
|
||||
/* Update cache */
|
||||
if (v != NULL) const_cast<Vehicle *>(v)->colourmap = map;
|
||||
if (v != nullptr) const_cast<Vehicle *>(v)->colourmap = map;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@@ -2630,7 +2630,7 @@ static PaletteID GetEngineColourMap(EngineID engine_type, CompanyID company, Eng
|
||||
if (twocc) map += livery->colour2 * 16;
|
||||
|
||||
/* Update cache */
|
||||
if (v != NULL) const_cast<Vehicle *>(v)->colourmap = map;
|
||||
if (v != nullptr) const_cast<Vehicle *>(v)->colourmap = map;
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -2642,7 +2642,7 @@ static PaletteID GetEngineColourMap(EngineID engine_type, CompanyID company, Eng
|
||||
*/
|
||||
PaletteID GetEnginePalette(EngineID engine_type, CompanyID company)
|
||||
{
|
||||
return GetEngineColourMap(engine_type, company, INVALID_ENGINE, NULL);
|
||||
return GetEngineColourMap(engine_type, company, INVALID_ENGINE, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2676,7 +2676,7 @@ void Vehicle::DeleteUnreachedImplicitOrders()
|
||||
}
|
||||
|
||||
const Order *order = this->GetOrder(this->cur_implicit_order_index);
|
||||
while (order != NULL) {
|
||||
while (order != nullptr) {
|
||||
if (this->cur_implicit_order_index == this->cur_real_order_index) break;
|
||||
|
||||
if (order->IsType(OT_IMPLICIT)) {
|
||||
@@ -2690,7 +2690,7 @@ void Vehicle::DeleteUnreachedImplicitOrders()
|
||||
}
|
||||
|
||||
/* Wrap around */
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
order = this->GetOrder(0);
|
||||
this->cur_implicit_order_index = 0;
|
||||
}
|
||||
@@ -2705,7 +2705,7 @@ void Vehicle::DeleteUnreachedImplicitOrders()
|
||||
*/
|
||||
static void VehicleIncreaseStats(const Vehicle *front)
|
||||
{
|
||||
for (const Vehicle *v = front; v != NULL; v = v->Next()) {
|
||||
for (const Vehicle *v = front; v != nullptr; v = v->Next()) {
|
||||
StationID last_loading_station = HasBit(front->vehicle_flags, VF_LAST_LOAD_ST_SEP) ? v->last_loading_station : front->last_loading_station;
|
||||
if (v->refit_cap > 0 &&
|
||||
last_loading_station != INVALID_STATION &&
|
||||
@@ -2762,12 +2762,12 @@ void Vehicle::BeginLoading()
|
||||
* the 'wrong' terminal when skipping orders etc. */
|
||||
Order *in_list = this->GetOrder(this->cur_implicit_order_index);
|
||||
if (this->IsGroundVehicle() &&
|
||||
(in_list == NULL || !in_list->IsType(OT_IMPLICIT) ||
|
||||
(in_list == nullptr || !in_list->IsType(OT_IMPLICIT) ||
|
||||
in_list->GetDestination() != this->last_station_visited)) {
|
||||
bool suppress_implicit_orders = HasBit(this->GetGroundVehicleFlags(), GVF_SUPPRESS_IMPLICIT_ORDERS);
|
||||
/* Do not create consecutive duplicates of implicit orders */
|
||||
Order *prev_order = this->cur_implicit_order_index > 0 ? this->GetOrder(this->cur_implicit_order_index - 1) : (this->GetNumOrders() > 1 ? this->GetLastOrder() : NULL);
|
||||
if (prev_order == NULL ||
|
||||
Order *prev_order = this->cur_implicit_order_index > 0 ? this->GetOrder(this->cur_implicit_order_index - 1) : (this->GetNumOrders() > 1 ? this->GetLastOrder() : nullptr);
|
||||
if (prev_order == nullptr ||
|
||||
(!prev_order->IsType(OT_IMPLICIT) && !prev_order->IsType(OT_GOTO_STATION)) ||
|
||||
prev_order->GetDestination() != this->last_station_visited) {
|
||||
|
||||
@@ -2780,7 +2780,7 @@ void Vehicle::BeginLoading()
|
||||
bool found = false;
|
||||
while (target_index != this->cur_real_order_index || this->GetNumManualOrders() == 0) {
|
||||
const Order *order = this->GetOrder(target_index);
|
||||
if (order == NULL) break; // No orders.
|
||||
if (order == nullptr) break; // No orders.
|
||||
if (order->IsType(OT_IMPLICIT) && order->GetDestination() == this->last_station_visited) {
|
||||
found = true;
|
||||
break;
|
||||
@@ -2816,15 +2816,15 @@ void Vehicle::BeginLoading()
|
||||
}
|
||||
|
||||
/* Wrap around */
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
order = this->GetOrder(0);
|
||||
this->cur_implicit_order_index = 0;
|
||||
}
|
||||
assert(order != NULL);
|
||||
assert(order != nullptr);
|
||||
}
|
||||
}
|
||||
} else if (!suppress_implicit_orders &&
|
||||
((this->orders.list == NULL ? OrderList::CanAllocateItem() : this->orders.list->GetNumOrders() < MAX_VEH_ORDER_ID)) &&
|
||||
((this->orders.list == nullptr ? OrderList::CanAllocateItem() : this->orders.list->GetNumOrders() < MAX_VEH_ORDER_ID)) &&
|
||||
Order::CanAllocateItem()) {
|
||||
/* Insert new implicit order */
|
||||
Order *implicit_order = new Order();
|
||||
@@ -2865,7 +2865,7 @@ void Vehicle::BeginLoading()
|
||||
*/
|
||||
void Vehicle::CancelReservation(StationID next, Station *st)
|
||||
{
|
||||
for (Vehicle *v = this; v != NULL; v = v->next) {
|
||||
for (Vehicle *v = this; v != nullptr; v = v->next) {
|
||||
VehicleCargoList &cargo = v->cargo;
|
||||
if (cargo.ActionCount(VehicleCargoList::MTA_LOAD) > 0) {
|
||||
DEBUG(misc, 1, "cancelling cargo reservation");
|
||||
@@ -2882,7 +2882,7 @@ CargoTypes Vehicle::GetLastLoadingStationValidCargoMask() const
|
||||
return (this->last_loading_station != INVALID_STATION) ? ALL_CARGOTYPES : 0;
|
||||
} else {
|
||||
CargoTypes cargo_mask = 0;
|
||||
for (const Vehicle *u = this; u != NULL; u = u->Next()) {
|
||||
for (const Vehicle *u = this; u != nullptr; u = u->Next()) {
|
||||
if (u->cargo_type < NUM_CARGO && u->last_loading_station != INVALID_STATION) {
|
||||
SetBit(cargo_mask, u->cargo_type);
|
||||
}
|
||||
@@ -2900,7 +2900,7 @@ void Vehicle::LeaveStation()
|
||||
assert(this->current_order.IsAnyLoadingType());
|
||||
|
||||
delete this->cargo_payment;
|
||||
assert(this->cargo_payment == NULL); // cleared by ~CargoPayment
|
||||
assert(this->cargo_payment == nullptr); // cleared by ~CargoPayment
|
||||
|
||||
TileIndex station_tile = INVALID_TILE;
|
||||
|
||||
@@ -2951,7 +2951,7 @@ void Vehicle::LeaveStation()
|
||||
|
||||
/* NB: this is saved here as we overwrite it on the first iteration of the loop below */
|
||||
StationID head_last_loading_station = this->last_loading_station;
|
||||
for (Vehicle *u = this; u != NULL; u = u->Next()) {
|
||||
for (Vehicle *u = this; u != nullptr; u = u->Next()) {
|
||||
StationID last_loading_station = HasBit(this->vehicle_flags, VF_LAST_LOAD_ST_SEP) ? u->last_loading_station : head_last_loading_station;
|
||||
if (u->cargo_type < NUM_CARGO && HasBit(cargoes_can_load_unload, u->cargo_type)) {
|
||||
if (HasBit(cargoes_can_leave_with_cargo, u->cargo_type)) {
|
||||
@@ -2973,7 +2973,7 @@ void Vehicle::LeaveStation()
|
||||
st->loading_vehicles.erase(std::remove(st->loading_vehicles.begin(), st->loading_vehicles.end(), this), st->loading_vehicles.end());
|
||||
|
||||
HideFillingPercent(&this->fill_percent_te_id);
|
||||
trip_occupancy = CalcPercentVehicleFilled(this, NULL);
|
||||
trip_occupancy = CalcPercentVehicleFilled(this, nullptr);
|
||||
|
||||
if (this->type == VEH_TRAIN && !(this->vehstatus & VS_CRASHED)) {
|
||||
/* Trigger station animation (trains only) */
|
||||
@@ -2987,7 +2987,7 @@ void Vehicle::LeaveStation()
|
||||
|
||||
if (this->cur_real_order_index < this->GetNumOrders()) {
|
||||
Order *real_current_order = this->GetOrder(this->cur_real_order_index);
|
||||
uint current_occupancy = CalcPercentVehicleFilled(this, NULL);
|
||||
uint current_occupancy = CalcPercentVehicleFilled(this, nullptr);
|
||||
uint old_occupancy = real_current_order->GetOccupancy();
|
||||
uint new_occupancy;
|
||||
if (old_occupancy == 0) {
|
||||
@@ -3004,7 +3004,7 @@ void Vehicle::LeaveStation()
|
||||
if (new_occupancy + 1 != old_occupancy) {
|
||||
this->order_occupancy_average = 0;
|
||||
real_current_order->SetOccupancy(static_cast<uint8>(new_occupancy + 1));
|
||||
for (const Vehicle *v = this->FirstShared(); v != NULL; v = v->NextShared()) {
|
||||
for (const Vehicle *v = this->FirstShared(); v != nullptr; v = v->NextShared()) {
|
||||
SetWindowDirty(WC_VEHICLE_ORDERS, v->index);
|
||||
}
|
||||
}
|
||||
@@ -3062,7 +3062,7 @@ void Vehicle::RecalculateOrderOccupancyAverage()
|
||||
*/
|
||||
void Vehicle::ResetRefitCaps()
|
||||
{
|
||||
for (Vehicle *v = this; v != NULL; v = v->Next()) v->refit_cap = v->cargo_cap;
|
||||
for (Vehicle *v = this; v != nullptr; v = v->Next()) v->refit_cap = v->cargo_cap;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3096,7 +3096,7 @@ void Vehicle::HandleLoading(bool mode)
|
||||
|
||||
/* Only advance to next order if we just loaded at the current one */
|
||||
const Order *order = this->GetOrder(this->cur_implicit_order_index);
|
||||
if (order == NULL ||
|
||||
if (order == nullptr ||
|
||||
(!order->IsType(OT_IMPLICIT) && !order->IsType(OT_GOTO_STATION)) ||
|
||||
order->GetDestination() != this->last_station_visited) {
|
||||
return;
|
||||
@@ -3539,34 +3539,34 @@ void Vehicle::ShowVisualEffect() const
|
||||
}
|
||||
|
||||
if (HasBit(v->vcache.cached_veh_flags, VCF_LAST_VISUAL_EFFECT)) break;
|
||||
} while ((v = v->Next()) != NULL);
|
||||
} while ((v = v->Next()) != nullptr);
|
||||
|
||||
if (sound) PlayVehicleSound(this, VSE_VISUAL_EFFECT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the next vehicle of this vehicle.
|
||||
* @param next the next vehicle. NULL removes the next vehicle.
|
||||
* @param next the next vehicle. nullptr removes the next vehicle.
|
||||
*/
|
||||
void Vehicle::SetNext(Vehicle *next)
|
||||
{
|
||||
assert(this != next);
|
||||
|
||||
if (this->next != NULL) {
|
||||
if (this->next != nullptr) {
|
||||
/* We had an old next vehicle. Update the first and previous pointers */
|
||||
for (Vehicle *v = this->next; v != NULL; v = v->Next()) {
|
||||
for (Vehicle *v = this->next; v != nullptr; v = v->Next()) {
|
||||
v->first = this->next;
|
||||
}
|
||||
this->next->previous = NULL;
|
||||
this->next->previous = nullptr;
|
||||
}
|
||||
|
||||
this->next = next;
|
||||
|
||||
if (this->next != NULL) {
|
||||
if (this->next != nullptr) {
|
||||
/* A new next vehicle. Update the first and previous pointers */
|
||||
if (this->next->previous != NULL) this->next->previous->next = NULL;
|
||||
if (this->next->previous != nullptr) this->next->previous->next = nullptr;
|
||||
this->next->previous = this;
|
||||
for (Vehicle *v = this->next; v != NULL; v = v->Next()) {
|
||||
for (Vehicle *v = this->next; v != nullptr; v = v->Next()) {
|
||||
v->first = this->first;
|
||||
}
|
||||
}
|
||||
@@ -3574,26 +3574,26 @@ void Vehicle::SetNext(Vehicle *next)
|
||||
|
||||
void Vehicle::ClearSeparation()
|
||||
{
|
||||
if (this->ahead_separation == NULL && this->behind_separation == NULL) return;
|
||||
if (this->ahead_separation == nullptr && this->behind_separation == nullptr) return;
|
||||
|
||||
assert(this->ahead_separation != NULL);
|
||||
assert(this->behind_separation != NULL);
|
||||
assert(this->ahead_separation != nullptr);
|
||||
assert(this->behind_separation != nullptr);
|
||||
|
||||
this->ahead_separation->behind_separation = this->behind_separation;
|
||||
this->behind_separation->ahead_separation = this->ahead_separation;
|
||||
|
||||
this->ahead_separation = NULL;
|
||||
this->behind_separation = NULL;
|
||||
this->ahead_separation = nullptr;
|
||||
this->behind_separation = nullptr;
|
||||
|
||||
SetWindowDirty(WC_VEHICLE_TIMETABLE, this->index);
|
||||
}
|
||||
|
||||
void Vehicle::InitSeparation()
|
||||
{
|
||||
assert(this->ahead_separation == NULL && this->behind_separation == NULL);
|
||||
assert(this->ahead_separation == nullptr && this->behind_separation == nullptr);
|
||||
Vehicle *best_match = this;
|
||||
int lowest_separation;
|
||||
for (Vehicle *v_other = this->FirstShared(); v_other != NULL; v_other = v_other->NextShared()) {
|
||||
for (Vehicle *v_other = this->FirstShared(); v_other != nullptr; v_other = v_other->NextShared()) {
|
||||
if ((HasBit(v_other->vehicle_flags, VF_TIMETABLE_STARTED)) && v_other != this) {
|
||||
if (best_match == this) {
|
||||
best_match = v_other;
|
||||
@@ -3612,8 +3612,8 @@ void Vehicle::InitSeparation()
|
||||
|
||||
void Vehicle::AddToSeparationBehind(Vehicle *v_other)
|
||||
{
|
||||
if (v_other->ahead_separation == NULL) v_other->ahead_separation = v_other;
|
||||
if (v_other->behind_separation == NULL) v_other->behind_separation = v_other;
|
||||
if (v_other->ahead_separation == nullptr) v_other->ahead_separation = v_other;
|
||||
if (v_other->behind_separation == nullptr) v_other->behind_separation = v_other;
|
||||
|
||||
this->ahead_separation = v_other;
|
||||
v_other->behind_separation->ahead_separation = this;
|
||||
@@ -3628,12 +3628,12 @@ void Vehicle::AddToSeparationBehind(Vehicle *v_other)
|
||||
*/
|
||||
void Vehicle::AddToShared(Vehicle *shared_chain)
|
||||
{
|
||||
assert(this->previous_shared == NULL && this->next_shared == NULL);
|
||||
assert(this->previous_shared == nullptr && this->next_shared == nullptr);
|
||||
|
||||
if (shared_chain->orders.list == NULL) {
|
||||
assert(shared_chain->previous_shared == NULL);
|
||||
assert(shared_chain->next_shared == NULL);
|
||||
this->orders.list = shared_chain->orders.list = new OrderList(NULL, shared_chain);
|
||||
if (shared_chain->orders.list == nullptr) {
|
||||
assert(shared_chain->previous_shared == nullptr);
|
||||
assert(shared_chain->next_shared == nullptr);
|
||||
this->orders.list = shared_chain->orders.list = new OrderList(nullptr, shared_chain);
|
||||
}
|
||||
|
||||
this->next_shared = shared_chain->next_shared;
|
||||
@@ -3641,7 +3641,7 @@ void Vehicle::AddToShared(Vehicle *shared_chain)
|
||||
|
||||
shared_chain->next_shared = this;
|
||||
|
||||
if (this->next_shared != NULL) this->next_shared->previous_shared = this;
|
||||
if (this->next_shared != nullptr) this->next_shared->previous_shared = this;
|
||||
|
||||
shared_chain->orders.list->AddVehicle(this);
|
||||
}
|
||||
@@ -3663,7 +3663,7 @@ void Vehicle::RemoveFromShared()
|
||||
this->previous_shared->next_shared = this->NextShared();
|
||||
}
|
||||
|
||||
if (this->next_shared != NULL) this->next_shared->previous_shared = this->previous_shared;
|
||||
if (this->next_shared != nullptr) this->next_shared->previous_shared = this->previous_shared;
|
||||
|
||||
|
||||
if (this->orders.list->GetNumVehicles() == 1) InvalidateVehicleOrder(this->FirstShared(), VIWD_MODIFY_ORDERS);
|
||||
@@ -3677,8 +3677,8 @@ void Vehicle::RemoveFromShared()
|
||||
InvalidateWindowData(GetWindowClassForVehicleType(this->type), vli.Pack(), this->FirstShared()->index | (1U << 31));
|
||||
}
|
||||
|
||||
this->next_shared = NULL;
|
||||
this->previous_shared = NULL;
|
||||
this->next_shared = nullptr;
|
||||
this->previous_shared = nullptr;
|
||||
|
||||
this->ClearSeparation();
|
||||
if (HasBit(this->vehicle_flags, VF_TIMETABLE_SEPARATION)) ClrBit(this->vehicle_flags, VF_TIMETABLE_STARTED);
|
||||
@@ -3817,7 +3817,7 @@ void VehiclesYearlyLoop()
|
||||
bool CanVehicleUseStation(EngineID engine_type, const Station *st)
|
||||
{
|
||||
const Engine *e = Engine::GetIfValid(engine_type);
|
||||
assert(e != NULL);
|
||||
assert(e != nullptr);
|
||||
|
||||
switch (e->type) {
|
||||
case VEH_TRAIN:
|
||||
@@ -3849,7 +3849,7 @@ bool CanVehicleUseStation(EngineID engine_type, const Station *st)
|
||||
*/
|
||||
bool CanVehicleUseStation(const Vehicle *v, const Station *st)
|
||||
{
|
||||
if (v->type == VEH_ROAD) return st->GetPrimaryRoadStop(RoadVehicle::From(v)) != NULL;
|
||||
if (v->type == VEH_ROAD) return st->GetPrimaryRoadStop(RoadVehicle::From(v)) != nullptr;
|
||||
|
||||
return CanVehicleUseStation(v->engine_type, st);
|
||||
}
|
||||
@@ -3930,7 +3930,7 @@ void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8 num_vehicles)
|
||||
u = u->GetFirstEnginePart();
|
||||
|
||||
/* Include num_vehicles vehicles, not counting articulated parts */
|
||||
for (; u != NULL && num_vehicles > 0; num_vehicles--) {
|
||||
for (; u != nullptr && num_vehicles > 0; num_vehicles--) {
|
||||
do {
|
||||
/* Include current vehicle in the selection. */
|
||||
include(set, u->index);
|
||||
@@ -3939,7 +3939,7 @@ void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8 num_vehicles)
|
||||
if (u->IsMultiheaded()) include(set, u->other_multiheaded_part->index);
|
||||
|
||||
u = u->Next();
|
||||
} while (u != NULL && u->IsArticulatedPart());
|
||||
} while (u != nullptr && u->IsArticulatedPart());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user