2011-02-19 18:23:45 +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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @file pool_func.cpp Implementation of PoolBase methods. */
|
|
|
|
|
|
|
|
#include "../stdafx.h"
|
|
|
|
#include "pool_type.hpp"
|
|
|
|
|
2014-04-23 20:13:33 +00:00
|
|
|
#include "../safeguards.h"
|
|
|
|
|
2011-02-19 18:55:10 +00:00
|
|
|
/**
|
|
|
|
* Destructor removes this object from the pool vector and
|
|
|
|
* deletes the vector itself if this was the last item removed.
|
|
|
|
*/
|
2011-02-24 06:57:55 +00:00
|
|
|
/* virtual */ PoolBase::~PoolBase()
|
2011-02-19 18:23:45 +00:00
|
|
|
{
|
|
|
|
PoolVector *pools = PoolBase::GetPools();
|
2018-09-23 16:36:45 +00:00
|
|
|
pools->erase(std::find(pools->begin(), pools->end(), this));
|
2023-10-20 18:09:58 +00:00
|
|
|
if (pools->empty()) delete pools;
|
2011-02-19 18:23:45 +00:00
|
|
|
}
|
|
|
|
|
2011-02-19 18:55:10 +00:00
|
|
|
/**
|
2011-02-19 23:05:47 +00:00
|
|
|
* Clean all pools of given type.
|
|
|
|
* @param pt pool types to clean.
|
2011-02-19 18:55:10 +00:00
|
|
|
*/
|
2011-02-19 23:05:47 +00:00
|
|
|
/* static */ void PoolBase::Clean(PoolType pt)
|
2011-02-19 18:23:45 +00:00
|
|
|
{
|
2019-02-17 11:20:52 +00:00
|
|
|
for (PoolBase *pool : *PoolBase::GetPools()) {
|
2011-02-19 23:05:47 +00:00
|
|
|
if (pool->type & pt) pool->CleanPool();
|
2011-02-19 18:23:45 +00:00
|
|
|
}
|
|
|
|
}
|