summaryrefslogtreecommitdiff
path: root/src/tunnelbridge_cmd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tunnelbridge_cmd.cpp')
-rw-r--r--src/tunnelbridge_cmd.cpp58
1 files changed, 29 insertions, 29 deletions
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 79011a3bd..78586b1a2 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -84,7 +84,7 @@ void ResetBridges()
{
/* First, free sprite table data */
for (BridgeType i = 0; i < MAX_BRIDGES; i++) {
- if (_bridge[i].sprite_table != NULL) {
+ if (_bridge[i].sprite_table != nullptr) {
for (BridgePieces j = BRIDGE_PIECE_NORTH; j < BRIDGE_PIECE_INVALID; j++) free(_bridge[i].sprite_table[j]);
free(_bridge[i].sprite_table);
}
@@ -150,7 +150,7 @@ static inline const PalSpriteID *GetBridgeSpriteTable(int index, BridgePieces ta
{
const BridgeSpec *bridge = GetBridgeSpec(index);
assert(table < BRIDGE_PIECE_INVALID);
- if (bridge->sprite_table == NULL || bridge->sprite_table[table] == NULL) {
+ if (bridge->sprite_table == nullptr || bridge->sprite_table[table] == nullptr) {
return _bridge_sprite_table[index][table];
} else {
return bridge->sprite_table[table];
@@ -268,7 +268,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
company = OWNER_TOWN;
/* If we are not within a town, we are not owned by the town */
- if (town == NULL || DistanceSquare(tile_start, town->xy) > town->cache.squared_town_zone_radius[HZB_TOWN_EDGE]) {
+ if (town == nullptr || DistanceSquare(tile_start, town->xy) > town->cache.squared_town_zone_radius[HZB_TOWN_EDGE]) {
company = OWNER_NONE;
}
}
@@ -329,7 +329,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
_game_mode != GM_EDITOR) {
Town *t = ClosestTownFromTile(tile_start, UINT_MAX);
- if (t == NULL) {
+ if (t == nullptr) {
return CMD_ERROR;
} else {
SetDParam(0, t->index);
@@ -479,7 +479,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
switch (transport_type) {
case TRANSPORT_RAIL:
/* Add to company infrastructure count if required. */
- if (is_new_owner && c != NULL) c->infrastructure.rail[railtype] += (bridge_len + 2) * TUNNELBRIDGE_TRACKBIT_FACTOR;
+ if (is_new_owner && c != nullptr) c->infrastructure.rail[railtype] += (bridge_len + 2) * TUNNELBRIDGE_TRACKBIT_FACTOR;
MakeRailBridgeRamp(tile_start, owner, bridge_type, dir, railtype);
MakeRailBridgeRamp(tile_end, owner, bridge_type, ReverseDiagDir(dir), railtype);
SetTunnelBridgeReservation(tile_start, pbs_reservation);
@@ -493,7 +493,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
if (HasBit(prev_roadtypes, ROADTYPE_ROAD) && GetRoadOwner(tile_start, ROADTYPE_ROAD) == OWNER_NONE) ClrBit(prev_roadtypes, ROADTYPE_ROAD);
if (HasBit(prev_roadtypes, ROADTYPE_TRAM) && GetRoadOwner(tile_start, ROADTYPE_TRAM) == OWNER_NONE) ClrBit(prev_roadtypes, ROADTYPE_TRAM);
}
- if (c != NULL) {
+ if (c != nullptr) {
/* Add all new road types to the company infrastructure counter. */
RoadType new_rt;
FOR_EACH_SET_ROADTYPE(new_rt, roadtypes ^ prev_roadtypes) {
@@ -509,7 +509,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
}
case TRANSPORT_WATER:
- if (is_new_owner && c != NULL) c->infrastructure.water += (bridge_len + 2) * TUNNELBRIDGE_TRACKBIT_FACTOR;
+ if (is_new_owner && c != nullptr) c->infrastructure.water += (bridge_len + 2) * TUNNELBRIDGE_TRACKBIT_FACTOR;
MakeAqueductBridgeRamp(tile_start, owner, dir);
MakeAqueductBridgeRamp(tile_end, owner, ReverseDiagDir(dir));
break;
@@ -534,7 +534,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
* and cost is computed in "bridge_gui.c". For AI, Towns this has to be of course calculated
*/
Company *c = Company::GetIfValid(company);
- if (!(flags & DC_QUERY_COST) || (c != NULL && c->is_ai)) {
+ if (!(flags & DC_QUERY_COST) || (c != nullptr && c->is_ai)) {
bridge_len += 2; // begin and end tiles/ramps
switch (transport_type) {
@@ -543,7 +543,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
default: break;
}
- if (c != NULL) bridge_len = CalcBridgeLenCostFactor(bridge_len);
+ if (c != nullptr) bridge_len = CalcBridgeLenCostFactor(bridge_len);
if (transport_type != TRANSPORT_WATER) {
cost.AddCost((int64)bridge_len * _price[PR_BUILD_BRIDGE] * GetBridgeSpec(bridge_type)->price >> 8);
@@ -598,7 +598,7 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1,
company = OWNER_TOWN;
/* If we are not within a town, we are not owned by the town */
- if (town == NULL || DistanceSquare(start_tile, town->xy) > town->cache.squared_town_zone_radius[HZB_TOWN_EDGE]) {
+ if (town == nullptr || DistanceSquare(start_tile, town->xy) > town->cache.squared_town_zone_radius[HZB_TOWN_EDGE]) {
company = OWNER_NONE;
}
}
@@ -680,7 +680,7 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1,
/* Mark the tile as already cleared for the terraform command.
* Do this for all tiles (like trees), not only objects. */
ClearedObjectArea *coa = FindClearedObject(end_tile);
- if (coa == NULL) {
+ if (coa == nullptr) {
/*C++17: coa = &*/ _cleared_object_areas.push_back({end_tile, TileArea(end_tile, 1, 1)});
coa = &_cleared_object_areas.back();
}
@@ -702,7 +702,7 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1,
assert(coa >= begin && coa < begin + _cleared_object_areas.size());
size_t coa_index = coa - begin;
assert(coa_index < UINT_MAX); // more than 2**32 cleared areas would be a bug in itself
- coa = NULL;
+ coa = nullptr;
ret = DoCommand(end_tile, end_tileh & start_tileh, 0, flags, CMD_TERRAFORM_LAND);
_cleared_object_areas[(uint)coa_index].first_tile = old_first_tile;
@@ -722,13 +722,13 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1,
Company *c = Company::GetIfValid(company);
uint num_pieces = (tiles + 2) * TUNNELBRIDGE_TRACKBIT_FACTOR;
if (transport_type == TRANSPORT_RAIL) {
- if (!IsTunnelTile(start_tile) && c != NULL) c->infrastructure.rail[railtype] += num_pieces;
+ if (!IsTunnelTile(start_tile) && c != nullptr) c->infrastructure.rail[railtype] += num_pieces;
MakeRailTunnel(start_tile, company, direction, railtype);
MakeRailTunnel(end_tile, company, ReverseDiagDir(direction), railtype);
AddSideToSignalBuffer(start_tile, INVALID_DIAGDIR, company);
YapfNotifyTrackLayoutChange(start_tile, DiagDirToDiagTrack(direction));
} else {
- if (c != NULL) {
+ if (c != nullptr) {
RoadType rt;
FOR_EACH_SET_ROADTYPE(rt, rts ^ (IsTunnelTile(start_tile) ? GetRoadTypes(start_tile) : ROADTYPES_NONE)) {
c->infrastructure.road[rt] += num_pieces * 2; // A full diagonal road has two road bits.
@@ -808,7 +808,7 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
_build_tunnel_endtile = endtile;
- Town *t = NULL;
+ Town *t = nullptr;
if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) {
t = ClosestTownFromTile(tile, UINT_MAX); // town penalty rating
@@ -833,10 +833,10 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
Track track = DiagDirToDiagTrack(dir);
Owner owner = GetTileOwner(tile);
- Train *v = NULL;
+ Train *v = nullptr;
if (HasTunnelBridgeReservation(tile)) {
v = GetTrainForReservation(tile, track);
- if (v != NULL) FreeTrainTrackReservation(v);
+ if (v != nullptr) FreeTrainTrackReservation(v);
}
if (Company::IsValidID(owner)) {
@@ -854,13 +854,13 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
YapfNotifyTrackLayoutChange(tile, track);
YapfNotifyTrackLayoutChange(endtile, track);
- if (v != NULL) TryPathReserve(v);
+ if (v != nullptr) TryPathReserve(v);
} else {
RoadType rt;
FOR_EACH_SET_ROADTYPE(rt, GetRoadTypes(tile)) {
/* A full diagonal road tile has two road bits. */
Company *c = Company::GetIfValid(GetRoadOwner(tile, rt));
- if (c != NULL) {
+ if (c != nullptr) {
c->infrastructure.road[rt] -= len * 2 * TUNNELBRIDGE_TRACKBIT_FACTOR;
DirtyCompanyInfrastructureWindows(c->index);
}
@@ -893,7 +893,7 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
DiagDirection direction = GetTunnelBridgeDirection(tile);
TileIndexDiff delta = TileOffsByDiagDir(direction);
- Town *t = NULL;
+ Town *t = nullptr;
if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) {
t = ClosestTownFromTile(tile, UINT_MAX); // town penalty rating
@@ -917,11 +917,11 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
bool rail = GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL;
Owner owner = GetTileOwner(tile);
int height = GetBridgeHeight(tile);
- Train *v = NULL;
+ Train *v = nullptr;
if (rail && HasTunnelBridgeReservation(tile)) {
v = GetTrainForReservation(tile, DiagDirToDiagTrack(direction));
- if (v != NULL) FreeTrainTrackReservation(v);
+ if (v != nullptr) FreeTrainTrackReservation(v);
}
/* Update company infrastructure counts. */
@@ -931,7 +931,7 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
RoadType rt;
FOR_EACH_SET_ROADTYPE(rt, GetRoadTypes(tile)) {
Company *c = Company::GetIfValid(GetRoadOwner(tile, rt));
- if (c != NULL) {
+ if (c != nullptr) {
/* A full diagonal road tile has two road bits. */
c->infrastructure.road[rt] -= len * 2 * TUNNELBRIDGE_TRACKBIT_FACTOR;
DirtyCompanyInfrastructureWindows(c->index);
@@ -963,7 +963,7 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
YapfNotifyTrackLayoutChange(tile, track);
YapfNotifyTrackLayoutChange(endtile, track);
- if (v != NULL) TryPathReserve(v, true);
+ if (v != nullptr) TryPathReserve(v, true);
}
}
@@ -1018,7 +1018,7 @@ static int DrawPillarColumn(int z_bottom, int z_top, const PalSpriteID *psid, in
{
int cur_z;
for (cur_z = z_top; cur_z >= z_bottom; cur_z -= TILE_HEIGHT) {
- DrawPillar(psid, x, y, cur_z, w, h, NULL);
+ DrawPillar(psid, x, y, cur_z, w, h, nullptr);
}
return cur_z;
}
@@ -1906,14 +1906,14 @@ extern const TileTypeProcs _tile_type_tunnelbridge_procs = {
DrawTile_TunnelBridge, // draw_tile_proc
GetSlopePixelZ_TunnelBridge, // get_slope_z_proc
ClearTile_TunnelBridge, // clear_tile_proc
- NULL, // add_accepted_cargo_proc
+ nullptr, // add_accepted_cargo_proc
GetTileDesc_TunnelBridge, // get_tile_desc_proc
GetTileTrackStatus_TunnelBridge, // get_tile_track_status_proc
- NULL, // click_tile_proc
- NULL, // animate_tile_proc
+ nullptr, // click_tile_proc
+ nullptr, // animate_tile_proc
TileLoop_TunnelBridge, // tile_loop_proc
ChangeTileOwner_TunnelBridge, // change_tile_owner_proc
- NULL, // add_produced_cargo_proc
+ nullptr, // add_produced_cargo_proc
VehicleEnter_TunnelBridge, // vehicle_enter_tile_proc
GetFoundation_TunnelBridge, // get_foundation_proc
TerraformTile_TunnelBridge, // terraform_tile_proc