OpenTTD Source: src/depot_base.h Source File

OpenTTD Source 15.3

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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
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#include "timer/timer_game_calendar.h"
16
17typedef Pool<Depot, DepotID, 64> DepotPool;
18extern DepotPool _depot_pool;
19
20 struct Depot : DepotPool::PoolItem<&_depot_pool> {
21 /* DepotID index member of DepotPool is 2 bytes. */
22 uint16_t town_cn = 0;
23 TileIndex xy = INVALID_TILE;
24 Town *town = nullptr;
25 std::string name{};
26 TimerGameCalendar::Date build_date{};
27
28 Depot() {}
29 Depot(TileIndex xy) : xy(xy), build_date(TimerGameCalendar::date) {}
30 ~Depot();
31
32 static inline Depot *GetByTile(TileIndex tile)
33 {
34 return Depot::Get(GetDepotIndex(tile));
35 }
36
43 inline bool IsOfType(const Depot *d) const
44 {
45 return GetTileType(d->xy) == GetTileType(this->xy);
46 }
47};
48
49#endif /* DEPOT_BASE_H */
TimerGameCalendar
Timer that is increased every 27ms, and counts towards ticks / days / months / years.
Definition timer_game_calendar.h:28
_depot_pool
DepotPool _depot_pool("Depot")
All our depots tucked away in a pool.
depot_map.h
Map related accessors for depots.
GetDepotIndex
DepotID GetDepotIndex(Tile t)
Get the index of which depot is attached to the tile.
Definition depot_map.h:53
pool_type.hpp
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
Depot
Definition depot_base.h:20
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:43
Depot::~Depot
~Depot()
Clean up a depot.
Definition depot.cpp:28
Depot::town_cn
uint16_t town_cn
The N-1th depot for this town (consecutive number)
Definition depot_base.h:22
Depot::build_date
TimerGameCalendar::Date build_date
Date of construction.
Definition depot_base.h:26
Pool::PoolItem
Base class for all PoolItems.
Definition pool_type.hpp:285
Pool::PoolItem<&_depot_pool >::Get
static Titem * Get(auto index)
Returns Titem with given index.
Definition pool_type.hpp:387
Pool
Base class for all pools.
Definition pool_type.hpp:133
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
Town
Town data structure.
Definition town.h:63
GetTileType
static TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
Definition tile_map.h:96
INVALID_TILE
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition tile_type.h:95
timer_game_calendar.h
Definition of the game-calendar-timer.