Changeset - r17360:71e102cec3ce
[Not reviewed]
src/autoreplace.cpp
Show inline comments
 
@@ -134,8 +134,3 @@ CommandCost RemoveEngineReplacement(Engi
 

	
 
	return CMD_ERROR;
 
}
 

	
 
void InitializeEngineRenews()
 
{
 
	_enginerenew_pool.CleanPool();
 
}
src/cargopacket.cpp
Show inline comments
 
@@ -18,14 +18,6 @@ CargoPacketPool _cargopacket_pool("Cargo
 
INSTANTIATE_POOL_METHODS(CargoPacket)
 

	
 
/**
 
 * Initialize, i.e. clean, the pool with cargo packets.
 
 */
 
void InitializeCargoPackets()
 
{
 
	_cargopacket_pool.CleanPool();
 
}
 

	
 
/**
 
 * Create a new packet for savegame loading.
 
 */
 
CargoPacket::CargoPacket()
src/cargopacket.h
Show inline comments
 
@@ -24,7 +24,7 @@ typedef uint32 CargoPacketID;
 
struct CargoPacket;
 

	
 
/** Type of the pool for cargo packets for a little over 16 million packets. */
 
typedef Pool<CargoPacket, CargoPacketID, 1024, 0xFFF000, true, false> CargoPacketPool;
 
typedef Pool<CargoPacket, CargoPacketID, 1024, 0xFFF000, PT_NORMAL, true, false> CargoPacketPool;
 
/** The actual pool with cargo packets. */
 
extern CargoPacketPool _cargopacket_pool;
 

	
src/company_cmd.cpp
Show inline comments
 
@@ -601,7 +601,6 @@ static void MaybeStartNewCompany()
 
/** Initialize the pool of companies. */
 
void InitializeCompanies()
 
{
 
	_company_pool.CleanPool();
 
	_cur_company_tick_index = 0;
 
}
 

	
src/core/pool_func.cpp
Show inline comments
 
@@ -24,14 +24,15 @@ PoolBase::~PoolBase()
 
}
 

	
 
/**
 
 * Clean all pools - calls Pool::CleanPool()
 
 * Clean all pools of given type.
 
 * @param pt pool types to clean.
 
 */
 
/* static */ void PoolBase::CleanAll()
 
/* static */ void PoolBase::Clean(PoolType pt)
 
{
 
	PoolVector *pools = PoolBase::GetPools();
 
	PoolBase **end = pools->End();
 
	for (PoolBase **ppool = pools->Begin(); ppool != end; ppool++) {
 
		PoolBase *pool = *ppool;
 
		pool->CleanPool();
 
		if (pool->type & pt) pool->CleanPool();
 
	}
 
}
src/core/pool_func.hpp
Show inline comments
 
@@ -17,14 +17,15 @@
 
#include "pool_type.hpp"
 

	
 
#define DEFINE_POOL_METHOD(type) \
 
	template <class Titem, typename Tindex, size_t Tgrowth_step, size_t Tmax_size, bool Tcache, bool Tzero> \
 
	type Pool<Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero>
 
	template <class Titem, typename Tindex, size_t Tgrowth_step, size_t Tmax_size, PoolType Tpool_type, bool Tcache, bool Tzero> \
 
	type Pool<Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero>
 

	
 
/**
 
 * Create a clean pool.
 
 * @param name The name for the pool.
 
 */
 
DEFINE_POOL_METHOD(inline)::Pool(const char *name) :
 
		PoolBase(Tpool_type),
 
		name(name),
 
		size(0),
 
		first_free(0),
src/core/pool_type.hpp
Show inline comments
 
@@ -13,11 +13,25 @@
 
#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
 

	
 
/** 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
 
@@ -28,12 +42,13 @@ struct PoolBase {
 
		return pools;
 
	}
 

	
 
	static void CleanAll();
 
	static void Clean(PoolType);
 

	
 
	/**
 
	 * Contructor registers this object in the pool vector.
 
	 * @param pt type of this pool.
 
	 */
 
	PoolBase()
 
	PoolBase(PoolType pt) : type(pt)
 
	{
 
		*PoolBase::GetPools()->Append() = this;
 
	}
 
