Add a method in NewGRFInspectWindow to resolve FeatureIndex
[openttd/fttd.git] / src / depot_base.h
blobf07424a3cefd116ec3f7d41b70fb40b687f6f92c
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_type.h"
16 #include "town_type.h"
17 #include "map/coord.h"
18 #include "map/depot.h"
19 #include "depot_func.h"
20 #include "station_func.h"
21 #include "core/pool_type.hpp"
23 typedef Pool<Depot, DepotID, 64, 64000> DepotPool;
24 extern DepotPool _depot_pool;
26 struct Depot : DepotPool::PoolItem<&_depot_pool> {
27 Town *town;
28 char *name;
30 TileIndex xy;
31 uint16 town_cn; ///< The N-1th depot for this town (consecutive number)
32 Date build_date; ///< Date of construction
34 Depot(TileIndex xy = INVALID_TILE) : xy(xy) {}
35 ~Depot();
37 static inline Depot *GetByTile(TileIndex tile)
39 return Depot::Get(GetDepotIndex(tile));
42 /**
43 * Is the "type" of depot the same as the given depot,
44 * i.e. are both a rail, road or ship depots?
45 * @param d The depot to compare to.
46 * @return true iff their types are equal.
48 inline bool IsOfType(const Depot *d) const
50 return GetTileType(d->xy) == GetTileType(this->xy);
54 #define FOR_ALL_DEPOTS_FROM(var, start) FOR_ALL_ITEMS_FROM(Depot, depot_index, var, start)
55 #define FOR_ALL_DEPOTS(var) FOR_ALL_DEPOTS_FROM(var, 0)
57 #endif /* DEPOT_BASE_H */