summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2012-04-08 17:26:59 +0000
committeralberth <alberth@openttd.org>2012-04-08 17:26:59 +0000
commitc876d183203aa658c8a591cfc0bd928276c40f6b (patch)
tree6784590d86b51653067d2b420cf0224131b83581 /src
parentf607538882b1963e25849b4b440a47dc1d258044 (diff)
downloadopenttd-c876d183203aa658c8a591cfc0bd928276c40f6b.tar.xz
(svn r24102) -Codechange: Refactor tile clearability test out of the statue callback.
Diffstat (limited to 'src')
-rw-r--r--src/town_cmd.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 99b58f3e6..031e37a70 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -2705,6 +2705,19 @@ static CommandCost TownActionRoadRebuild(Town *t, DoCommandFlag flags)
}
/**
+ * 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 @@ static bool SearchTileForStatue(TileIndex tile, void *user_data)
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);
}
/**