mirror of https://github.com/OpenTTD/OpenTTD
(svn r24102) -Codechange: Refactor tile clearability test out of the statue callback.
parent
f607538882
commit
c876d18320
|
@ -2704,6 +2704,19 @@ static CommandCost TownActionRoadRebuild(Town *t, DoCommandFlag flags)
|
||||||
return CommandCost();
|
return CommandCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the land can be cleared.
|
||||||
|
* @param tile Tile to check.
|
||||||
|
* @return The tile can be cleared.
|
||||||
|
*/
|
||||||
|
static bool TryClearTile(TileIndex tile)
|
||||||
|
{
|
||||||
|
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||||
|
CommandCost r = DoCommand(tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR);
|
||||||
|
cur_company.Restore();
|
||||||
|
return r.Succeeded();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search callback function for TownActionBuildStatue.
|
* Search callback function for TownActionBuildStatue.
|
||||||
* @param tile Tile on which to perform the search.
|
* @param tile Tile on which to perform the search.
|
||||||
|
@ -2723,13 +2736,7 @@ static bool SearchTileForStatue(TileIndex tile, void *user_data)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
return TryClearTile(tile);
|
||||||
CommandCost r = DoCommand(tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR);
|
|
||||||
cur_company.Restore();
|
|
||||||
|
|
||||||
if (r.Failed()) return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue