aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/PoolHandler.cpp34
-rw-r--r--src/game/PoolHandler.h68
-rw-r--r--src/shared/revision_nr.h2
3 files changed, 49 insertions, 55 deletions
diff --git a/src/game/PoolHandler.cpp b/src/game/PoolHandler.cpp
index 7aee571331c..0f18aee0549 100644
--- a/src/game/PoolHandler.cpp
+++ b/src/game/PoolHandler.cpp
@@ -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;
}
diff --git a/src/game/PoolHandler.h b/src/game/PoolHandler.h
index b920db5f7d2..747dae62edb 100644
--- a/src/game/PoolHandler.h
+++ b/src/game/PoolHandler.h
@@ -36,11 +36,37 @@ struct PoolObject
PoolObject(uint32 _guid, float _chance): guid(_guid), chance(fabs(_chance)), spawned(false) {}
};
-class PoolHandler
+template <class T>
+class PoolGroup
{
- template <class T> class PoolGroup;
- class Pool;
+ public:
+ PoolGroup();
+ ~PoolGroup() {};
+ bool isEmpty() { return ExplicitlyChanced.size()==0 && EqualChanced.size()==0; }
+ void AddEntry(PoolObject& poolitem, uint32 maxentries);
+ bool CheckPool(void);
+ uint32 RollOne(void);
+ bool IsSpawnedObject(uint32 guid);
+ void DespawnObject(uint32 guid=0);
+ void Despawn1Object(uint32 guid);
+ void SpawnObject(uint32 limit, bool cache=false);
+ bool Spawn1Object(uint32 guid);
+ bool ReSpawn1Object(uint32 guid);
+ 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
+ PoolObjectList ExplicitlyChanced;
+ PoolObjectList EqualChanced;
+ uint32 Spawned; // Used to know the number of spawned objects
+};
+class Pool // for Pool of Pool case
+{
+};
+
+class PoolHandler
+{
public:
PoolHandler();
~PoolHandler() {};
@@ -53,15 +79,13 @@ class PoolHandler
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<Creature> > PoolGroupCreatureMap;
typedef std::vector<PoolGroup<GameObject> > PoolGroupGameObjectMap;
- typedef std::vector<PoolGroup<Pool> > PoolGroupPoolMap;
+ typedef std::vector<PoolGroup<Pool> > PoolGroupPoolMap;
typedef std::pair<uint32, uint16> SearchPair;
typedef std::map<uint32, uint16> SearchMap;
@@ -75,35 +99,5 @@ class PoolHandler
};
-template <class T>
-class PoolHandler::PoolGroup
-{
- public:
- PoolGroup();
- ~PoolGroup() {};
- bool isEmpty() { return ExplicitlyChanced.size()==0 && EqualChanced.size()==0; }
- void AddEntry(PoolObject& poolitem, uint32 maxentries);
- bool CheckPool(void);
- uint32 RollOne(void);
- bool IsSpawnedObject(uint32 guid);
- void DespawnObject(uint32 guid=0);
- void Despawn1Object(uint32 guid);
- void SpawnObject(uint32 limit, bool cache=false);
- bool Spawn1Object(uint32 guid);
- bool ReSpawn1Object(uint32 guid);
- 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
- PoolObjectList ExplicitlyChanced;
- PoolObjectList EqualChanced;
- uint32 Spawned; // Used to know the number of spawned objects
-
-};
-
-class PoolHandler::Pool
-{
-};
-
#define poolhandler MaNGOS::Singleton<PoolHandler>::Instance()
#endif
diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h
index 7e8a05116d0..9c40bc3f0e6 100644
--- a/src/shared/revision_nr.h
+++ b/src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
- #define REVISION_NR "7303"
+ #define REVISION_NR "7304"
#endif // __REVISION_NR_H__