Mercurial > hg > openttd
changeset 19217:f379f2281802 draft
(svn r24102) -Codechange: Refactor tile clearability test out of the statue callback.
author | alberth <alberth@openttd.org> |
---|---|
date | Sun, 08 Apr 2012 17:26:59 +0000 |
parents | 4b152b00ba27 |
children | e75b33bd86b4 |
files | src/town_cmd.cpp |
diffstat | 1 files changed, 14 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2705,6 +2705,19 @@ } /** + * 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. * @param tile Tile on which to perform the search. * @param user_data Unused. @@ -2723,13 +2736,7 @@ return false; } - Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE); - CommandCost r = DoCommand(tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR); - cur_company.Restore(); - - if (r.Failed()) return false; - - return true; + return TryClearTile(tile); } /**