summaryrefslogtreecommitdiff
path: root/src/rail_cmd.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2007-12-28 15:27:12 +0000
committersmatz <smatz@openttd.org>2007-12-28 15:27:12 +0000
commit8e1f21e29b9f0fec72e24f34f7baa3ad14945d5f (patch)
treecff486341f2e67f81c5884f6ff9038a84977d291 /src/rail_cmd.cpp
parente9a039b845afb5296a37d8413c8c651b1eb699fb (diff)
downloadopenttd-8e1f21e29b9f0fec72e24f34f7baa3ad14945d5f.tar.xz
(svn r11715) -Fix: do not use GetTrackBits() for depots and waypoints while converting railtype
Diffstat (limited to 'src/rail_cmd.cpp')
-rw-r--r--src/rail_cmd.cpp45
1 files changed, 31 insertions, 14 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 39e3bd00a..78227bb38 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -1227,21 +1227,38 @@ CommandCost CmdConvertRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
switch (tt) {
case MP_RAILWAY:
- if (flags & DC_EXEC) {
- /* notify YAPF about the track layout change */
- TrackBits tracks = GetTrackBits(tile);
- while (tracks != TRACK_BIT_NONE) {
- YapfNotifyTrackLayoutChange(tile, RemoveFirstTrack(&tracks));
- }
-
- if (IsTileDepotType(tile, TRANSPORT_RAIL)) {
- /* Update build vehicle window related to this depot */
- InvalidateWindowData(WC_VEHICLE_DEPOT, tile);
- InvalidateWindowData(WC_BUILD_VEHICLE, tile);
- }
+ switch (GetRailTileType(tile)) {
+ case RAIL_TILE_WAYPOINT:
+ if (flags & DC_EXEC) {
+ /* notify YAPF about the track layout change */
+ YapfNotifyTrackLayoutChange(tile, AxisToTrack(GetWaypointAxis(tile)));
+ }
+ cost.AddCost(RailConvertCost(type, totype));
+ break;
+
+ case RAIL_TILE_DEPOT:
+ if (flags & DC_EXEC) {
+ /* notify YAPF about the track layout change */
+ YapfNotifyTrackLayoutChange(tile, AxisToTrack(DiagDirToAxis(GetRailDepotDirection(tile))));
+
+ /* Update build vehicle window related to this depot */
+ InvalidateWindowData(WC_VEHICLE_DEPOT, tile);
+ InvalidateWindowData(WC_BUILD_VEHICLE, tile);
+ }
+ cost.AddCost(RailConvertCost(type, totype));
+ break;
+
+ default: // RAIL_TILE_NORMAL, RAIL_TILE_SIGNALS
+ if (flags & DC_EXEC) {
+ /* notify YAPF about the track layout change */
+ TrackBits tracks = GetTrackBits(tile);
+ while (tracks != TRACK_BIT_NONE) {
+ YapfNotifyTrackLayoutChange(tile, RemoveFirstTrack(&tracks));
+ }
+ }
+ cost.AddCost(RailConvertCost(type, totype) * CountBits(GetTrackBits(tile)));
+ break;
}
-
- cost.AddCost(CommandCost(RailConvertCost(type, totype) * CountBits(GetTrackBits(tile))));
break;
case MP_TUNNELBRIDGE: {