Mercurial > hg > openttd
changeset 14896:67eefe61a8ee draft
(svn r19492) -Codechange: Keep track of last error in CmdClearArea().
author | alberth <alberth@openttd.org> |
---|---|
date | Sat, 20 Mar 2010 17:19:16 +0000 |
parents | 5d0fff76578e |
children | 671004f47e42 |
files | src/landscape.cpp |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -624,14 +624,18 @@ 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 @@ } } - return (success) ? cost : CMD_ERROR; + return had_success ? cost : last_error; }