diff options
author | alberth <alberth@openttd.org> | 2010-03-20 17:19:16 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2010-03-20 17:19:16 +0000 |
commit | 66a2a84035d1dfccf608f6efd7e2aa4913c973b8 (patch) | |
tree | 6bad8ed33d9a84df080db590b124dc9fdf713829 | |
parent | b714160fccc19490e4a8b8d5d371c8d0c69d8ac7 (diff) | |
download | openttd-66a2a84035d1dfccf608f6efd7e2aa4913c973b8.tar.xz |
(svn r19492) -Codechange: Keep track of last error in CmdClearArea().
-rw-r--r-- | src/landscape.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/landscape.cpp b/src/landscape.cpp index f122c0c30..6c9f062f5 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -624,14 +624,18 @@ CommandCost CmdClearArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 Money money = GetAvailableMoneyForCommand(); CommandCost cost(EXPENSES_CONSTRUCTION); - bool success = false; + CommandCost last_error = CMD_ERROR; + bool had_success = false; for (int x = sx; x <= ex; ++x) { for (int y = sy; y <= ey; ++y) { CommandCost ret = DoCommand(TileXY(x, y), 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR); - if (ret.Failed()) continue; - success = true; + if (ret.Failed()) { + last_error = ret; + continue; + } + had_success = true; if (flags & DC_EXEC) { money -= ret.GetCost(); if (ret.GetCost() > 0 && money < 0) { @@ -652,7 +656,7 @@ CommandCost CmdClearArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 } } - return (success) ? cost : CMD_ERROR; + return had_success ? cost : last_error; } |