2008-04-17 19:10:30 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file depot_base.h Base for all depots (except hangars) */
|
2008-04-17 19:10:30 +00:00
|
|
|
|
|
|
|
#ifndef DEPOT_BASE_H
|
|
|
|
#define DEPOT_BASE_H
|
|
|
|
|
2009-09-10 14:36:38 +00:00
|
|
|
#include "depot_map.h"
|
2009-05-22 15:39:22 +00:00
|
|
|
#include "core/pool_type.hpp"
|
2008-04-17 19:10:30 +00:00
|
|
|
|
2009-05-22 15:13:50 +00:00
|
|
|
typedef Pool<Depot, DepotID, 64, 64000> DepotPool;
|
|
|
|
extern DepotPool _depot_pool;
|
2008-04-17 19:10:30 +00:00
|
|
|
|
2009-05-22 15:13:50 +00:00
|
|
|
struct Depot : DepotPool::PoolItem<&_depot_pool> {
|
2010-05-12 19:21:00 +00:00
|
|
|
Town *town;
|
2010-05-12 20:50:10 +00:00
|
|
|
char *name;
|
2010-05-12 19:21:00 +00:00
|
|
|
|
2008-04-17 19:10:30 +00:00
|
|
|
TileIndex xy;
|
2010-09-16 16:31:57 +00:00
|
|
|
uint16 town_cn; ///< The N-1th depot for this town (consecutive number)
|
2010-06-20 19:13:02 +00:00
|
|
|
Date build_date; ///< Date of construction
|
2008-04-17 19:10:30 +00:00
|
|
|
|
2009-01-03 16:06:58 +00:00
|
|
|
Depot(TileIndex xy = INVALID_TILE) : xy(xy) {}
|
2008-04-17 19:10:30 +00:00
|
|
|
~Depot();
|
|
|
|
|
2009-09-10 14:36:38 +00:00
|
|
|
static FORCEINLINE Depot *GetByTile(TileIndex tile)
|
|
|
|
{
|
|
|
|
return Depot::Get(GetDepotIndex(tile));
|
|
|
|
}
|
2010-05-12 19:21:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Is the "type" of depot the same as the given depot,
|
|
|
|
* i.e. are both a rail, road or ship depots?
|
|
|
|
* @param d The depot to compare to.
|
|
|
|
* @return true iff their types are equal.
|
|
|
|
*/
|
|
|
|
FORCEINLINE bool IsOfType(const Depot *d) const
|
|
|
|
{
|
|
|
|
return GetTileType(d->xy) == GetTileType(this->xy);
|
|
|
|
}
|
2009-06-24 19:26:41 +00:00
|
|
|
};
|
2008-04-17 19:10:30 +00:00
|
|
|
|
2009-05-22 14:23:36 +00:00
|
|
|
#define FOR_ALL_DEPOTS_FROM(var, start) FOR_ALL_ITEMS_FROM(Depot, depot_index, var, start)
|
|
|
|
#define FOR_ALL_DEPOTS(var) FOR_ALL_DEPOTS_FROM(var, 0)
|
2008-04-17 19:10:30 +00:00
|
|
|
|
|
|
|
#endif /* DEPOT_BASE_H */
|