summaryrefslogtreecommitdiff
path: root/src/rail_cmd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rail_cmd.cpp')
-rw-r--r--src/rail_cmd.cpp62
1 files changed, 31 insertions, 31 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 4257b5258..d8327c444 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -622,7 +622,7 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1,
* so do not call GetTileOwner(tile) in any case here */
Owner owner = INVALID_OWNER;
- Train *v = NULL;
+ Train *v = nullptr;
switch (GetTileType(tile)) {
case MP_ROAD: {
@@ -643,7 +643,7 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (flags & DC_EXEC) {
if (HasReservedTracks(tile, trackbit)) {
v = GetTrainForReservation(tile, track);
- if (v != NULL) FreeTrainTrackReservation(v);
+ if (v != nullptr) FreeTrainTrackReservation(v);
}
owner = GetTileOwner(tile);
Company::Get(owner)->infrastructure.rail[GetRailType(tile)] -= LEVELCROSSING_TRACKBIT_FACTOR;
@@ -681,7 +681,7 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (flags & DC_EXEC) {
if (HasReservedTracks(tile, trackbit)) {
v = GetTrainForReservation(tile, track);
- if (v != NULL) FreeTrainTrackReservation(v);
+ if (v != nullptr) FreeTrainTrackReservation(v);
}
owner = GetTileOwner(tile);
@@ -736,7 +736,7 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1,
YapfNotifyTrackLayoutChange(tile, track);
}
- if (v != NULL) TryPathReserve(v, true);
+ if (v != nullptr) TryPathReserve(v, true);
}
return cost;
@@ -1095,13 +1095,13 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1,
}
if (flags & DC_EXEC) {
- Train *v = NULL;
+ Train *v = nullptr;
/* The new/changed signal could block our path. As this can lead to
* stale reservations, we clear the path reservation here and try
* to redo it later on. */
if (HasReservedTracks(tile, TrackToTrackBits(track))) {
v = GetTrainForReservation(tile, track);
- if (v != NULL) FreeTrainTrackReservation(v);
+ if (v != nullptr) FreeTrainTrackReservation(v);
}
if (!HasSignals(tile)) {
@@ -1177,7 +1177,7 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1,
MarkTileDirtyByTile(tile);
AddTrackToSignalBuffer(tile, track, _current_company);
YapfNotifyTrackLayoutChange(tile, track);
- if (v != NULL) {
+ if (v != nullptr) {
/* Extend the train's path if it's not stopped or loading, or not at a safe position. */
if (!(((v->vehstatus & VS_STOPPED) && v->cur_speed == 0) || v->current_order.IsType(OT_LOADING)) ||
!IsSafeWaitingPosition(v, v->tile, v->GetVehicleTrackdir(), true, _settings_game.pf.forbid_90_deg)) {
@@ -1467,13 +1467,13 @@ CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1
/* Do it? */
if (flags & DC_EXEC) {
- Train *v = NULL;
+ Train *v = nullptr;
if (HasReservedTracks(tile, TrackToTrackBits(track))) {
v = GetTrainForReservation(tile, track);
} else if (IsPbsSignal(GetSignalType(tile, track))) {
/* PBS signal, might be the end of a path reservation. */
Trackdir td = TrackToTrackdir(track);
- for (int i = 0; v == NULL && i < 2; i++, td = ReverseTrackdir(td)) {
+ for (int i = 0; v == nullptr && i < 2; i++, td = ReverseTrackdir(td)) {
/* Only test the active signal side. */
if (!HasSignalOnTrackdir(tile, ReverseTrackdir(td))) continue;
TileIndex next = TileAddByDiagDir(tile, TrackdirToExitdir(td));
@@ -1497,7 +1497,7 @@ CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1
AddTrackToSignalBuffer(tile, track, GetTileOwner(tile));
YapfNotifyTrackLayoutChange(tile, track);
- if (v != NULL) TryPathReserve(v, false);
+ if (v != nullptr) TryPathReserve(v, false);
MarkTileDirtyByTile(tile);
}
@@ -1531,12 +1531,12 @@ CommandCost CmdRemoveSignalTrack(TileIndex tile, DoCommandFlag flags, uint32 p1,
/** Update power of train under which is the railtype being converted */
static Vehicle *UpdateTrainPowerProc(Vehicle *v, void *data)
{
- if (v->type != VEH_TRAIN) return NULL;
+ if (v->type != VEH_TRAIN) return nullptr;
TrainList *affected_trains = static_cast<TrainList*>(data);
include(*affected_trains, Train::From(v)->First());
- return NULL;
+ return nullptr;
}
/**
@@ -1620,7 +1620,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
Track track;
while ((track = RemoveFirstTrack(&reserved)) != INVALID_TRACK) {
Train *v = GetTrainForReservation(tile, track);
- if (v != NULL && !HasPowerOnRail(v->railtype, totype)) {
+ if (v != nullptr && !HasPowerOnRail(v->railtype, totype)) {
/* No power on new rail type, reroute. */
FreeTrainTrackReservation(v);
vehicles_affected.push_back(v);
@@ -1702,7 +1702,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
Track track = DiagDirToDiagTrack(GetTunnelBridgeDirection(tile));
if (HasTunnelBridgeReservation(tile)) {
Train *v = GetTrainForReservation(tile, track);
- if (v != NULL && !HasPowerOnRail(v->railtype, totype)) {
+ if (v != nullptr && !HasPowerOnRail(v->railtype, totype)) {
/* No power on new rail type, reroute. */
FreeTrainTrackReservation(v);
vehicles_affected.push_back(v);
@@ -1777,11 +1777,11 @@ static CommandCost RemoveTrainDepot(TileIndex tile, DoCommandFlag flags)
/* read variables before the depot is removed */
DiagDirection dir = GetRailDepotDirection(tile);
Owner owner = GetTileOwner(tile);
- Train *v = NULL;
+ Train *v = nullptr;
if (HasDepotReservation(tile)) {
v = GetTrainForReservation(tile, DiagDirToDiagTrack(dir));
- if (v != NULL) FreeTrainTrackReservation(v);
+ if (v != nullptr) FreeTrainTrackReservation(v);
}
Company::Get(owner)->infrastructure.rail[GetRailType(tile)]--;
@@ -1791,7 +1791,7 @@ static CommandCost RemoveTrainDepot(TileIndex tile, DoCommandFlag flags)
DoClearSquare(tile);
AddSideToSignalBuffer(tile, dir, owner);
YapfNotifyTrackLayoutChange(tile, DiagDirToDiagTrack(dir));
- if (v != NULL) TryPathReserve(v, true);
+ if (v != nullptr) TryPathReserve(v, true);
}
return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_DEPOT_TRAIN]);
@@ -2064,7 +2064,7 @@ static const SubSprite _halftile_sub_sprite[4] = {
static inline void DrawTrackSprite(SpriteID sprite, PaletteID pal, const TileInfo *ti, Slope s)
{
- DrawGroundSprite(sprite, pal, NULL, 0, (ti->tileh & s) ? -8 : 0);
+ DrawGroundSprite(sprite, pal, nullptr, 0, (ti->tileh & s) ? -8 : 0);
}
static void DrawTrackBitsOverlay(TileInfo *ti, TrackBits track, const RailtypeInfo *rti)
@@ -2258,7 +2258,7 @@ static void DrawTrackBits(TileInfo *ti, TrackBits track)
SpriteID image;
PaletteID pal = PAL_NONE;
- const SubSprite *sub = NULL;
+ const SubSprite *sub = nullptr;
bool junction = false;
/* Select the sprite to use. */
@@ -2355,10 +2355,10 @@ static void DrawTrackBits(TileInfo *ti, TrackBits track)
DrawGroundSprite(_track_sloped_sprites[ti->tileh - 1] + rti->base_sprites.single_sloped - 20, PALETTE_CRASH);
}
}
- if (pbs & TRACK_BIT_UPPER) DrawGroundSprite(rti->base_sprites.single_n, PALETTE_CRASH, NULL, 0, ti->tileh & SLOPE_N ? -(int)TILE_HEIGHT : 0);
- if (pbs & TRACK_BIT_LOWER) DrawGroundSprite(rti->base_sprites.single_s, PALETTE_CRASH, NULL, 0, ti->tileh & SLOPE_S ? -(int)TILE_HEIGHT : 0);
- if (pbs & TRACK_BIT_LEFT) DrawGroundSprite(rti->base_sprites.single_w, PALETTE_CRASH, NULL, 0, ti->tileh & SLOPE_W ? -(int)TILE_HEIGHT : 0);
- if (pbs & TRACK_BIT_RIGHT) DrawGroundSprite(rti->base_sprites.single_e, PALETTE_CRASH, NULL, 0, ti->tileh & SLOPE_E ? -(int)TILE_HEIGHT : 0);
+ if (pbs & TRACK_BIT_UPPER) DrawGroundSprite(rti->base_sprites.single_n, PALETTE_CRASH, nullptr, 0, ti->tileh & SLOPE_N ? -(int)TILE_HEIGHT : 0);
+ if (pbs & TRACK_BIT_LOWER) DrawGroundSprite(rti->base_sprites.single_s, PALETTE_CRASH, nullptr, 0, ti->tileh & SLOPE_S ? -(int)TILE_HEIGHT : 0);
+ if (pbs & TRACK_BIT_LEFT) DrawGroundSprite(rti->base_sprites.single_w, PALETTE_CRASH, nullptr, 0, ti->tileh & SLOPE_W ? -(int)TILE_HEIGHT : 0);
+ if (pbs & TRACK_BIT_RIGHT) DrawGroundSprite(rti->base_sprites.single_e, PALETTE_CRASH, nullptr, 0, ti->tileh & SLOPE_E ? -(int)TILE_HEIGHT : 0);
}
if (IsValidCorner(halftile_corner)) {
@@ -2378,7 +2378,7 @@ static void DrawTrackBits(TileInfo *ti, TrackBits track)
if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasReservedTracks(ti->tile, CornerToTrackBits(halftile_corner))) {
static const byte _corner_to_track_sprite[] = {3, 1, 2, 0};
- DrawGroundSprite(_corner_to_track_sprite[halftile_corner] + rti->base_sprites.single_n, PALETTE_CRASH, NULL, 0, -(int)TILE_HEIGHT);
+ DrawGroundSprite(_corner_to_track_sprite[halftile_corner] + rti->base_sprites.single_n, PALETTE_CRASH, nullptr, 0, -(int)TILE_HEIGHT);
}
}
}
@@ -2958,7 +2958,7 @@ static VehicleEnterTileStatus VehicleEnter_Track(Vehicle *u, TileIndex tile, int
if (fract_coord_leave == fract_coord) {
/* Leave the depot. */
- if ((v = v->Next()) != NULL) {
+ if ((v = v->Next()) != nullptr) {
v->vehstatus &= ~VS_HIDDEN;
v->track = (DiagDirToAxis(dir) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y);
}
@@ -2969,7 +2969,7 @@ static VehicleEnterTileStatus VehicleEnter_Track(Vehicle *u, TileIndex tile, int
v->track = TRACK_BIT_DEPOT,
v->vehstatus |= VS_HIDDEN;
v->direction = ReverseDir(v->direction);
- if (v->Next() == NULL) VehicleEnterDepot(v->First());
+ if (v->Next() == nullptr) VehicleEnterDepot(v->First());
v->tile = tile;
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
@@ -3034,7 +3034,7 @@ static CommandCost TestAutoslopeOnRailTile(TileIndex tile, uint flags, int z_old
*/
static Vehicle *EnsureNoShipProc(Vehicle *v, void *data)
{
- return v->type == VEH_SHIP ? v : NULL;
+ return v->type == VEH_SHIP ? v : nullptr;
}
static CommandCost TerraformTile_Track(TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new)
@@ -3047,7 +3047,7 @@ static CommandCost TerraformTile_Track(TileIndex tile, DoCommandFlag flags, int
bool was_water = (GetRailGroundType(tile) == RAIL_GROUND_WATER && IsSlopeWithOneCornerRaised(tileh_old));
/* Allow clearing the water only if there is no ship */
- if (was_water && HasVehicleOnPos(tile, NULL, &EnsureNoShipProc)) return_cmd_error(STR_ERROR_SHIP_IN_THE_WAY);
+ if (was_water && HasVehicleOnPos(tile, nullptr, &EnsureNoShipProc)) return_cmd_error(STR_ERROR_SHIP_IN_THE_WAY);
/* First test autoslope. However if it succeeds we still have to test the rest, because non-autoslope terraforming is cheaper. */
CommandCost autoslope_result = TestAutoslopeOnRailTile(tile, flags, z_old, tileh_old, z_new, tileh_new, rail_bits);
@@ -3090,14 +3090,14 @@ extern const TileTypeProcs _tile_type_rail_procs = {
DrawTile_Track, // draw_tile_proc
GetSlopePixelZ_Track, // get_slope_z_proc
ClearTile_Track, // clear_tile_proc
- NULL, // add_accepted_cargo_proc
+ nullptr, // add_accepted_cargo_proc
GetTileDesc_Track, // get_tile_desc_proc
GetTileTrackStatus_Track, // get_tile_track_status_proc
ClickTile_Track, // click_tile_proc
- NULL, // animate_tile_proc
+ nullptr, // animate_tile_proc
TileLoop_Track, // tile_loop_proc
ChangeTileOwner_Track, // change_tile_owner_proc
- NULL, // add_produced_cargo_proc
+ nullptr, // add_produced_cargo_proc
VehicleEnter_Track, // vehicle_enter_tile_proc
GetFoundation_Track, // get_foundation_proc
TerraformTile_Track, // terraform_tile_proc