diff options
author | smatz <smatz@openttd.org> | 2007-12-17 22:29:27 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2007-12-17 22:29:27 +0000 |
commit | 0b08f7370ddd778da13ed5426c8c4d24fe0d5432 (patch) | |
tree | 4b515d99becc25cc7fb8461375ce7ffa41682f47 /src/tunnelbridge_cmd.cpp | |
parent | bda9d4a23633c4ebb6ad18c29218deaf1a92d55d (diff) | |
download | openttd-0b08f7370ddd778da13ed5426c8c4d24fe0d5432.tar.xz |
(svn r11657) -Fix: show better error message when trying to convert rail
-Codechange: merge DoConvert functions into one, make test and exec runs the same for tunnels/bridges
Diffstat (limited to 'src/tunnelbridge_cmd.cpp')
-rw-r--r-- | src/tunnelbridge_cmd.cpp | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 68be57389..95fc6f980 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -691,54 +691,6 @@ static CommandCost ClearTile_TunnelBridge(TileIndex tile, byte flags) } /** - * Switches the rail type for a tunnel or a bridgehead. As the railtype - * on the bridge are determined by the one of the bridgehead, this - * functions converts the railtype on the entire bridge. - * @param tile The tile on which the railtype is to be convert. - * @param totype The railtype we want to convert to - * @param exec Switches between test and execute mode - * @return The cost and state of the operation - * @retval CMD_ERROR An error occured during the operation. - */ -CommandCost DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec) -{ - if (GetTunnelBridgeTransportType(tile) != TRANSPORT_RAIL) return CMD_ERROR; - - TileIndex endtile = IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(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; - } - - if (exec) { - SetRailType(tile, totype); - SetRailType(endtile, totype); - - Track track = AxisToTrack(DiagDirToAxis(GetTunnelBridgeDirection(tile))); - - YapfNotifyTrackLayoutChange(tile, track); - YapfNotifyTrackLayoutChange(endtile, track); - - VehicleFromPos(tile, NULL, &UpdateTrainPowerProc); - VehicleFromPos(endtile, NULL, &UpdateTrainPowerProc); - - MarkTileDirtyByTile(tile); - MarkTileDirtyByTile(endtile); - - if (IsBridge(tile)) { - TileIndexDiff delta = TileOffsByDiagDir(GetTunnelBridgeDirection(tile)); - 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)); -} - - -/** * Draws the pillars under high bridges. * * @param psid Image and palette of a bridge pillar. |