Codechange: Don't use a global for the terrforming error tile.

This commit is contained in:
Michael Lutz
2021-12-01 00:44:57 +01:00
parent 2e39637db2
commit c521b965bd
7 changed files with 46 additions and 54 deletions

View File

@@ -959,8 +959,8 @@ static bool IsRoadAllowedHere(Town *t, TileIndex tile, DiagDirection dir)
CommandCost res = CMD_ERROR;
if (!_generating_world && Chance16(1, 10)) {
/* Note: Do not replace "^ SLOPE_ELEVATED" with ComplementSlope(). The slope might be steep. */
res = Command<CMD_TERRAFORM_LAND>::Do(DC_EXEC | DC_AUTO | DC_NO_WATER,
tile, Chance16(1, 16) ? cur_slope : cur_slope ^ SLOPE_ELEVATED, false);
res = std::get<0>(Command<CMD_TERRAFORM_LAND>::Do(DC_EXEC | DC_AUTO | DC_NO_WATER,
tile, Chance16(1, 16) ? cur_slope : cur_slope ^ SLOPE_ELEVATED, false));
}
if (res.Failed() && Chance16(1, 3)) {
/* We can consider building on the slope, though. */
@@ -976,7 +976,7 @@ static bool TerraformTownTile(TileIndex tile, Slope edges, bool dir)
{
assert(tile < MapSize());
CommandCost r = Command<CMD_TERRAFORM_LAND>::Do(DC_AUTO | DC_NO_WATER, tile, edges, dir);
CommandCost r = std::get<0>(Command<CMD_TERRAFORM_LAND>::Do(DC_AUTO | DC_NO_WATER, tile, edges, dir));
if (r.Failed() || r.GetCost() >= (_price[PR_TERRAFORM] + 2) * 8) return false;
Command<CMD_TERRAFORM_LAND>::Do(DC_AUTO | DC_NO_WATER | DC_EXEC, tile, edges, dir);
return true;