mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r19490) -Fix: Return to old behaviour of CmdLevelLand() by keeping track of last error.
This commit is contained in:
parent
8b785ccb8a
commit
467803a7c0
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user