(svn r28004) -Update from Eints:
[openttd.git] / src / depot_base.h
blobe5eb3b622c33db44cf6c2ff1681f8fc6c8d549f9
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 depot_base.h Base for all depots (except hangars) */
12 #ifndef DEPOT_BASE_H
13 #define DEPOT_BASE_H
15 #include "depot_map.h"
16 #include "core/pool_type.hpp"
18 typedef Pool<Depot, DepotID, 64, 64000> DepotPool;
19 extern DepotPool _depot_pool;
21 struct Depot : DepotPool::PoolItem<&_depot_pool> {
22 Town *town;
23 char *name;
25 TileIndex xy;
26 uint16 town_cn; ///< The N-1th depot for this town (consecutive number)
27 Date build_date; ///< Date of construction
29 Depot(TileIndex xy = INVALID_TILE) : xy(xy) {}
30 ~Depot();
32 static inline Depot *GetByTile(TileIndex tile)
34 return Depot::Get(GetDepotIndex(tile));
37 /**
38 * Is the "type" of depot the same as the given depot,
39 * i.e. are both a rail, road or ship depots?
40 * @param d The depot to compare to.
41 * @return true iff their types are equal.
43 inline bool IsOfType(const Depot *d) const
45 return GetTileType(d->xy) == GetTileType(this->xy);
49 #define FOR_ALL_DEPOTS_FROM(var, start) FOR_ALL_ITEMS_FROM(Depot, depot_index, var, start)
50 #define FOR_ALL_DEPOTS(var) FOR_ALL_DEPOTS_FROM(var, 0)
52 #endif /* DEPOT_BASE_H */