summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-03-20 17:13:00 +0000
committeralberth <alberth@openttd.org>2010-03-20 17:13:00 +0000
commit467803a7c0cacab9d0793c25c8d5b971804aff98 (patch)
tree4bd2748245772a7aeac4d685de6281109f8c8025 /src
parent8b785ccb8a009a7e3a2378fda68cf0844a90502a (diff)
downloadopenttd-467803a7c0cacab9d0793c25c8d5b971804aff98.tar.xz
(svn r19490) -Fix: Return to old behaviour of CmdLevelLand() by keeping track of last error.
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;
}