Mercurial > hg > openttd
changeset 8153:a18e5c54295e draft
(svn r11715) -Fix: do not use GetTrackBits() for depots and waypoints while converting railtype
author | smatz <smatz@openttd.org> |
---|---|
date | Fri, 28 Dec 2007 15:27:12 +0000 |
parents | 32bfb56e7e0e |
children | 5143b10911a1 |
files | src/rail_cmd.cpp |
diffstat | 1 files changed, 31 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1227,21 +1227,38 @@ 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: {