diff options
author | alberth <alberth@openttd.org> | 2010-03-20 17:14:26 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2010-03-20 17:14:26 +0000 |
commit | b714160fccc19490e4a8b8d5d371c8d0c69d8ac7 (patch) | |
tree | 36e88160069b5c6e190603d0ba4ac47678e78c56 | |
parent | 467803a7c0cacab9d0793c25c8d5b971804aff98 (diff) | |
download | openttd-b714160fccc19490e4a8b8d5d371c8d0c69d8ac7.tar.xz |
(svn r19491) -Codechange: Keep track of last error in CmdRemoveLongRoad().
-rw-r--r-- | src/road_cmd.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 9942ae787..07805be7e 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -848,6 +848,8 @@ CommandCost CmdRemoveLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 Money money = GetAvailableMoneyForCommand(); TileIndex tile = start_tile; + CommandCost last_error = CMD_ERROR; + bool had_success = false; /* Start tile is the small number. */ for (;;) { RoadBits bits = AxisToRoadBits(axis); @@ -868,6 +870,9 @@ CommandCost CmdRemoveLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 RemoveRoad(tile, flags, bits, rt, true, false); } cost.AddCost(ret); + had_success = true; + } else { + last_error = ret; } } @@ -876,7 +881,7 @@ CommandCost CmdRemoveLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 tile += (axis == AXIS_Y) ? TileDiffXY(0, 1) : TileDiffXY(1, 0); } - return (cost.GetCost() == 0) ? CMD_ERROR : cost; + return had_success ? cost : last_error; } /** Build a road depot. |