1
0
Fork 0

(svn r19492) -Codechange: Keep track of last error in CmdClearArea().

release/1.1
alberth 2010-03-20 17:19:16 +00:00
parent b714160fcc
commit 66a2a84035
1 changed files with 8 additions and 4 deletions

View File

@ -624,14 +624,18 @@ CommandCost CmdClearArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
Money money = GetAvailableMoneyForCommand(); Money money = GetAvailableMoneyForCommand();
CommandCost cost(EXPENSES_CONSTRUCTION); 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 x = sx; x <= ex; ++x) {
for (int y = sy; y <= ey; ++y) { for (int y = sy; y <= ey; ++y) {
CommandCost ret = DoCommand(TileXY(x, y), 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR); CommandCost ret = DoCommand(TileXY(x, y), 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR);
if (ret.Failed()) continue; if (ret.Failed()) {
success = true; last_error = ret;
continue;
}
had_success = true;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
money -= ret.GetCost(); money -= ret.GetCost();
if (ret.GetCost() > 0 && money < 0) { 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;
} }