@@ -52,11 +67,12 @@ struct PoolBase {
 
 * @tparam Tindex       Type of the index for this pool
 
 * @tparam Tgrowth_step Size of growths; if the pool is full increase the size by this amount
 
 * @tparam Tmax_size    Maximum size of the pool
 
 * @tparam Tpool_type   Type of this pool
 
 * @tparam Tcache       Whether to perform 'alloc' caching, i.e. don't actually free/malloc just reuse the memory
 
 * @tparam Tzero        Whether to zero the memory
 
 * @warning when Tcache is enabled *all* instances of this pool's item must be of the same size.
 
 */
 
template <class Titem, typename Tindex, size_t Tgrowth_step, size_t Tmax_size, bool Tcache = false, bool Tzero = true>
 
template <class Titem, typename Tindex, size_t Tgrowth_step, size_t Tmax_size, PoolType Tpool_type = PT_NORMAL, bool Tcache = false, bool Tzero = true>
 
struct Pool : PoolBase {
 
	static const size_t MAX_SIZE = Tmax_size; ///< Make template parameter accessible from outside
 

	
 
@@ -116,7 +132,7 @@ struct Pool : PoolBase {
 
	 * Base class for all PoolItems
 
	 * @tparam Tpool The pool this item is going to be part of
 
	 */
 
	template <struct Pool<Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero> *Tpool>
 
	template <struct Pool<Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero> *Tpool>
 
	struct PoolItem {
 
		Tindex index; ///< Index of this pool item
 

	
src/depot.cpp
Show inline comments
 
@@ -52,8 +52,3 @@ Depot::~Depot()
 
	}
 
	DeleteWindowById(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_DEPOT_LIST, vt, GetTileOwner(this->xy), this->index).Pack());
 
}
 

	
 
void InitializeDepots()
 
{
 
	_depot_pool.CleanPool();
 
}
src/depot_func.h
Show inline comments
 
@@ -18,7 +18,6 @@
 
#include "slope_type.h"
 

	
 
void ShowDepotWindow(TileIndex tile, VehicleType type);
 
void InitializeDepots();
 

	
 
void DeleteDepotHighlightOfVehicle(const Vehicle *v);
 

	
src/group.h
Show inline comments
 
@@ -82,7 +82,6 @@ static inline void DecreaseGroupNumVehic
 
}
 

	
 

	
 
void InitializeGroup();
 
void SetTrainGroupID(Train *v, GroupID grp);
 
void UpdateTrainGroupID(Train *v);
 
void RemoveVehicleFromGroup(const Vehicle *v);
src/group_cmd.cpp
Show inline comments
 
@@ -67,11 +67,6 @@ Group::~Group()
 
	free(this->num_engines);
 
}
 

	
 
void InitializeGroup()
 
{
 
	_group_pool.CleanPool();
 
}
 

	
 

	
 
/**
 
 * Create a new vehicle group.
src/industry_cmd.cpp
Show inline comments
 
@@ -2638,8 +2638,6 @@ void IndustryMonthlyLoop()
 

	
 
void InitializeIndustries()
 
{
 
	_industry_pool.CleanPool();
 

	
 
	Industry::ResetIndustryCounts();
 
	_industry_sound_tile = 0;
 

	
src/misc.cpp
Show inline comments
 
@@ -25,6 +25,7 @@
 
#include "tilehighlight_func.h"
 
#include "network/network_func.h"
 
#include "window_func.h"
 
#include "core/pool_type.hpp"
 

	
 

	
 
extern TileIndex _cur_tileloop_tile;
 
@@ -33,10 +34,6 @@ extern void MakeNewgameSettingsLive();
 
void InitializeSound();
 
void InitializeMusic();
 
void InitializeVehicles();
 
void InitializeDepots();
 
void InitializeEngineRenews();
 
void InitializeOrders();
 
void InitializeOrderBackups();
 
void InitializeClearLand();
 
void InitializeRailGui();
 
void InitializeRoadGui();
 
@@ -45,13 +42,7 @@ void InitializeDockGui();
 
void InitializeObjectGui();
 
void InitializeIndustries();
 
void InitializeObjects();
 
void InitializeTowns();
 
void InitializeSubsidies();
 
void InitializeTrees();
 
void InitializeSigns();
 
void InitializeStations();
 
void InitializeRoadStops();
 
void InitializeCargoPackets();
 
void InitializeCompanies();
 
void InitializeCheats();
 
void InitializeNPF();
 
@@ -77,15 +68,12 @@ void InitializeGame(uint size_x, uint si
 
		InitializeOldNames();
 
	}
 

	
 
	PoolBase::Clean(PT_NORMAL);
 

	
 
	InitializeSound();
 
	InitializeMusic();
 

	
 
	InitializeEngineRenews();
 
	InitializeVehicles();
 
	InitializeDepots();
 
	InitializeOrders();
 
	InitializeOrderBackups();
 
	InitializeGroup();
 

	
 
	InitNewsItemStructs();
 
	InitializeLandscape();
 
@@ -96,13 +84,7 @@ void InitializeGame(uint size_x, uint si
 
	InitializeDockGui();
 
	InitializeObjectGui();
 
	InitializeAIGui();
 
	InitializeTowns();
 
	InitializeSubsidies();
 
	InitializeTrees();
 
	InitializeSigns();
 
	InitializeStations();
 
	InitializeRoadStops();
 
	InitializeCargoPackets();
 
	InitializeIndustries();
 
	InitializeObjects();
 
	InitializeBuildingCounts();
src/network/network.cpp
Show inline comments
 
@@ -493,9 +493,7 @@ void ParseConnectionString(const char **
 
 */
 
