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/>.
10 /** @file tunnel_base.h Base for all tunnels */
15 #include "tunnel_map.h"
16 #include "core/pool_type.hpp"
20 typedef Pool
<Tunnel
, TunnelID
, 64, 1048576> TunnelPool
;
21 extern TunnelPool _tunnel_pool
;
23 struct Tunnel
: TunnelPool::PoolItem
<&_tunnel_pool
> {
25 TileIndex tile_n
; // North tile of tunnel.
26 TileIndex tile_s
; // South tile of tunnel.
27 uint8 height
; // Tunnel height
28 bool is_chunnel
; // Whether this tunnel is a chunnel
33 Tunnel(TileIndex tile_n
, TileIndex tile_s
, uint8 height
, bool is_chunnel
) : tile_n(tile_n
), tile_s(tile_s
), height(height
), is_chunnel(is_chunnel
)
35 this->UpdateIndexes();
40 static inline Tunnel
*GetByTile(TileIndex tile
)
42 return Tunnel::Get(GetTunnelIndex(tile
));
45 static void PreCleanPool();
48 #define FOR_ALL_TUNNELS_FROM(var, start) FOR_ALL_ITEMS_FROM(Tunnel, tunnel_index, var, start)
49 #define FOR_ALL_TUNNELS(var) FOR_ALL_TUNNELS_FROM(var, 0)
51 #endif /* TUNNEL_BASE_H */