(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge

This commit is contained in:
smatz 2008-01-15 11:45:29 +00:00
parent ea6535c864
commit 0078fd1699

View File

@ -606,16 +606,20 @@ static CommandCost DoClearTunnel(TileIndex tile, uint32 flags)
/* We first need to request the direction before calling DoClearSquare /* We first need to request the direction before calling DoClearSquare
* else the direction is always 0.. dah!! ;) */ * else the direction is always 0.. dah!! ;) */
DiagDirection dir = GetTunnelBridgeDirection(tile); DiagDirection dir = GetTunnelBridgeDirection(tile);
Track track; bool rail = GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL;
DoClearSquare(tile); DoClearSquare(tile);
DoClearSquare(endtile); DoClearSquare(endtile);
if (rail) {
UpdateSignalsOnSegment(tile, ReverseDiagDir(dir)); UpdateSignalsOnSegment(tile, ReverseDiagDir(dir));
UpdateSignalsOnSegment(endtile, dir); UpdateSignalsOnSegment(endtile, dir);
track = AxisToTrack(DiagDirToAxis(dir));
Track track = AxisToTrack(DiagDirToAxis(dir));
YapfNotifyTrackLayoutChange(tile, track); YapfNotifyTrackLayoutChange(tile, track);
YapfNotifyTrackLayoutChange(endtile, track); YapfNotifyTrackLayoutChange(endtile, track);
} }
}
return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_tunnel * (DistanceManhattan(tile, endtile) + 1)); return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_tunnel * (DistanceManhattan(tile, endtile) + 1));
} }
@ -654,22 +658,25 @@ static CommandCost DoClearBridge(TileIndex tile, uint32 flags)
} }
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
TileIndex c; /* read this value before actual removal of bridge */
Track track; bool rail = GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL;
DoClearSquare(tile); DoClearSquare(tile);
DoClearSquare(endtile); DoClearSquare(endtile);
for (c = tile + delta; c != endtile; c += delta) { for (TileIndex c = tile + delta; c != endtile; c += delta) {
ClearBridgeMiddle(c); ClearBridgeMiddle(c);
MarkTileDirtyByTile(c); MarkTileDirtyByTile(c);
} }
if (rail) {
UpdateSignalsOnSegment(tile, ReverseDiagDir(direction)); UpdateSignalsOnSegment(tile, ReverseDiagDir(direction));
UpdateSignalsOnSegment(endtile, direction); UpdateSignalsOnSegment(endtile, direction);
track = AxisToTrack(DiagDirToAxis(direction));
Track track = AxisToTrack(DiagDirToAxis(direction));
YapfNotifyTrackLayoutChange(tile, track); YapfNotifyTrackLayoutChange(tile, track);
YapfNotifyTrackLayoutChange(endtile, track); YapfNotifyTrackLayoutChange(endtile, track);
} }
}
return CommandCost(EXPENSES_CONSTRUCTION, (DistanceManhattan(tile, endtile) + 1) * _price.clear_bridge); return CommandCost(EXPENSES_CONSTRUCTION, (DistanceManhattan(tile, endtile) + 1) * _price.clear_bridge);
} }