summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-16 06:06:05 +0000
committertron <tron@openttd.org>2006-03-16 06:06:05 +0000
commit8a77808f650976f532bb43bef155edc5fd1943fe (patch)
treee0ea2149ed41fd18b12b507329c4ef90b48bb18e
parentec33376fa3355a840cd6ddb31687382e5251b1fa (diff)
downloadopenttd-8a77808f650976f532bb43bef155edc5fd1943fe.tar.xz
(svn r3899) Use wrapper functions to make more clear how deleting stuff under bridges works; also remove an unnecessary local variable
-rw-r--r--bridge_map.h5
-rw-r--r--tunnelbridge_cmd.c48
2 files changed, 31 insertions, 22 deletions
diff --git a/bridge_map.h b/bridge_map.h
index 4f4b33d53..610728060 100644
--- a/bridge_map.h
+++ b/bridge_map.h
@@ -45,6 +45,11 @@ static inline bool IsClearUnderBridge(TileIndex t)
return GB(_m[t].m5, 3, 3) == 0;
}
+static inline bool IsWaterUnderBridge(TileIndex t)
+{
+ return GB(_m[t].m5, 3, 3) == 1;
+}
+
static inline bool IsTransportUnderBridge(TileIndex t)
{
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index 6496dfd10..63cb93dcf 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -633,34 +633,38 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags)
direction = GB(_m[tile].m5, 0, 1);
- /* delete stuff under the middle part if there's a transport route there..? */
- if ((_m[tile].m5 & 0xE0) == 0xE0) {
- int32 cost;
+ if (IsBridgeMiddle(tile)) {
+ if (IsTransportUnderBridge(tile)) {
+ /* delete transport route under the bridge */
+ int32 cost;
- // check if we own the tile below the bridge..
- if (_current_player != OWNER_WATER && (!CheckTileOwnership(tile) || !EnsureNoVehicleZ(tile, TilePixelHeight(tile))))
- return CMD_ERROR;
+ // check if we own the tile below the bridge..
+ if (_current_player != OWNER_WATER && (!CheckTileOwnership(tile) || !EnsureNoVehicleZ(tile, TilePixelHeight(tile))))
+ return CMD_ERROR;
- cost = (_m[tile].m5 & 8) ? _price.remove_road * 2 : _price.remove_rail;
+ if (GetTransportTypeUnderBridge(tile) == TRANSPORT_RAIL) {
+ cost = _price.remove_rail;
+ } else {
+ cost = _price.remove_road * 2;
+ }
- if (flags & DC_EXEC) {
- SetClearUnderBridge(tile);
- MarkTileDirtyByTile(tile);
- }
- return cost;
+ if (flags & DC_EXEC) {
+ SetClearUnderBridge(tile);
+ MarkTileDirtyByTile(tile);
+ }
+ return cost;
+ } else if (IsWaterUnderBridge(tile) && TilePixelHeight(tile) != 0) {
+ /* delete canal under bridge */
- /* delete canal under bridge */
- } else if ((_m[tile].m5 & 0xC8) == 0xC8 && TilePixelHeight(tile) != 0) {
- int32 cost;
+ // check for vehicles under bridge
+ if (!EnsureNoVehicleZ(tile, TilePixelHeight(tile))) return CMD_ERROR;
- // check for vehicles under bridge
- if (!EnsureNoVehicleZ(tile, TilePixelHeight(tile))) return CMD_ERROR;
- cost = _price.clear_water;
- if (flags & DC_EXEC) {
- SetClearUnderBridge(tile);
- MarkTileDirtyByTile(tile);
+ if (flags & DC_EXEC) {
+ SetClearUnderBridge(tile);
+ MarkTileDirtyByTile(tile);
+ }
+ return _price.clear_water;
}
- return cost;
}
tile = FindEdgesOfBridge(tile, &endtile);