mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[7304] Move inner template class from parent class definition for better compatibility with some GCC versions.
This commit is contained in:
parent
a5f51f70d0
commit
b419c0ed03
3 changed files with 56 additions and 62 deletions
|
|
@ -31,14 +31,14 @@ INSTANTIATE_SINGLETON_1(PoolHandler);
|
|||
// Methods of template class PoolGroup
|
||||
|
||||
template <class T>
|
||||
PoolHandler::PoolGroup<T>::PoolGroup()
|
||||
PoolGroup<T>::PoolGroup()
|
||||
{
|
||||
Spawned = 0;
|
||||
}
|
||||
|
||||
// Method to add a gameobject/creature guid to the proper list depending on pool type and chance value
|
||||
template <class T>
|
||||
void PoolHandler::PoolGroup<T>::AddEntry(PoolObject& poolitem, uint32 maxentries)
|
||||
void PoolGroup<T>::AddEntry(PoolObject& poolitem, uint32 maxentries)
|
||||
{
|
||||
if (poolitem.chance != 0 && maxentries == 1)
|
||||
ExplicitlyChanced.push_back(poolitem);
|
||||
|
|
@ -48,7 +48,7 @@ void PoolHandler::PoolGroup<T>::AddEntry(PoolObject& poolitem, uint32 maxentries
|
|||
|
||||
// Method to check the chances are proper in this object pool
|
||||
template <class T>
|
||||
bool PoolHandler::PoolGroup<T>::CheckPool(void)
|
||||
bool PoolGroup<T>::CheckPool(void)
|
||||
{
|
||||
if (EqualChanced.size() == 0)
|
||||
{
|
||||
|
|
@ -63,7 +63,7 @@ bool PoolHandler::PoolGroup<T>::CheckPool(void)
|
|||
|
||||
// Method that tell if the gameobject, creature or pool is spawned currently
|
||||
template <class T>
|
||||
bool PoolHandler::PoolGroup<T>::IsSpawnedObject(uint32 guid)
|
||||
bool PoolGroup<T>::IsSpawnedObject(uint32 guid)
|
||||
{
|
||||
for (uint32 i=0; i<ExplicitlyChanced.size(); ++i)
|
||||
if (ExplicitlyChanced[i].guid == guid)
|
||||
|
|
@ -77,7 +77,7 @@ bool PoolHandler::PoolGroup<T>::IsSpawnedObject(uint32 guid)
|
|||
// Method that return a guid of a rolled creature or gameobject
|
||||
// Note: Copy from loot system because it's very similar and only few things change
|
||||
template <class T>
|
||||
uint32 PoolHandler::PoolGroup<T>::RollOne(void)
|
||||
uint32 PoolGroup<T>::RollOne(void)
|
||||
{
|
||||
if (!ExplicitlyChanced.empty()) // First explicitly chanced entries are checked
|
||||
{
|
||||
|
|
@ -100,7 +100,7 @@ uint32 PoolHandler::PoolGroup<T>::RollOne(void)
|
|||
// If no guid is passed, the pool is just removed (event end case)
|
||||
// If guid is filled, cache will be used and no removal will occur, it just fill the cache
|
||||
template<class T>
|
||||
void PoolHandler::PoolGroup<T>::DespawnObject(uint32 guid)
|
||||
void PoolGroup<T>::DespawnObject(uint32 guid)
|
||||
{
|
||||
for (int i=0; i<EqualChanced.size(); ++i)
|
||||
{
|
||||
|
|
@ -122,7 +122,7 @@ void PoolHandler::PoolGroup<T>::DespawnObject(uint32 guid)
|
|||
|
||||
// Method that is actualy doing the removal job on one creature
|
||||
template<>
|
||||
void PoolHandler::PoolGroup<Creature>::Despawn1Object(uint32 guid)
|
||||
void PoolGroup<Creature>::Despawn1Object(uint32 guid)
|
||||
{
|
||||
if (CreatureData const* data = objmgr.GetCreatureData(guid))
|
||||
{
|
||||
|
|
@ -138,7 +138,7 @@ void PoolHandler::PoolGroup<Creature>::Despawn1Object(uint32 guid)
|
|||
|
||||
// Same on one gameobject
|
||||
template<>
|
||||
void PoolHandler::PoolGroup<GameObject>::Despawn1Object(uint32 guid)
|
||||
void PoolGroup<GameObject>::Despawn1Object(uint32 guid)
|
||||
{
|
||||
if (GameObjectData const* data = objmgr.GetGOData(guid))
|
||||
{
|
||||
|
|
@ -151,14 +151,14 @@ void PoolHandler::PoolGroup<GameObject>::Despawn1Object(uint32 guid)
|
|||
|
||||
// Same on one pool
|
||||
template<>
|
||||
void PoolHandler::PoolGroup<PoolHandler::Pool>::Despawn1Object(uint32 child_pool_id)
|
||||
void PoolGroup<Pool>::Despawn1Object(uint32 child_pool_id)
|
||||
{
|
||||
poolhandler.DespawnPool(child_pool_id);
|
||||
}
|
||||
|
||||
// Method for a pool only to remove any found record causing a circular dependency loop
|
||||
template<>
|
||||
void PoolHandler::PoolGroup<PoolHandler::Pool>::RemoveOneRelation(uint16 child_pool_id)
|
||||
void PoolGroup<Pool>::RemoveOneRelation(uint16 child_pool_id)
|
||||
{
|
||||
for (PoolObjectList::iterator itr = ExplicitlyChanced.begin(); itr != ExplicitlyChanced.end(); ++itr)
|
||||
{
|
||||
|
|
@ -182,7 +182,7 @@ void PoolHandler::PoolGroup<PoolHandler::Pool>::RemoveOneRelation(uint16 child_p
|
|||
// if cache is false (initialization or event start), X creatures are spawned with X <= limit (< if limit higher that the number of creatures in pool)
|
||||
// if cache is true, this means only one has to be spawned (or respawned if the rolled one is same as cached one)
|
||||
template <class T>
|
||||
void PoolHandler::PoolGroup<T>::SpawnObject(uint32 limit, bool cache)
|
||||
void PoolGroup<T>::SpawnObject(uint32 limit, bool cache)
|
||||
{
|
||||
if (limit == 1) // This is the only case where explicit chance is used
|
||||
{
|
||||
|
|
@ -227,7 +227,7 @@ void PoolHandler::PoolGroup<T>::SpawnObject(uint32 limit, bool cache)
|
|||
|
||||
// Method that is actualy doing the spawn job on 1 creature
|
||||
template <>
|
||||
bool PoolHandler::PoolGroup<Creature>::Spawn1Object(uint32 guid)
|
||||
bool PoolGroup<Creature>::Spawn1Object(uint32 guid)
|
||||
{
|
||||
CreatureData const* data = objmgr.GetCreatureData(guid);
|
||||
if (data)
|
||||
|
|
@ -257,7 +257,7 @@ bool PoolHandler::PoolGroup<Creature>::Spawn1Object(uint32 guid)
|
|||
|
||||
// Same for 1 gameobject
|
||||
template <>
|
||||
bool PoolHandler::PoolGroup<GameObject>::Spawn1Object(uint32 guid)
|
||||
bool PoolGroup<GameObject>::Spawn1Object(uint32 guid)
|
||||
{
|
||||
GameObjectData const* data = objmgr.GetGOData(guid);
|
||||
if (data)
|
||||
|
|
@ -288,7 +288,7 @@ bool PoolHandler::PoolGroup<GameObject>::Spawn1Object(uint32 guid)
|
|||
|
||||
// Same for 1 pool
|
||||
template <>
|
||||
bool PoolHandler::PoolGroup<PoolHandler::Pool>::Spawn1Object(uint32 child_pool_id)
|
||||
bool PoolGroup<Pool>::Spawn1Object(uint32 child_pool_id)
|
||||
{
|
||||
poolhandler.SpawnPool(child_pool_id);
|
||||
return true;
|
||||
|
|
@ -296,7 +296,7 @@ bool PoolHandler::PoolGroup<PoolHandler::Pool>::Spawn1Object(uint32 child_pool_i
|
|||
|
||||
// Method that does the respawn job on the specified creature
|
||||
template <>
|
||||
bool PoolHandler::PoolGroup<Creature>::ReSpawn1Object(uint32 guid)
|
||||
bool PoolGroup<Creature>::ReSpawn1Object(uint32 guid)
|
||||
{
|
||||
CreatureData const* data = objmgr.GetCreatureData(guid);
|
||||
if (data)
|
||||
|
|
@ -310,7 +310,7 @@ bool PoolHandler::PoolGroup<Creature>::ReSpawn1Object(uint32 guid)
|
|||
|
||||
// Same for 1 gameobject
|
||||
template <>
|
||||
bool PoolHandler::PoolGroup<GameObject>::ReSpawn1Object(uint32 guid)
|
||||
bool PoolGroup<GameObject>::ReSpawn1Object(uint32 guid)
|
||||
{
|
||||
GameObjectData const* data = objmgr.GetGOData(guid);
|
||||
if (data)
|
||||
|
|
@ -324,7 +324,7 @@ bool PoolHandler::PoolGroup<GameObject>::ReSpawn1Object(uint32 guid)
|
|||
|
||||
// Nothing to do for a child Pool
|
||||
template <>
|
||||
bool PoolHandler::PoolGroup<PoolHandler::Pool>::ReSpawn1Object(uint32 guid)
|
||||
bool PoolGroup<Pool>::ReSpawn1Object(uint32 guid)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,47 +36,8 @@ struct PoolObject
|
|||
PoolObject(uint32 _guid, float _chance): guid(_guid), chance(fabs(_chance)), spawned(false) {}
|
||||
};
|
||||
|
||||
class PoolHandler
|
||||
{
|
||||
template <class T> class PoolGroup;
|
||||
class Pool;
|
||||
|
||||
public:
|
||||
PoolHandler();
|
||||
~PoolHandler() {};
|
||||
void LoadFromDB();
|
||||
uint16 IsPartOfAPool(uint32 guid, uint32 type);
|
||||
bool IsSpawnedObject(uint16 pool_id, uint32 guid, uint32 type);
|
||||
bool CheckPool(uint16 pool_id);
|
||||
void SpawnPool(uint16 pool_id, bool cache=false);
|
||||
void DespawnPool(uint16 pool_id);
|
||||
void UpdatePool(uint16 pool_id, uint32 guid, uint32 type);
|
||||
void Initialize();
|
||||
|
||||
private:
|
||||
|
||||
protected:
|
||||
bool isSystemInit;
|
||||
uint16 max_pool_id;
|
||||
typedef std::vector<PoolTemplateData> PoolTemplateDataMap;
|
||||
typedef std::vector<PoolGroup<Creature> > PoolGroupCreatureMap;
|
||||
typedef std::vector<PoolGroup<GameObject> > PoolGroupGameObjectMap;
|
||||
typedef std::vector<PoolGroup<Pool> > PoolGroupPoolMap;
|
||||
typedef std::pair<uint32, uint16> SearchPair;
|
||||
typedef std::map<uint32, uint16> SearchMap;
|
||||
|
||||
PoolTemplateDataMap mPoolTemplate;
|
||||
PoolGroupCreatureMap mPoolCreatureGroups;
|
||||
PoolGroupGameObjectMap mPoolGameobjectGroups;
|
||||
PoolGroupPoolMap mPoolPoolGroups;
|
||||
SearchMap mCreatureSearchMap;
|
||||
SearchMap mGameobjectSearchMap;
|
||||
SearchMap mPoolSearchMap;
|
||||
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class PoolHandler::PoolGroup
|
||||
class PoolGroup
|
||||
{
|
||||
public:
|
||||
PoolGroup();
|
||||
|
|
@ -94,16 +55,49 @@ class PoolHandler::PoolGroup
|
|||
void RemoveOneRelation(uint16 child_pool_id);
|
||||
private:
|
||||
typedef std::vector<PoolObject> PoolObjectList;
|
||||
uint32 CacheValue; // Store the guid of the removed creature/gameobject during a pool update
|
||||
uint32 CacheValue; // Store the guid of the removed creature/gameobject during a pool update
|
||||
PoolObjectList ExplicitlyChanced;
|
||||
PoolObjectList EqualChanced;
|
||||
uint32 Spawned; // Used to know the number of spawned objects
|
||||
|
||||
uint32 Spawned; // Used to know the number of spawned objects
|
||||
};
|
||||
|
||||
class PoolHandler::Pool
|
||||
class Pool // for Pool of Pool case
|
||||
{
|
||||
};
|
||||
|
||||
class PoolHandler
|
||||
{
|
||||
public:
|
||||
PoolHandler();
|
||||
~PoolHandler() {};
|
||||
void LoadFromDB();
|
||||
uint16 IsPartOfAPool(uint32 guid, uint32 type);
|
||||
bool IsSpawnedObject(uint16 pool_id, uint32 guid, uint32 type);
|
||||
bool CheckPool(uint16 pool_id);
|
||||
void SpawnPool(uint16 pool_id, bool cache=false);
|
||||
void DespawnPool(uint16 pool_id);
|
||||
void UpdatePool(uint16 pool_id, uint32 guid, uint32 type);
|
||||
void Initialize();
|
||||
|
||||
protected:
|
||||
bool isSystemInit;
|
||||
uint16 max_pool_id;
|
||||
typedef std::vector<PoolTemplateData> PoolTemplateDataMap;
|
||||
typedef std::vector<PoolGroup<Creature> > PoolGroupCreatureMap;
|
||||
typedef std::vector<PoolGroup<GameObject> > PoolGroupGameObjectMap;
|
||||
typedef std::vector<PoolGroup<Pool> > PoolGroupPoolMap;
|
||||
typedef std::pair<uint32, uint16> SearchPair;
|
||||
typedef std::map<uint32, uint16> SearchMap;
|
||||
|
||||
PoolTemplateDataMap mPoolTemplate;
|
||||
PoolGroupCreatureMap mPoolCreatureGroups;
|
||||
PoolGroupGameObjectMap mPoolGameobjectGroups;
|
||||
PoolGroupPoolMap mPoolPoolGroups;
|
||||
SearchMap mCreatureSearchMap;
|
||||
SearchMap mGameobjectSearchMap;
|
||||
SearchMap mPoolSearchMap;
|
||||
|
||||
};
|
||||
|
||||
#define poolhandler MaNGOS::Singleton<PoolHandler>::Instance()
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "7303"
|
||||
#define REVISION_NR "7304"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue