Fix some daylength issues, possible division by zero in main menu.
[openttd-joker.git] / src / tunnel_base.h
blob8e0452dfbc8d479ed89d816a77020342a851e4b6
1 /* $Id$ */
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 tunnel_base.h Base for all tunnels */
12 #ifndef TUNNEL_BASE_H
13 #define TUNNEL_BASE_H
15 #include "tunnel_map.h"
16 #include "core/pool_type.hpp"
18 struct Tunnel;
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
30 Tunnel() {}
31 ~Tunnel();
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();
38 void 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 */