|
@@ -5,49 +5,49 @@
|
|
|
* 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/>.
|
|
|
*/
|
|
|
|
|
|
/** @file pool_type.hpp Defintion of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle, Town, and other indexed items. */
|
|
|
|
|
|
#ifndef POOL_TYPE_HPP
|
|
|
#define POOL_TYPE_HPP
|
|
|
|
|
|
#include "smallvec_type.hpp"
|
|
|
#include "enum_type.hpp"
|
|
|
|
|
|
/** Various types of a pool. */
|
|
|
enum PoolType {
|
|
|
PT_NONE = 0x00, ///< No pool is selected.
|
|
|
PT_NORMAL = 0x01, ///< Normal pool containing game objects.
|
|
|
PT_NCLIENT = 0x02, ///< Network client pools.
|
|
|
PT_NADMIN = 0x04, ///< Network admin pool.
|
|
|
PT_DATA = 0x08, ///< NewGRF or other data, that is not reset together with normal pools.
|
|
|
PT_ALL = 0x0F, ///< All pool types.
|
|
|
};
|
|
|
DECLARE_ENUM_AS_BIT_SET(PoolType)
|
|
|
|
|
|
typedef SmallVector<struct PoolBase *, 4> PoolVector; ///< Vector of pointers to PoolBase
|
|
|
typedef std::vector<struct PoolBase *> PoolVector; ///< Vector of pointers to PoolBase
|
|
|
|
|
|
/** Base class for base of all pools. */
|
|
|
struct PoolBase {
|
|
|
const PoolType type; ///< Type of this pool.
|
|
|
|
|
|
/**
|
|
|
* Function used to access the vector of all pools.
|
|
|
* @return pointer to vector of all pools
|
|
|
*/
|
|
|
static PoolVector *GetPools()
|
|
|
{
|
|
|
static PoolVector *pools = new PoolVector();
|
|
|
return pools;
|
|
|
}
|
|
|
|
|
|
static void Clean(PoolType);
|
|
|
|
|
|
/**
|
|
|
* Constructor registers this object in the pool vector.
|
|
|
* @param pt type of this pool.
|
|
|
*/
|
|
|
PoolBase(PoolType pt) : type(pt)
|
|
|
{
|
|
|
PoolBase::GetPools()->push_back(this);
|