summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/terraform_cmd.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp
index 5bad78fdf..b98dc233d 100644
--- a/src/terraform_cmd.cpp
+++ b/src/terraform_cmd.cpp
@@ -379,13 +379,18 @@ CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
Money money = GetAvailableMoneyForCommand();
CommandCost cost(EXPENSES_CONSTRUCTION);
+ CommandCost last_error((p2 == 0) ? STR_ERROR_ALREADY_LEVELLED : INVALID_STRING_ID);
+ bool had_success = false;
TileArea ta(tile, p1);
TILE_AREA_LOOP(tile, ta) {
uint curh = TileHeight(tile);
while (curh != h) {
CommandCost ret = DoCommand(tile, SLOPE_N, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND);
- if (ret.Failed()) return (cost.GetCost() == 0) ? ret : cost;
+ if (ret.Failed()) {
+ last_error = ret;
+ break;
+ }
if (flags & DC_EXEC) {
money -= ret.GetCost();
@@ -398,13 +403,9 @@ CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
cost.AddCost(ret);
curh += (curh > h) ? -1 : 1;
+ had_success = true;
}
}
- if (cost.GetCost() == 0) {
- if (p2 != 0) return CMD_ERROR;
- cost.MakeError(STR_ERROR_ALREADY_LEVELLED);
- cost.SetGlobalErrorMessage();
- }
- return cost;
+ return had_success ? cost : last_error;
}