mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-08 23:19:40 +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();
|
Money money = GetAvailableMoneyForCommand();
|
||||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||||
|
CommandCost last_error((p2 == 0) ? STR_ERROR_ALREADY_LEVELLED : INVALID_STRING_ID);
|
||||||
|
bool had_success = false;
|
||||||
|
|
||||||
TileArea ta(tile, p1);
|
TileArea ta(tile, p1);
|
||||||
TILE_AREA_LOOP(tile, ta) {
|
TILE_AREA_LOOP(tile, ta) {
|
||||||
uint curh = TileHeight(tile);
|
uint curh = TileHeight(tile);
|
||||||
while (curh != h) {
|
while (curh != h) {
|
||||||
CommandCost ret = DoCommand(tile, SLOPE_N, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND);
|
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) {
|
if (flags & DC_EXEC) {
|
||||||
money -= ret.GetCost();
|
money -= ret.GetCost();
|
||||||
@ -398,13 +403,9 @@ CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|||||||
|
|
||||||
cost.AddCost(ret);
|
cost.AddCost(ret);
|
||||||
curh += (curh > h) ? -1 : 1;
|
curh += (curh > h) ? -1 : 1;
|
||||||
|
had_success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cost.GetCost() == 0) {
|
return had_success ? cost : last_error;
|
||||||
if (p2 != 0) return CMD_ERROR;
|
|
||||||
cost.MakeError(STR_ERROR_ALREADY_LEVELLED);
|
|
||||||
cost.SetGlobalErrorMessage();
|
|
||||||
}
|
|
||||||
return cost;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user