static void InitializeNetworkPools(bool close_admins = true)
 
{
 
	_networkclientsocket_pool.CleanPool();
 
	_networkclientinfo_pool.CleanPool();
 
	if (close_admins) _networkadminsocket_pool.CleanPool();
 
	PoolBase::Clean(PT_NCLIENT | (close_admins ? PT_NADMIN : PT_NONE));
 
}
 

	
 
/**
src/network/network_admin.h
Show inline comments
 
@@ -21,7 +21,7 @@
 
extern AdminIndex _redirect_console_to_admin;
 

	
 
class ServerNetworkAdminSocketHandler;
 
typedef Pool<ServerNetworkAdminSocketHandler, AdminIndex, 2, MAX_ADMINS> NetworkAdminSocketPool;
 
typedef Pool<ServerNetworkAdminSocketHandler, AdminIndex, 2, MAX_ADMINS, PT_NADMIN> NetworkAdminSocketPool;
 
extern NetworkAdminSocketPool _networkadminsocket_pool;
 

	
 
/** Class for handling the server side of the game connection. */
src/network/network_base.h
Show inline comments
 
@@ -19,7 +19,7 @@
 
#include "../core/pool_type.hpp"
 
#include "../company_type.h"
 

	
 
typedef Pool<NetworkClientInfo, ClientIndex, 8, MAX_CLIENT_SLOTS> NetworkClientInfoPool;
 
typedef Pool<NetworkClientInfo, ClientIndex, 8, MAX_CLIENT_SLOTS, PT_NCLIENT> NetworkClientInfoPool;
 
extern NetworkClientInfoPool _networkclientinfo_pool;
 

	
 
struct NetworkClientInfo : NetworkClientInfoPool::PoolItem<&_networkclientinfo_pool> {
src/network/network_server.h
Show inline comments
 
@@ -20,7 +20,7 @@
 

	
 
class ServerNetworkGameSocketHandler;
 
typedef ServerNetworkGameSocketHandler NetworkClientSocket;
 
typedef Pool<NetworkClientSocket, ClientIndex, 8, MAX_CLIENT_SLOTS> NetworkClientSocketPool;
 
typedef Pool<NetworkClientSocket, ClientIndex, 8, MAX_CLIENT_SLOTS, PT_NCLIENT> NetworkClientSocketPool;
 
extern NetworkClientSocketPool _networkclientsocket_pool;
 

	
 
/** Class for handling the server side of the game connection. */
src/newgrf_spritegroup.h
Show inline comments
 
@@ -52,7 +52,7 @@ typedef uint32 SpriteGroupID;
 
/* SPRITE_WIDTH is 24. ECS has roughly 30 sprite groups per real sprite.
 
 * Adding an 'extra' margin would be assuming 64 sprite groups per real
 
 * sprite. 64 = 2^6, so 2^30 should be enough (for now) */
 
typedef Pool<SpriteGroup, SpriteGroupID, 1024, 1 << 30> SpriteGroupPool;
 
typedef Pool<SpriteGroup, SpriteGroupID, 1024, 1 << 30, PT_DATA> SpriteGroupPool;
 
extern SpriteGroupPool _spritegroup_pool;
 

	
 
/* Common wrapper for all the different sprite group types */
src/object_cmd.cpp
Show inline comments
 
@@ -55,7 +55,6 @@ uint16 Object::counts[NUM_OBJECTS];
 
/** Initialize/reset the objects. */
 
void InitializeObjects()
 
{
 
	_object_pool.CleanPool();
 
	Object::ResetTypeCounts();
 
}
 

	
src/openttd.cpp
Show inline comments
 
@@ -270,7 +270,7 @@ static void ShutdownGame()
 
