@@ -621,20 +621,24 @@ CommandCost CmdClearArea(TileIndex tile,
int sy = TileY(p1);
if (ex < sx) Swap(ex, sx);
if (ey < sy) Swap(ey, sy);
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) {
_additional_cash_required = ret.GetCost();
return cost;
@@ -649,13 +653,13 @@ CommandCost CmdClearArea(TileIndex tile,
cost.AddCost(ret);
return (success) ? cost : CMD_ERROR;
return had_success ? cost : last_error;
TileIndex _cur_tileloop_tile;
#define TILELOOP_BITS 4
#define TILELOOP_SIZE (1 << TILELOOP_BITS)