summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2007-01-13 14:48:47 +0000
committerDarkvater <Darkvater@openttd.org>2007-01-13 14:48:47 +0000
commit64f34d322d806e4ff3404b7d4f59a63aed5a82d3 (patch)
treef0f474d541855b43acd1749a507a8c495b568971 /src
parent8ad471c3214570fe1b19152e031aec4b22a17551 (diff)
downloadopenttd-64f34d322d806e4ff3404b7d4f59a63aed5a82d3.tar.xz
(svn r8096) -Codechange: Invert the check if you are allowed to clear a road tile so there are not so many negations (too confusing) and added some comments to further clarify what happens.
Diffstat (limited to 'src')
-rw-r--r--src/road_cmd.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index dc4304d03..37fa9d562 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -558,21 +558,24 @@ static int32 RemoveRoadDepot(TileIndex tile, uint32 flags)
return _price.remove_road_depot;
}
-#define M(x) (1<<(x))
-
static int32 ClearTile_Road(TileIndex tile, byte flags)
{
switch (GetRoadTileType(tile)) {
case ROAD_TILE_NORMAL: {
RoadBits b = GetRoadBits(tile);
- if (!((1 << b) & (M(1)|M(2)|M(4)|M(8))) &&
- (!(flags & DC_AI_BUILDING) || !IsTileOwner(tile, OWNER_TOWN)) &&
- flags & DC_AUTO) {
- return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST);
+#define M(x) (1 << (x))
+ /* Clear the road if only one piece is on the tile OR the AI tries
+ * to clear town road OR we are not using the DC_AUTO flag */
+ if ((M(b) & (M(ROAD_NW) | M(ROAD_SW) | M(ROAD_SE) | M(ROAD_NE))) ||
+ ((flags & DC_AI_BUILDING) && IsTileOwner(tile, OWNER_TOWN)) ||
+ !(flags & DC_AUTO)
+ ) {
+ return DoCommand(tile, b, 0, flags, CMD_REMOVE_ROAD);
}
- return DoCommand(tile, b, 0, flags, CMD_REMOVE_ROAD);
- }
+ return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST);
+ } break;
+#undef M
case ROAD_TILE_CROSSING: {
int32 ret;