	free(_config_file);
 
#endif
 

	
 
	PoolBase::CleanAll();
 
	PoolBase::Clean(PT_ALL);
 

	
 
	ResetNewGRFData();
 

	
src/order_backup.cpp
Show inline comments
 
@@ -254,8 +254,3 @@ CommandCost CmdClearOrderBackup(TileInde
 
		}
 
	}
 
}
 

	
 
void InitializeOrderBackups()
 
{
 
	_order_backup_pool.CleanPool();
 
}
src/order_cmd.cpp
Show inline comments
 
@@ -2009,9 +2009,3 @@ bool Order::ShouldStopAtStation(const Ve
 
			/* Finally do stop when there is no non-stop flag set for this type of station. */
 
			!(this->GetNonStopType() & (is_dest_station ? ONSF_NO_STOP_AT_DESTINATION_STATION : ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS));
 
}
 

	
 
void InitializeOrders()
 
{
 
	_order_pool.CleanPool();
 
	_orderlist_pool.CleanPool();
 
}
src/roadstop.cpp
Show inline comments
 
@@ -387,9 +387,3 @@ void RoadStop::Entry::CheckIntegrity(con
 
	temp.Rebuild(rs, rs->east == this);
 
	if (temp.length != this->length || temp.occupied != this->occupied) NOT_REACHED();
 
}
 

	
 

	
 
void InitializeRoadStops()
 
{
 
	_roadstop_pool.CleanPool();
 
}
src/signs.cpp
Show inline comments
 
@@ -59,13 +59,3 @@ void UpdateAllSignVirtCoords()
 
		si->UpdateVirtCoord();
 
	}
 
}
 

	
 
/**
 
 *
 
 * Initialize the signs
 
 *
 
 */
 
void InitializeSigns()
 
{
 
	_sign_pool.CleanPool();
 
}
src/station.cpp
Show inline comments
 
@@ -514,9 +514,3 @@ StationRect& StationRect::operator = (co
 
	this->bottom = src.bottom;
 
	return *this;
 
}
 

	
 

	
 
void InitializeStations()
 
{
 
	_station_pool.CleanPool();
 
}
src/subsidy.cpp
Show inline comments
 
@@ -62,14 +62,6 @@ void Subsidy::AwardTo(CompanyID company)
 
	InvalidateWindowData(WC_SUBSIDIES_LIST, 0);
 
}
 

	
 
/**
 
 * Initializes subsidies, files don't have to include subsidy_base,h this way
 
 */
 
void InitializeSubsidies()
 
{
 
	_subsidy_pool.CleanPool();
 
}
 

	
 
Pair SetupSubsidyDecodeParam(const Subsidy *s, bool mode)
 
{
 
	NewsReferenceType reftype1 = NR_NONE;
src/town_cmd.cpp
Show inline comments
 
@@ -3028,11 +3028,6 @@ void TownsYearlyLoop()
 
	}
 
}
 

	
 
void InitializeTowns()
 
{
 
	_town_pool.CleanPool();
 
}
 

	
 
static CommandCost TerraformTile_Town(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
 
{
 
	if (AutoslopeEnabled()) {
src/vehicle.cpp
Show inline comments
 
@@ -586,9 +586,6 @@ static AutoreplaceMap _vehicles_to_autor
 

	
 
void InitializeVehicles()
 
{
 
	_vehicle_pool.CleanPool();
 
	_cargo_payment_pool.CleanPool();
 

	
 
	_age_cargo_skip_counter = 1;
 

	
 
	_vehicles_to_autoreplace.Reset();
0 comments (0 inline, 0 general)