OpenTTD Source  1.11.2
depot_base.h
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * 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.
4  * 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.
5  * 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/>.
6  */
7 
10 #ifndef DEPOT_BASE_H
11 #define DEPOT_BASE_H
12 
13 #include "depot_map.h"
14 #include "core/pool_type.hpp"
15 
17 extern DepotPool _depot_pool;
18 
19 struct Depot : DepotPool::PoolItem<&_depot_pool> {
20  Town *town;
21  std::string name;
22 
23  TileIndex xy;
24  uint16 town_cn;
26 
27  Depot(TileIndex xy = INVALID_TILE) : xy(xy) {}
28  ~Depot();
29 
30  static inline Depot *GetByTile(TileIndex tile)
31  {
32  return Depot::Get(GetDepotIndex(tile));
33  }
34 
41  inline bool IsOfType(const Depot *d) const
42  {
43  return GetTileType(d->xy) == GetTileType(this->xy);
44  }
45 };
46 
47 #endif /* DEPOT_BASE_H */
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:83
Pool::PoolItem<&_depot_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:329
_depot_pool
DepotPool _depot_pool
All our depots tucked away in a pool.
Depot::IsOfType
bool IsOfType(const Depot *d) const
Is the "type" of depot the same as the given depot, i.e.
Definition: depot_base.h:41
Date
int32 Date
The type to store our dates in.
Definition: date_type.h:14
Depot::town_cn
uint16 town_cn
The N-1th depot for this town (consecutive number)
Definition: depot_base.h:24
Depot::~Depot
~Depot()
Clean up a depot.
Definition: depot.cpp:28
Pool
Base class for all pools.
Definition: pool_type.hpp:81
depot_map.h
Depot::build_date
Date build_date
Date of construction.
Definition: depot_base.h:25
Depot
Definition: depot_base.h:19
Town
Town data structure.
Definition: town.h:50
INVALID_TILE
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:88
pool_type.hpp
GetTileType
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
Definition: tile_map.h:96
Pool::PoolItem
Base class for all PoolItems.
Definition: pool_type.hpp:226
GetDepotIndex
static DepotID GetDepotIndex(TileIndex t)
Get the index of which depot is attached to the tile.
Definition: depot_map.h:52