diff options
author | rubidium <rubidium@openttd.org> | 2009-02-21 18:10:08 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-02-21 18:10:08 +0000 |
commit | 87751dc95dd931f65a6c8268192399dbd3c9cc75 (patch) | |
tree | 74a9ebc4004c5274f831813dd3c35b56e148bd3b /src | |
parent | 6390ece34f89fbce779330483c6f4b83032b6b4a (diff) | |
download | openttd-87751dc95dd931f65a6c8268192399dbd3c9cc75.tar.xz |
(svn r15548) -Fix: incorrect error message when removing non-existing diagonal rail (TRACK_X/Y) with the single directional rail tool (i.e. not autorail).
Diffstat (limited to 'src')
-rw-r--r-- | src/rail_cmd.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 7d6725807..e76fea8aa 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -672,25 +672,23 @@ static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint3 { CommandCost ret, total_cost(EXPENSES_CONSTRUCTION); Track track = (Track)GB(p2, 4, 3); - Trackdir trackdir; - byte mode = HasBit(p2, 7); + bool remove = HasBit(p2, 7); RailType railtype = (RailType)GB(p2, 0, 4); - TileIndex end_tile; if (!ValParamRailtype(railtype) || !ValParamTrackOrientation(track)) return CMD_ERROR; if (p1 >= MapSize()) return CMD_ERROR; - end_tile = p1; - trackdir = TrackToTrackdir(track); + TileIndex end_tile = p1; + Trackdir trackdir = TrackToTrackdir(track); if (CmdFailed(ValidateAutoDrag(&trackdir, tile, end_tile))) return CMD_ERROR; if (flags & DC_EXEC) SndPlayTileFx(SND_20_SPLAT_2, tile); for (;;) { - ret = DoCommand(tile, railtype, TrackdirToTrack(trackdir), flags, (mode == 0) ? CMD_BUILD_SINGLE_RAIL : CMD_REMOVE_SINGLE_RAIL); + ret = DoCommand(tile, railtype, TrackdirToTrack(trackdir), flags, remove ? CMD_REMOVE_SINGLE_RAIL : CMD_BUILD_SINGLE_RAIL); if (CmdFailed(ret)) { - if ((_error_message != STR_1007_ALREADY_BUILT) && (mode == 0)) break; + if (_error_message != STR_1007_ALREADY_BUILT && !remove) break; _error_message = INVALID_STRING_ID; } else { total_cost.AddCost(ret); @@ -704,7 +702,7 @@ static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint3 if (!IsDiagonalTrackdir(trackdir)) ToggleBit(trackdir, 0); } - return (total_cost.GetCost() == 0) ? CommandCost(STR_1007_ALREADY_BUILT) : total_cost; + return (total_cost.GetCost() == 0) ? CommandCost(remove ? INVALID_STRING_ID : STR_1007_ALREADY_BUILT) : total_cost; } /** Build rail on a stretch of track. |