summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ai/trolly/pathfinder.cpp11
-rw-r--r--src/elrail.cpp14
-rw-r--r--src/npf.cpp23
-rw-r--r--src/openttd.cpp10
-rw-r--r--src/pathfind.cpp13
-rw-r--r--src/rail.cpp6
-rw-r--r--src/rail_cmd.cpp20
-rw-r--r--src/rail_gui.cpp8
-rw-r--r--src/road_cmd.cpp23
-rw-r--r--src/road_map.cpp9
-rw-r--r--src/roadveh_cmd.cpp7
-rw-r--r--src/smallmap_gui.cpp7
-rw-r--r--src/town_cmd.cpp6
-rw-r--r--src/train_cmd.cpp4
-rw-r--r--src/tunnelbridge_cmd.cpp99
15 files changed, 77 insertions, 183 deletions
diff --git a/src/ai/trolly/pathfinder.cpp b/src/ai/trolly/pathfinder.cpp
index 33383a560..bfd4a0799 100644
--- a/src/ai/trolly/pathfinder.cpp
+++ b/src/ai/trolly/pathfinder.cpp
@@ -45,10 +45,7 @@ static bool IsRoad(TileIndex tile)
return
// MP_ROAD, but not a road depot?
(IsTileType(tile, MP_ROAD) && !IsTileDepotType(tile, TRANSPORT_ROAD)) ||
- (IsTileType(tile, MP_TUNNELBRIDGE) && (
- (IsTunnel(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD) ||
- (IsBridge(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD)
- ));
+ (IsTileType(tile, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD);
}
@@ -236,11 +233,7 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr
// If the next step is a bridge, we have to enter it the right way
if (!PathFinderInfo->rail_or_road && IsRoad(atile)) {
if (IsTileType(atile, MP_TUNNELBRIDGE)) {
- if (IsTunnel(atile)) {
- if (GetTunnelBridgeDirection(atile) != i) continue;
- } else {
- if (GetTunnelBridgeDirection(atile) != i) continue;
- }
+ if (GetTunnelBridgeDirection(atile) != i) continue;
}
}
diff --git a/src/elrail.cpp b/src/elrail.cpp
index fd6e47fec..1aedb056a 100644
--- a/src/elrail.cpp
+++ b/src/elrail.cpp
@@ -93,17 +93,11 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
break;
case MP_TUNNELBRIDGE:
- if (IsTunnel(t)) {
- if (GetRailType(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE;
- if (override != NULL) *override = 1 << GetTunnelBridgeDirection(t);
- return AxisToTrackBits(DiagDirToAxis(GetTunnelBridgeDirection(t)));
- } else {
- if (GetRailType(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE;
- if (override != NULL && DistanceMax(t, GetOtherBridgeEnd(t)) > 1) {
- *override = 1 << GetTunnelBridgeDirection(t);
- }
- return AxisToTrackBits(DiagDirToAxis(GetTunnelBridgeDirection(t)));
+ if (GetRailType(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE;
+ if (override != NULL && (IsTunnel(t) || DistanceMax(t, GetOtherBridgeEnd(t)) > 1)) {
+ *override = 1 << GetTunnelBridgeDirection(t);
}
+ return AxisToTrackBits(DiagDirToAxis(GetTunnelBridgeDirection(t)));
case MP_ROAD:
if (GetRoadTileType(t) != ROAD_TILE_CROSSING) return TRACK_BIT_NONE;
diff --git a/src/npf.cpp b/src/npf.cpp
index 696484e03..15120dc4e 100644
--- a/src/npf.cpp
+++ b/src/npf.cpp
@@ -481,8 +481,7 @@ static bool VehicleMayEnterTile(Owner owner, TileIndex tile, DiagDirection enter
break;
case MP_TUNNELBRIDGE:
- if ((IsTunnel(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) ||
- (IsBridge(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL)) {
+ if (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) {
return IsTileOwner(tile, owner);
}
break;
@@ -534,14 +533,11 @@ static void NPFFollowTrack(AyStar* aystar, OpenListNode* current)
DEBUG(npf, 4, "Expanding: (%d, %d, %d) [%d]", TileX(src_tile), TileY(src_tile), src_trackdir, src_tile);
/* Find dest tile */
- if (IsTunnelTile(src_tile) && GetTunnelBridgeDirection(src_tile) == src_exitdir) {
- /* This is a tunnel. We know this tunnel is our type,
+ if (IsTileType(src_tile, MP_TUNNELBRIDGE) && GetTunnelBridgeDirection(src_tile) == src_exitdir) {
+ /* This is a tunnel/bridge. We know this tunnel/bridge is our type,
* otherwise we wouldn't have got here. It is also facing us,
* so we should skip it's body */
- dst_tile = GetOtherTunnelEnd(src_tile);
- override_dst_check = true;
- } else if (IsBridgeTile(src_tile) && GetTunnelBridgeDirection(src_tile) == src_exitdir) {
- dst_tile = GetOtherBridgeEnd(src_tile);
+ dst_tile = IsTunnel(src_tile) ? GetOtherTunnelEnd(src_tile) : GetOtherBridgeEnd(src_tile);
override_dst_check = true;
} else if (type != TRANSPORT_WATER && (IsStandardRoadStopTile(src_tile) || IsTileDepotType(src_tile, type))) {
/* This is a road station (non drive-through) or a train or road depot. We can enter and exit
@@ -590,14 +586,9 @@ static void NPFFollowTrack(AyStar* aystar, OpenListNode* current)
/* I can't enter a tunnel entry/exit tile from a tile above the tunnel. Note
* that I can enter the tunnel from a tile below the tunnel entrance. This
* solves the problem of vehicles wanting to drive off a tunnel entrance */
- if (!override_dst_check) {
- if (IsTileType(dst_tile, MP_TUNNELBRIDGE)) {
- if (IsTunnel(dst_tile)) {
- if (GetTunnelBridgeDirection(dst_tile) != src_exitdir) return;
- } else {
- if (GetTunnelBridgeDirection(dst_tile) != src_exitdir) return;
- }
- }
+ if (!override_dst_check && IsTileType(dst_tile, MP_TUNNELBRIDGE) &&
+ GetTunnelBridgeDirection(dst_tile) != src_exitdir) {
+ return;
}
/* check correct rail type (mono, maglev, etc) */
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 77d3bb2a4..2c0f1a0ec 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -1759,14 +1759,8 @@ bool AfterLoadGame()
break;
case MP_TUNNELBRIDGE:
- if (IsTunnel(t)) {
- if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) {
- SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
- }
- } else {
- if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) {
- SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
- }
+ if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) {
+ SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
}
break;
diff --git a/src/pathfind.cpp b/src/pathfind.cpp
index 4cefc7125..988c2b737 100644
--- a/src/pathfind.cpp
+++ b/src/pathfind.cpp
@@ -260,16 +260,9 @@ static inline void TPFMode1_NormalCase(TrackPathFinder* tpf, TileIndex tile, Til
/* Check if the new tile is a tunnel or bridge head and that the direction
* and transport type match */
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
- if (IsTunnel(tile)) {
- if (GetTunnelBridgeDirection(tile) != direction ||
- GetTunnelBridgeTransportType(tile) != tpf->tracktype) {
- return;
- }
- } else if (IsBridge(tile)) {
- if (GetTunnelBridgeDirection(tile) != direction ||
- GetTunnelBridgeTransportType(tile) != tpf->tracktype) {
- return;
- }
+ if (GetTunnelBridgeDirection(tile) != direction ||
+ GetTunnelBridgeTransportType(tile) != tpf->tracktype) {
+ return;
}
}
diff --git a/src/rail.cpp b/src/rail.cpp
index f3f62175f..ba5228ee5 100644
--- a/src/rail.cpp
+++ b/src/rail.cpp
@@ -132,11 +132,7 @@ RailType GetTileRailType(TileIndex tile)
break;
case MP_TUNNELBRIDGE:
- if (IsTunnel(tile)) {
- if (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) return GetRailType(tile);
- } else {
- if (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) return GetRailType(tile);
- }
+ if (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) return GetRailType(tile);
break;
default:
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 793d9363f..454e4b30e 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -926,17 +926,15 @@ static bool CheckSignalAutoFill(TileIndex &tile, Trackdir &trackdir, int &signal
return true;
case MP_TUNNELBRIDGE: {
- TileIndex orig_tile = tile;
- /* Skip to end of tunnel or bridge */
- if (IsBridge(tile)) {
- if (GetTunnelBridgeTransportType(tile) != TRANSPORT_RAIL) return false;
- if (GetTunnelBridgeDirection(tile) != TrackdirToExitdir(trackdir)) return false;
- tile = GetOtherBridgeEnd(tile);
- } else {
- if (GetTunnelBridgeTransportType(tile) != TRANSPORT_RAIL) return false;
- if (GetTunnelBridgeDirection(tile) != TrackdirToExitdir(trackdir)) return false;
- tile = GetOtherTunnelEnd(tile);
- }
+ TileIndex orig_tile = tile; // backup old value
+
+ if (GetTunnelBridgeTransportType(tile) != TRANSPORT_RAIL) return false;
+ if (GetTunnelBridgeDirection(tile) != TrackdirToExitdir(trackdir)) return false;
+
+ /* Skip to end of tunnel or bridge
+ * note that tile is a parameter by reference, so it must be updated */
+ tile = IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile);
+
signal_ctr += 2 + DistanceMax(orig_tile, tile) * 2;
return true;
}
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 6b80ab81b..2b48d7a23 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -1522,12 +1522,8 @@ void SetDefaultRailGui()
RailType count[RAILTYPE_END];
memset(count, 0, sizeof(count));
for (TileIndex t = 0; t < MapSize(); t++) {
- if (IsTileType(t, MP_RAILWAY) ||
- IsLevelCrossingTile(t) ||
- IsRailwayStationTile(t) ||
- (IsTunnelTile(t) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) ||
- (IsBridgeTile(t) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL)
- ) {
+ if (IsTileType(t, MP_RAILWAY) || IsLevelCrossingTile(t) || IsRailwayStationTile(t) ||
+ (IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL)) {
count[GetRailType(t)]++;
}
}
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index df4404a05..58ad42208 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -133,15 +133,8 @@ CommandCost CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
case MP_TUNNELBRIDGE:
{
- TileIndex endtile;
- if (IsTunnel(tile)) {
- if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
- endtile = GetOtherTunnelEnd(tile);
- } else {
- if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
- endtile = GetOtherBridgeEnd(tile);
- }
-
+ if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
+ TileIndex endtile = IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile);
if (GetVehicleTunnelBridge(tile, endtile) != NULL) return CMD_ERROR;
} break;
@@ -514,15 +507,11 @@ CommandCost CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
case MP_TUNNELBRIDGE:
{
- TileIndex endtile;
- if (IsTunnel(tile)) {
- if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
- endtile = GetOtherTunnelEnd(tile);
- } else {
- if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
- endtile = GetOtherBridgeEnd(tile);
- }
+ if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
if (HasBit(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT);
+
+ TileIndex endtile = IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile);
+
/* Don't allow "upgrading" the bridge/tunnel when vehicles are already driving on it */
if (GetVehicleTunnelBridge(tile, endtile) != NULL) return CMD_ERROR;
} break;
diff --git a/src/road_map.cpp b/src/road_map.cpp
index 0bdf66dfe..4d6a1d6f8 100644
--- a/src/road_map.cpp
+++ b/src/road_map.cpp
@@ -34,13 +34,8 @@ RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt)
return DiagDirToRoadBits(GetRoadStopDir(tile));
case MP_TUNNELBRIDGE:
- if (IsTunnel(tile)) {
- if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE;
- return DiagDirToRoadBits(ReverseDiagDir(GetTunnelBridgeDirection(tile)));
- } else {
- if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE;
- return DiagDirToRoadBits(ReverseDiagDir(GetTunnelBridgeDirection(tile)));
- }
+ if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE;
+ return DiagDirToRoadBits(ReverseDiagDir(GetTunnelBridgeDirection(tile)));
default: return ROAD_NONE;
}
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 2850b2d7c..d9cdeb4d3 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -551,8 +551,7 @@ CommandCost CmdTurnRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (IsTileType(v->tile, MP_ROAD) && GetRoadTileType(v->tile) == ROAD_TILE_NORMAL && GetDisallowedRoadDirections(v->tile) != DRD_NONE) return CMD_ERROR;
- if (IsTunnelTile(v->tile) && DirToDiagDir(v->direction) == GetTunnelBridgeDirection(v->tile)) return CMD_ERROR;
- if (IsBridgeTile(v->tile) && DirToDiagDir(v->direction) == GetTunnelBridgeDirection(v->tile)) return CMD_ERROR;
+ if (IsTileType(v->tile, MP_TUNNELBRIDGE) && DirToDiagDir(v->direction) == GetTunnelBridgeDirection(v->tile)) return CMD_ERROR;
if (flags & DC_EXEC) v->u.road.reverse_ctr = 180;
@@ -1407,9 +1406,7 @@ static Trackdir FollowPreviousRoadVehicle(const Vehicle *v, const Vehicle *prev,
if (prev_state == RVSB_WORMHOLE || prev_state == RVSB_IN_DEPOT) {
DiagDirection diag_dir = INVALID_DIAGDIR;
- if (IsTunnelTile(tile)) {
- diag_dir = GetTunnelBridgeDirection(tile);
- } else if (IsBridgeTile(tile)) {
+ if (IsTileType(tile, MP_TUNNELBRIDGE)) {
diag_dir = GetTunnelBridgeDirection(tile);
} else if (IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_DEPOT) {
diag_dir = ReverseDiagDir(GetRoadDepotDirection(tile));
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index 638a43322..2208128b7 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -339,13 +339,8 @@ static inline TileType GetEffectiveTileType(TileIndex tile)
TileType t = GetTileType(tile);
if (t == MP_TUNNELBRIDGE) {
- TransportType tt;
+ TransportType tt = GetTunnelBridgeTransportType(tile);
- if (IsTunnel(tile)) {
- tt = GetTunnelBridgeTransportType(tile);
- } else {
- tt = GetTunnelBridgeTransportType(tile);
- }
switch (tt) {
case TRANSPORT_RAIL: t = MP_RAILWAY; break;
case TRANSPORT_ROAD: t = MP_ROAD; break;
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 302146081..e2eb21537 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -1064,10 +1064,8 @@ static void GrowTownInTile(TileIndex *tile_ptr, RoadBits cur_rb, DiagDirection t
/* Reached a tunnel/bridge? Then continue at the other side of it. */
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
- if (IsTunnel(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD) {
- *tile_ptr = GetOtherTunnelEnd(tile);
- } else if (IsBridge(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD) {
- *tile_ptr = GetOtherBridgeEnd(tile);
+ if (GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD) {
+ *tile_ptr = IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile);
}
return;
}
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index a3f551ec7..2b32faff3 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -3059,7 +3059,7 @@ static void DeleteLastWagon(Vehicle *v)
if (GetVehicleTunnelBridge(v->tile, endtile) != NULL) return; // tunnel / bridge is busy
- DiagDirection dir = IsTunnel(v->tile) ? GetTunnelBridgeDirection(v->tile) : GetTunnelBridgeDirection(v->tile);
+ DiagDirection dir = GetTunnelBridgeDirection(v->tile);
/* v->direction is "random", so it cannot be used to determine the direction of the track */
UpdateSignalsOnSegment(v->tile, dir);
@@ -3176,7 +3176,7 @@ static bool TrainCheckIfLineEnds(Vehicle *v)
TileIndex tile = v->tile;
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
- DiagDirection dir = IsTunnel(tile) ? GetTunnelBridgeDirection(tile) : GetTunnelBridgeDirection(tile);
+ DiagDirection dir = GetTunnelBridgeDirection(tile);
if (DiagDirToDir(dir) == v->direction) return true;
}
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 14304e624..68be57389 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -702,63 +702,39 @@ static CommandCost ClearTile_TunnelBridge(TileIndex tile, byte flags)
*/
CommandCost DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
{
- if (IsTunnel(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) {
- TileIndex endtile = GetOtherTunnelEnd(tile);
+ if (GetTunnelBridgeTransportType(tile) != TRANSPORT_RAIL) return CMD_ERROR;
- /* If not coverting rail <-> el. rail, any vehicle cannot be in tunnel */
- if (!IsCompatibleRail(GetRailType(tile), totype) &&
- GetVehicleTunnelBridge(tile, endtile) != NULL) {
- return CMD_ERROR;
- }
-
- if (exec) {
- SetRailType(tile, totype);
- SetRailType(endtile, totype);
- MarkTileDirtyByTile(tile);
- MarkTileDirtyByTile(endtile);
+ TileIndex endtile = IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile);
- Track track = AxisToTrack(DiagDirToAxis(GetTunnelBridgeDirection(tile)));
+ /* If not coverting rail <-> el. rail, any vehicle cannot be in tunnel/bridge */
+ if (!IsCompatibleRail(GetRailType(tile), totype) &&
+ GetVehicleTunnelBridge(tile, endtile) != NULL) {
+ return CMD_ERROR;
+ }
- YapfNotifyTrackLayoutChange(tile, track);
- YapfNotifyTrackLayoutChange(endtile, track);
+ if (exec) {
+ SetRailType(tile, totype);
+ SetRailType(endtile, totype);
- VehicleFromPos(tile, NULL, &UpdateTrainPowerProc);
- VehicleFromPos(endtile, NULL, &UpdateTrainPowerProc);
- }
+ Track track = AxisToTrack(DiagDirToAxis(GetTunnelBridgeDirection(tile)));
- return CommandCost((DistanceManhattan(tile, endtile) + 1) * RailConvertCost(GetRailType(tile), totype));
- } else if (IsBridge(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) {
- TileIndex endtile = GetOtherBridgeEnd(tile);
+ YapfNotifyTrackLayoutChange(tile, track);
+ YapfNotifyTrackLayoutChange(endtile, track);
- if (!IsCompatibleRail(GetRailType(tile), totype) &&
- GetVehicleTunnelBridge(tile, endtile) != NULL) {
- return CMD_ERROR;
- }
+ VehicleFromPos(tile, NULL, &UpdateTrainPowerProc);
+ VehicleFromPos(endtile, NULL, &UpdateTrainPowerProc);
- if (exec) {
- SetRailType(tile, totype);
- SetRailType(endtile, totype);
- MarkTileDirtyByTile(tile);
- MarkTileDirtyByTile(endtile);
+ MarkTileDirtyByTile(tile);
+ MarkTileDirtyByTile(endtile);
- Track track = AxisToTrack(DiagDirToAxis(GetTunnelBridgeDirection(tile)));
+ if (IsBridge(tile)) {
TileIndexDiff delta = TileOffsByDiagDir(GetTunnelBridgeDirection(tile));
-
- YapfNotifyTrackLayoutChange(tile, track);
- YapfNotifyTrackLayoutChange(endtile, track);
-
- VehicleFromPos(tile, NULL, &UpdateTrainPowerProc);
- VehicleFromPos(endtile, NULL, &UpdateTrainPowerProc);
-
- for (tile += delta; tile != endtile; tile += delta) {
- MarkTileDirtyByTile(tile); // TODO encapsulate this into a function
- }
+ TileIndex t = tile + delta;
+ for (; t != endtile; t += delta) MarkTileDirtyByTile(t); // TODO encapsulate this into a function
}
-
- return CommandCost((DistanceManhattan(tile, endtile) + 1) * RailConvertCost(GetRailType(tile), totype));
- } else {
- return CMD_ERROR;
}
+
+ return CommandCost((DistanceManhattan(tile, endtile) + 1) * RailConvertCost(GetRailType(tile), totype));
}
@@ -1261,29 +1237,24 @@ static void AnimateTile_TunnelBridge(TileIndex tile)
static void TileLoop_TunnelBridge(TileIndex tile)
{
- bool snow_or_desert = IsTunnelTile(tile) ? HasTunnelBridgeSnowOrDesert(tile) : HasTunnelBridgeSnowOrDesert(tile);
+ bool snow_or_desert = HasTunnelBridgeSnowOrDesert(tile);
switch (_opt.landscape) {
case LT_ARCTIC:
if (snow_or_desert != (GetTileZ(tile) > GetSnowLine())) {
- if (IsTunnelTile(tile)) {
- SetTunnelBridgeSnowOrDesert(tile, !snow_or_desert);
- } else {
- SetTunnelBridgeSnowOrDesert(tile, !snow_or_desert);
- }
+ SetTunnelBridgeSnowOrDesert(tile, !snow_or_desert);
MarkTileDirtyByTile(tile);
}
break;
case LT_TROPIC:
if (GetTropicZone(tile) == TROPICZONE_DESERT && !snow_or_desert) {
- if (IsTunnelTile(tile)) {
- SetTunnelBridgeSnowOrDesert(tile, true);
- } else {
- SetTunnelBridgeSnowOrDesert(tile, true);
- }
+ SetTunnelBridgeSnowOrDesert(tile, true);
MarkTileDirtyByTile(tile);
}
break;
+
+ default:
+ break;
}
}
@@ -1295,15 +1266,9 @@ static void ClickTile_TunnelBridge(TileIndex tile)
static uint32 GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode, uint sub_mode)
{
- if (IsTunnel(tile)) {
- if (GetTunnelBridgeTransportType(tile) != mode) return 0;
- if (GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD && (GetRoadTypes(tile) & sub_mode) == 0) return 0;
- return AxisToTrackBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) * 0x101;
- } else {
- if (GetTunnelBridgeTransportType(tile) != mode) return 0;
- if (GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD && (GetRoadTypes(tile) & sub_mode) == 0) return 0;
- return AxisToTrackBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) * 0x101;
- }
+ if (GetTunnelBridgeTransportType(tile) != mode) return 0;
+ if (GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD && (GetRoadTypes(tile) & sub_mode) == 0) return 0;
+ return AxisToTrackBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) * 0x101;
}
static void ChangeTileOwner_TunnelBridge(TileIndex tile, PlayerID old_player, PlayerID new_player)
@@ -1318,7 +1283,7 @@ static void ChangeTileOwner_TunnelBridge(TileIndex tile, PlayerID old_player, Pl
* the bridge/tunnel. As all *our* vehicles are already removed, they
* must be of another owner. Therefor this must be a road bridge/tunnel.
* In that case we can safely reassign the ownership to OWNER_NONE. */
- assert((IsTunnel(tile) ? GetTunnelBridgeTransportType(tile) : GetTunnelBridgeTransportType(tile)) == TRANSPORT_ROAD);
+ assert(GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD);
SetTileOwner(tile, OWNER_NONE);
}
}