Merge branch 'development' into feature/no_multiplayer_grf_limit
[openttd-joker.git] / src / dock_base.h
blobc9665813b5093b145c3f6db59ad4ca8b10526bb1
1 /* $Id: dock_base.h $ */
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 dock_base.h Base class for docks. */
12 #ifndef DOCK_BASE_H
13 #define DOCK_BASE_H
15 #include "station_type.h"
16 #include "tile_type.h"
17 #include "map_func.h"
18 #include "core/pool_type.hpp"
20 typedef Pool<Dock, DockID, 32, 64000> DockPool;
21 extern DockPool _dock_pool;
23 /** A Dock structure. */
24 struct Dock : DockPool::PoolItem<&_dock_pool> {
25 TileIndex sloped; ///< The sloped tile of the dock.
26 TileIndex flat; ///< Position on the map of the flat tile.
27 Dock *next; ///< Next dock of the given type at this station.
29 Dock(TileIndex s = INVALID_TILE, TileIndex f = INVALID_TILE) : sloped(s), flat(f), next(NULL) { }
31 ~Dock() {}
33 inline Dock *GetNextDock() const { return this->next; }
35 inline TileIndex GetDockingTile() const
37 return this->flat + TileOffsByDiagDir(DiagdirBetweenTiles(this->sloped, this->flat));
40 static Dock *GetByTile(TileIndex tile);
43 #define FOR_ALL_DOCKS_FROM(var, start) FOR_ALL_ITEMS_FROM(Dock, dock_index, var, start)
44 #define FOR_ALL_DOCKS(var) FOR_ALL_DOCKS_FROM(var, 0)
46 #endif /* DOCK_BASE_H */