From 10f0988fd90b70e489a97c2c5e37ebdfeace149d Mon Sep 17 00:00:00 2001 From: megamage Date: Thu, 19 Feb 2009 18:52:03 -0600 Subject: [PATCH] [7304] Move inner template class from parent class definition for better compatibility with some GCC versions. Author: VladimirMangos --HG-- branch : trunk --- src/game/PoolHandler.cpp | 34 ++++++++--------- src/game/PoolHandler.h | 82 +++++++++++++++++++--------------------- src/shared/revision_nr.h | 2 +- 3 files changed, 56 insertions(+), 62 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 -PoolHandler::PoolGroup::PoolGroup() +PoolGroup::PoolGroup() { Spawned = 0; } // Method to add a gameobject/creature guid to the proper list depending on pool type and chance value template -void PoolHandler::PoolGroup::AddEntry(PoolObject& poolitem, uint32 maxentries) +void PoolGroup::AddEntry(PoolObject& poolitem, uint32 maxentries) { if (poolitem.chance != 0 && maxentries == 1) ExplicitlyChanced.push_back(poolitem); @@ -48,7 +48,7 @@ void PoolHandler::PoolGroup::AddEntry(PoolObject& poolitem, uint32 maxentries // Method to check the chances are proper in this object pool template -bool PoolHandler::PoolGroup::CheckPool(void) +bool PoolGroup::CheckPool(void) { if (EqualChanced.size() == 0) { @@ -63,7 +63,7 @@ bool PoolHandler::PoolGroup::CheckPool(void) // Method that tell if the gameobject, creature or pool is spawned currently template -bool PoolHandler::PoolGroup::IsSpawnedObject(uint32 guid) +bool PoolGroup::IsSpawnedObject(uint32 guid) { for (uint32 i=0; i::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 -uint32 PoolHandler::PoolGroup::RollOne(void) +uint32 PoolGroup::RollOne(void) { if (!ExplicitlyChanced.empty()) // First explicitly chanced entries are checked { @@ -100,7 +100,7 @@ uint32 PoolHandler::PoolGroup::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 -void PoolHandler::PoolGroup::DespawnObject(uint32 guid) +void PoolGroup::DespawnObject(uint32 guid) { for (int i=0; i::DespawnObject(uint32 guid) // Method that is actualy doing the removal job on one creature template<> -void PoolHandler::PoolGroup::Despawn1Object(uint32 guid) +void PoolGroup::Despawn1Object(uint32 guid) { if (CreatureData const* data = objmgr.GetCreatureData(guid)) { @@ -138,7 +138,7 @@ void PoolHandler::PoolGroup::Despawn1Object(uint32 guid) // Same on one gameobject template<> -void PoolHandler::PoolGroup::Despawn1Object(uint32 guid) +void PoolGroup::Despawn1Object(uint32 guid) { if (GameObjectData const* data = objmgr.GetGOData(guid)) { @@ -151,14 +151,14 @@ void PoolHandler::PoolGroup::Despawn1Object(uint32 guid) // Same on one pool template<> -void PoolHandler::PoolGroup::Despawn1Object(uint32 child_pool_id) +void PoolGroup::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::RemoveOneRelation(uint16 child_pool_id) +void PoolGroup::RemoveOneRelation(uint16 child_pool_id) { for (PoolObjectList::iterator itr = ExplicitlyChanced.begin(); itr != ExplicitlyChanced.end(); ++itr) { @@ -182,7 +182,7 @@ void PoolHandler::PoolGroup::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 -void PoolHandler::PoolGroup::SpawnObject(uint32 limit, bool cache) +void PoolGroup::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::SpawnObject(uint32 limit, bool cache) // Method that is actualy doing the spawn job on 1 creature template <> -bool PoolHandler::PoolGroup::Spawn1Object(uint32 guid) +bool PoolGroup::Spawn1Object(uint32 guid) { CreatureData const* data = objmgr.GetCreatureData(guid); if (data) @@ -257,7 +257,7 @@ bool PoolHandler::PoolGroup::Spawn1Object(uint32 guid) // Same for 1 gameobject template <> -bool PoolHandler::PoolGroup::Spawn1Object(uint32 guid) +bool PoolGroup::Spawn1Object(uint32 guid) { GameObjectData const* data = objmgr.GetGOData(guid); if (data) @@ -288,7 +288,7 @@ bool PoolHandler::PoolGroup::Spawn1Object(uint32 guid) // Same for 1 pool template <> -bool PoolHandler::PoolGroup::Spawn1Object(uint32 child_pool_id) +bool PoolGroup::Spawn1Object(uint32 child_pool_id) { poolhandler.SpawnPool(child_pool_id); return true; @@ -296,7 +296,7 @@ bool PoolHandler::PoolGroup::Spawn1Object(uint32 child_pool_i // Method that does the respawn job on the specified creature template <> -bool PoolHandler::PoolGroup::ReSpawn1Object(uint32 guid) +bool PoolGroup::ReSpawn1Object(uint32 guid) { CreatureData const* data = objmgr.GetCreatureData(guid); if (data) @@ -310,7 +310,7 @@ bool PoolHandler::PoolGroup::ReSpawn1Object(uint32 guid) // Same for 1 gameobject template <> -bool PoolHandler::PoolGroup::ReSpawn1Object(uint32 guid) +bool PoolGroup::ReSpawn1Object(uint32 guid) { GameObjectData const* data = objmgr.GetGOData(guid); if (data) @@ -324,7 +324,7 @@ bool PoolHandler::PoolGroup::ReSpawn1Object(uint32 guid) // Nothing to do for a child Pool template <> -bool PoolHandler::PoolGroup::ReSpawn1Object(uint32 guid) +bool PoolGroup::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,47 +36,8 @@ struct PoolObject PoolObject(uint32 _guid, float _chance): guid(_guid), chance(fabs(_chance)), spawned(false) {} }; -class PoolHandler -{ - template 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 PoolTemplateDataMap; - typedef std::vector > PoolGroupCreatureMap; - typedef std::vector > PoolGroupGameObjectMap; - typedef std::vector > PoolGroupPoolMap; - typedef std::pair SearchPair; - typedef std::map SearchMap; - - PoolTemplateDataMap mPoolTemplate; - PoolGroupCreatureMap mPoolCreatureGroups; - PoolGroupGameObjectMap mPoolGameobjectGroups; - PoolGroupPoolMap mPoolPoolGroups; - SearchMap mCreatureSearchMap; - SearchMap mGameobjectSearchMap; - SearchMap mPoolSearchMap; - -}; - template -class PoolHandler::PoolGroup +class PoolGroup { public: PoolGroup(); @@ -94,16 +55,49 @@ class PoolHandler::PoolGroup void RemoveOneRelation(uint16 child_pool_id); private: typedef std::vector 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 PoolTemplateDataMap; + typedef std::vector > PoolGroupCreatureMap; + typedef std::vector > PoolGroupGameObjectMap; + typedef std::vector > PoolGroupPoolMap; + typedef std::pair SearchPair; + typedef std::map SearchMap; + + PoolTemplateDataMap mPoolTemplate; + PoolGroupCreatureMap mPoolCreatureGroups; + PoolGroupGameObjectMap mPoolGameobjectGroups; + PoolGroupPoolMap mPoolPoolGroups; + SearchMap mCreatureSearchMap; + SearchMap mGameobjectSearchMap; + SearchMap mPoolSearchMap; + +}; + #define poolhandler MaNGOS::Singleton::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__