Update readme and changelog for v1.27.0
[openttd-joker.git] / src / tunnelbridge.h
blob8f31d5f49bbf051b0be168a8f4ef843215bffede
1 /* $Id: tunnelbridge.h 22405 2011-05-01 19:14:12Z rubidium $ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /** @file tunnelbridge.h Header file for things common for tunnels and bridges */
12 #ifndef TUNNELBRIDGE_H
13 #define TUNNELBRIDGE_H
15 #include "map_func.h"
16 #include "tile_map.h"
18 void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height, const ZoomLevel mark_dirty_if_zoomlevel_is_below = ZOOM_LVL_END);
19 void MarkBridgeDirty(TileIndex tile, const ZoomLevel mark_dirty_if_zoomlevel_is_below = ZOOM_LVL_END);
20 void MarkBridgeOrTunnelDirty(TileIndex tile, const ZoomLevel mark_dirty_if_zoomlevel_is_below = ZOOM_LVL_END);
21 uint GetTunnelBridgeSignalSimulationSignalCount(uint length);
23 /**
24 * Calculates the length of a tunnel or a bridge (without end tiles)
25 * @param begin The begin of the tunnel or bridge.
26 * @param end The end of the tunnel or bridge.
27 * @return length of bridge/tunnel middle
29 static inline uint GetTunnelBridgeLength(TileIndex begin, TileIndex end)
31 int x1 = TileX(begin);
32 int y1 = TileY(begin);
33 int x2 = TileX(end);
34 int y2 = TileY(end);
36 return abs(x2 + y2 - x1 - y1) - 1;
39 /**
40 * Sets the ownership of the bridge/tunnel ramps
41 * @param begin The begin of the tunnel or bridge.
42 * @param end The end of the tunnel or bridge.
43 * @param owner The new owner to set
45 static inline void SetTunnelBridgeOwner(TileIndex begin, TileIndex end, Owner owner)
47 SetTileOwner(begin, owner);
48 SetTileOwner(end, owner);
51 /**
52 * Get number of signals on bridge or tunnel with signal simulation.
53 * @param begin The begin of the tunnel or bridge.
54 * @param end The end of the tunnel or bridge.
55 * @pre IsTunnelBridgeWithSignalSimulation(begin)
57 static inline uint GetTunnelBridgeSignalSimulationSignalCount(TileIndex begin, TileIndex end)
59 return GetTunnelBridgeSignalSimulationSignalCount(GetTunnelBridgeLength(begin, end));
63 extern TileIndex _build_tunnel_endtile;
65 #endif /* TUNNELBRIDGE_H */