Go to the documentation of this file.
1 /* $Id: depot_base.h 23640 2011-12-20 17:57:56Z truebrain $ */
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 <>.
8  */
12 #ifndef DEPOT_BASE_H
13 #define DEPOT_BASE_H
15 #include "depot_map.h"
16 #include "core/pool_type.hpp"
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;
29  Depot(TileIndex xy = INVALID_TILE) : xy(xy) {}
30  ~Depot();
32  static inline Depot *GetByTile(TileIndex tile)
33  {
34  return Depot::Get(GetDepotIndex(tile));
35  }
43  inline bool IsOfType(const Depot *d) const
44  {
45  return GetTileType(d->xy) == GetTileType(this->xy);
46  }
47 };
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 */
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
Definition: tile_map.h:89
Clean up a depot.
Definition: depot.cpp:30
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:246
Defintion of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle...
Date build_date
Date of construction.
Definition: depot_base.h:27
Map related accessors for depots.
DepotPool _depot_pool
All our depots tucked away in a pool.
Base class for all PoolItems.
Definition: pool_type.hpp:146
static DepotID GetDepotIndex(TileIndex t)
Get the index of which depot is attached to the tile.
Definition: depot_map.h:54
Base class for all pools.
Definition: pool_type.hpp:83
bool IsOfType(const Depot *d) const
Is the "type" of depot the same as the given depot, i.e.
Definition: depot_base.h:43
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
Town data structure.
Definition: town.h:55
int32 Date
The type to store our dates in.
Definition: date_type.h:16
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:85
uint16 town_cn
The N-1th depot for this town (consecutive number)
Definition: depot_base.h:26