Update readme and changelog for v1.26.0
[openttd-joker.git] / src / tunnelbridge.h
blob2d2dbe09b3a956695ecbeb44e7074017c3972575
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"
17 void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height, const ZoomLevel mark_dirty_if_zoomlevel_is_below = ZOOM_LVL_END);
18 void MarkBridgeDirty(TileIndex tile, const ZoomLevel mark_dirty_if_zoomlevel_is_below = ZOOM_LVL_END);
19 void MarkBridgeOrTunnelDirty(TileIndex tile, const ZoomLevel mark_dirty_if_zoomlevel_is_below = ZOOM_LVL_END);
20 uint GetTunnelBridgeSignalSimulationSignalCount(uint length);
22 /**
23 * Calculates the length of a tunnel or a bridge (without end tiles)
24 * @param begin The begin of the tunnel or bridge.
25 * @param end The end of the tunnel or bridge.
26 * @return length of bridge/tunnel middle
28 static inline uint GetTunnelBridgeLength(TileIndex begin, TileIndex end)
30 int x1 = TileX(begin);
31 int y1 = TileY(begin);
32 int x2 = TileX(end);
33 int y2 = TileY(end);
35 return abs(x2 + y2 - x1 - y1) - 1;
38 /**
39 * Get number of signals on bridge or tunnel with signal simulation.
40 * @param begin The begin of the tunnel or bridge.
41 * @param end The end of the tunnel or bridge.
42 * @pre IsTunnelBridgeWithSignalSimulation(begin)
44 static inline uint GetTunnelBridgeSignalSimulationSignalCount(TileIndex begin, TileIndex end)
46 return GetTunnelBridgeSignalSimulationSignalCount(GetTunnelBridgeLength(begin, end));
49 extern TileIndex _build_tunnel_endtile;
51 #endif /* TUNNELBRIDGE_H */