Core/Pools: Implemented pooling for instances
This commit is contained in:
1 parent
317a9f2d32
commit
0f0b283168
10 files changed
+320
-200
No files matched your search
@@ -1624,7 +1624,7 @@ bool Creature::LoadFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap,
|
|||||||
if (!m_respawnCompatibilityMode)
|
if (!m_respawnCompatibilityMode)
|
||||||
{
|
{
|
||||||
// @todo pools need fixing! this is just a temporary thing, but they violate dynspawn principles
|
// @todo pools need fixing! this is just a temporary thing, but they violate dynspawn principles
|
||||||
if (!sPoolMgr->IsPartOfAPool<Creature>(spawnId))
|
if (!data->poolId)
|
||||||
{
|
{
|
||||||
TC_LOG_ERROR("entities.unit", "Creature (SpawnID %u) trying to load in inactive spawn group '%s':\n", spawnId, data->spawnGroupData->name.c_str());
|
TC_LOG_ERROR("entities.unit", "Creature (SpawnID %u) trying to load in inactive spawn group '%s':\n", spawnId, data->spawnGroupData->name.c_str());
|
||||||
return false;
|
return false;
|
||||||
@@ -1639,7 +1639,7 @@ bool Creature::LoadFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap,
|
|||||||
if (!m_respawnCompatibilityMode)
|
if (!m_respawnCompatibilityMode)
|
||||||
{
|
{
|
||||||
// @todo same as above
|
// @todo same as above
|
||||||
if (!sPoolMgr->IsPartOfAPool<Creature>(spawnId))
|
if (!data->poolId)
|
||||||
{
|
{
|
||||||
TC_LOG_ERROR("entities.unit", "Creature (SpawnID %u) trying to load despite a respawn timer in progress:\n", spawnId);
|
TC_LOG_ERROR("entities.unit", "Creature (SpawnID %u) trying to load despite a respawn timer in progress:\n", spawnId);
|
||||||
return false;
|
return false;
|
||||||
@@ -2038,9 +2038,9 @@ void Creature::Respawn(bool force)
|
|||||||
|
|
||||||
m_triggerJustAppeared = true;
|
m_triggerJustAppeared = true;
|
||||||
|
|
||||||
uint32 poolid = GetSpawnId() ? sPoolMgr->IsPartOfAPool<Creature>(GetSpawnId()) : 0;
|
uint32 poolid = GetCreatureData() ? GetCreatureData()->poolId : 0;
|
||||||
if (poolid)
|
if (poolid)
|
||||||
sPoolMgr->UpdatePool<Creature>(poolid, GetSpawnId());
|
sPoolMgr->UpdatePool<Creature>(GetMap()->GetPoolData(), poolid, GetSpawnId());
|
||||||
}
|
}
|
||||||
UpdateObjectVisibility();
|
UpdateObjectVisibility();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -941,9 +941,9 @@ void GameObject::Update(uint32 diff)
|
|||||||
AI()->Reset();
|
AI()->Reset();
|
||||||
|
|
||||||
// Respawn timer
|
// Respawn timer
|
||||||
uint32 poolid = GetSpawnId() ? sPoolMgr->IsPartOfAPool<GameObject>(GetSpawnId()) : 0;
|
uint32 poolid = GetGameObjectData() ? GetGameObjectData()->poolId : 0;
|
||||||
if (poolid)
|
if (poolid)
|
||||||
sPoolMgr->UpdatePool<GameObject>(poolid, GetSpawnId());
|
sPoolMgr->UpdatePool<GameObject>(GetMap()->GetPoolData(), poolid, GetSpawnId());
|
||||||
else
|
else
|
||||||
GetMap()->AddToMap(this);
|
GetMap()->AddToMap(this);
|
||||||
}
|
}
|
||||||
@@ -1237,9 +1237,9 @@ void GameObject::Delete()
|
|||||||
if (GameObjectTemplateAddon const* addon = GetTemplateAddon())
|
if (GameObjectTemplateAddon const* addon = GetTemplateAddon())
|
||||||
SetUInt32Value(GAMEOBJECT_FLAGS, addon->flags);
|
SetUInt32Value(GAMEOBJECT_FLAGS, addon->flags);
|
||||||
|
|
||||||
uint32 poolid = GetSpawnId() ? sPoolMgr->IsPartOfAPool<GameObject>(GetSpawnId()) : 0;
|
uint32 poolid = GetGameObjectData() ? GetGameObjectData()->poolId : 0;
|
||||||
if (poolid)
|
if (poolid)
|
||||||
sPoolMgr->UpdatePool<GameObject>(poolid, GetSpawnId());
|
sPoolMgr->UpdatePool<GameObject>(GetMap()->GetPoolData(), poolid, GetSpawnId());
|
||||||
else
|
else
|
||||||
AddObjectToRemoveList();
|
AddObjectToRemoveList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -407,6 +407,11 @@ void GameEventMgr::LoadFromDB()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Log error for pooled object, but still spawn it
|
||||||
|
if (data->poolId)
|
||||||
|
TC_LOG_ERROR("sql.sql", "`game_event_creature`: game event id (%i) contains creature (%u) which is part of a pool (%u). This should be spawned in game_event_pool", event_id, guid, data->poolId);
|
||||||
|
|
||||||
|
|
||||||
GuidList& crelist = mGameEventCreatureGuids[internal_event_id];
|
GuidList& crelist = mGameEventCreatureGuids[internal_event_id];
|
||||||
crelist.push_back(guid);
|
crelist.push_back(guid);
|
||||||
|
|
||||||
@@ -453,6 +458,10 @@ void GameEventMgr::LoadFromDB()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Log error for pooled object, but still spawn it
|
||||||
|
if (data->poolId)
|
||||||
|
TC_LOG_ERROR("sql.sql", "`game_event_gameobject`: game event id (%i) contains game object (%u) which is part of a pool (%u). This should be spawned in game_event_pool", event_id, guid, data->poolId);
|
||||||
|
|
||||||
GuidList& golist = mGameEventGameobjectGuids[internal_event_id];
|
GuidList& golist = mGameEventGameobjectGuids[internal_event_id];
|
||||||
golist.push_back(guid);
|
golist.push_back(guid);
|
||||||
|
|
||||||
@@ -1314,7 +1323,15 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (IdList::iterator itr = mGameEventPoolIds[internal_event_id].begin(); itr != mGameEventPoolIds[internal_event_id].end(); ++itr)
|
for (IdList::iterator itr = mGameEventPoolIds[internal_event_id].begin(); itr != mGameEventPoolIds[internal_event_id].end(); ++itr)
|
||||||
sPoolMgr->SpawnPool(*itr);
|
{
|
||||||
|
if (PoolTemplateData const* poolTemplate = sPoolMgr->GetPoolTemplate(*itr))
|
||||||
|
{
|
||||||
|
sMapMgr->DoForAllMapsWithMapId(poolTemplate->MapId, [&itr](Map* map)
|
||||||
|
{
|
||||||
|
sPoolMgr->SpawnPool(map->GetPoolData(), *itr);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameEventMgr::GameEventUnspawn(int16 event_id)
|
void GameEventMgr::GameEventUnspawn(int16 event_id)
|
||||||
@@ -1390,7 +1407,13 @@ void GameEventMgr::GameEventUnspawn(int16 event_id)
|
|||||||
|
|
||||||
for (IdList::iterator itr = mGameEventPoolIds[internal_event_id].begin(); itr != mGameEventPoolIds[internal_event_id].end(); ++itr)
|
for (IdList::iterator itr = mGameEventPoolIds[internal_event_id].begin(); itr != mGameEventPoolIds[internal_event_id].end(); ++itr)
|
||||||
{
|
{
|
||||||
sPoolMgr->DespawnPool(*itr, true);
|
if (PoolTemplateData const* poolTemplate = sPoolMgr->GetPoolTemplate(*itr))
|
||||||
|
{
|
||||||
|
sMapMgr->DoForAllMapsWithMapId(poolTemplate->MapId, [&itr](Map* map)
|
||||||
|
{
|
||||||
|
sPoolMgr->DespawnPool(map->GetPoolData(), *itr, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2068,7 +2068,7 @@ void ObjectMgr::LoadCreatures()
|
|||||||
data.movementType = fields[14].GetUInt8();
|
data.movementType = fields[14].GetUInt8();
|
||||||
data.spawnMask = fields[15].GetUInt8();
|
data.spawnMask = fields[15].GetUInt8();
|
||||||
int16 gameEvent = fields[16].GetInt8();
|
int16 gameEvent = fields[16].GetInt8();
|
||||||
uint32 PoolId = fields[17].GetUInt32();
|
data.poolId = fields[17].GetUInt32();
|
||||||
data.npcflag = fields[18].GetUInt32();
|
data.npcflag = fields[18].GetUInt32();
|
||||||
data.unit_flags = fields[19].GetUInt32();
|
data.unit_flags = fields[19].GetUInt32();
|
||||||
data.dynamicflags = fields[20].GetUInt32();
|
data.dynamicflags = fields[20].GetUInt32();
|
||||||
@@ -2208,8 +2208,8 @@ void ObjectMgr::LoadCreatures()
|
|||||||
WorldDatabase.Execute(stmt);
|
WorldDatabase.Execute(stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add to grid if not managed by the game event or pool system
|
// Add to grid if not managed by the game event
|
||||||
if (gameEvent == 0 && PoolId == 0)
|
if (gameEvent == 0)
|
||||||
AddCreatureToGrid(guid, &data);
|
AddCreatureToGrid(guid, &data);
|
||||||
}
|
}
|
||||||
while (result->NextRow());
|
while (result->NextRow());
|
||||||
@@ -2359,10 +2359,10 @@ void ObjectMgr::LoadGameObjects()
|
|||||||
data.spawnGroupData = GetLegacySpawnGroup(); // force compatibility group for transport spawns
|
data.spawnGroupData = GetLegacySpawnGroup(); // force compatibility group for transport spawns
|
||||||
|
|
||||||
int16 gameEvent = fields[15].GetInt8();
|
int16 gameEvent = fields[15].GetInt8();
|
||||||
uint32 PoolId = fields[16].GetUInt32();
|
data.poolId = fields[16].GetUInt32();
|
||||||
data.phaseUseFlags = fields[17].GetUInt8();
|
data.phaseUseFlags = fields[17].GetUInt8();
|
||||||
data.phaseId = fields[18].GetUInt32();
|
data.phaseId = fields[18].GetUInt32();
|
||||||
data.phaseGroup = fields[19].GetUInt32();
|
data.phaseGroup = fields[19].GetUInt32();
|
||||||
|
|
||||||
if (data.phaseUseFlags & ~PHASE_USE_FLAGS_ALL)
|
if (data.phaseUseFlags & ~PHASE_USE_FLAGS_ALL)
|
||||||
{
|
{
|
||||||
@@ -2459,7 +2459,7 @@ void ObjectMgr::LoadGameObjects()
|
|||||||
WorldDatabase.Execute(stmt);
|
WorldDatabase.Execute(stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gameEvent == 0 && PoolId == 0) // if not this is to be managed by GameEvent System or Pool system
|
if (gameEvent == 0) // if not this is to be managed by GameEvent System or Pool system
|
||||||
AddGameobjectToGrid(guid, &data);
|
AddGameobjectToGrid(guid, &data);
|
||||||
}
|
}
|
||||||
while (result->NextRow());
|
while (result->NextRow());
|
||||||
|
|||||||
@@ -146,6 +146,8 @@ i_scriptLock(false), _respawnCheckTimer(0)
|
|||||||
|
|
||||||
_weatherUpdateTimer.SetInterval(time_t(1 * IN_MILLISECONDS));
|
_weatherUpdateTimer.SetInterval(time_t(1 * IN_MILLISECONDS));
|
||||||
|
|
||||||
|
_poolData = sPoolMgr->InitPoolsForMap(this);
|
||||||
|
|
||||||
sTransportMgr->CreateTransportsForMap(this);
|
sTransportMgr->CreateTransportsForMap(this);
|
||||||
|
|
||||||
MMAP::MMapFactory::createOrGetMMapManager()->loadMapInstance(sWorld->GetDataPath(), GetId(), i_InstanceId);
|
MMAP::MMapFactory::createOrGetMMapManager()->loadMapInstance(sWorld->GetDataPath(), GetId(), i_InstanceId);
|
||||||
@@ -1968,7 +1970,7 @@ void Map::ProcessRespawns()
|
|||||||
GetRespawnMapForType(next->type).erase(next->spawnId);
|
GetRespawnMapForType(next->type).erase(next->spawnId);
|
||||||
|
|
||||||
// step 2: tell pooling logic to do its thing
|
// step 2: tell pooling logic to do its thing
|
||||||
sPoolMgr->UpdatePool(poolId, next->type, next->spawnId);
|
sPoolMgr->UpdatePool(GetPoolData(), poolId, next->type, next->spawnId);
|
||||||
|
|
||||||
// step 3: get rid of the actual entry
|
// step 3: get rid of the actual entry
|
||||||
RemoveRespawnTime(next->type, next->spawnId, nullptr, true);
|
RemoveRespawnTime(next->type, next->spawnId, nullptr, true);
|
||||||
@@ -2062,6 +2064,10 @@ bool Map::ShouldBeSpawnedOnGridLoad(SpawnObjectType type, ObjectGuid::LowType sp
|
|||||||
if (!IsSpawnGroupActive(spawnGroup->groupId))
|
if (!IsSpawnGroupActive(spawnGroup->groupId))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (spawnData->ToSpawnData()->poolId)
|
||||||
|
if (!GetPoolData().IsSpawnedObject(type, spawnId))
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ class MapInstanced;
|
|||||||
class Object;
|
class Object;
|
||||||
class PhaseShift;
|
class PhaseShift;
|
||||||
class Player;
|
class Player;
|
||||||
|
class SpawnedPoolData;
|
||||||
class TempSummon;
|
class TempSummon;
|
||||||
class TerrainInfo;
|
class TerrainInfo;
|
||||||
class Transport;
|
class Transport;
|
||||||
@@ -646,6 +647,9 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
|
|||||||
// This will not affect any already-present creatures in the group
|
// This will not affect any already-present creatures in the group
|
||||||
void SetSpawnGroupInactive(uint32 groupId) { SetSpawnGroupActive(groupId, false); }
|
void SetSpawnGroupInactive(uint32 groupId) { SetSpawnGroupActive(groupId, false); }
|
||||||
|
|
||||||
|
SpawnedPoolData& GetPoolData() { return *_poolData; }
|
||||||
|
SpawnedPoolData const& GetPoolData() const { return *_poolData; }
|
||||||
|
|
||||||
typedef std::function<void(Map*)> FarSpellCallback;
|
typedef std::function<void(Map*)> FarSpellCallback;
|
||||||
void AddFarSpellCallback(FarSpellCallback&& callback);
|
void AddFarSpellCallback(FarSpellCallback&& callback);
|
||||||
|
|
||||||
@@ -727,6 +731,7 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::map<HighGuid, std::unique_ptr<ObjectGuidGeneratorBase>> _guidGenerators;
|
std::map<HighGuid, std::unique_ptr<ObjectGuidGeneratorBase>> _guidGenerators;
|
||||||
|
std::unique_ptr<SpawnedPoolData> _poolData;
|
||||||
MapStoredObjectTypesContainer _objectsStore;
|
MapStoredObjectTypesContainer _objectsStore;
|
||||||
CreatureBySpawnIdContainer _creatureBySpawnIdStore;
|
CreatureBySpawnIdContainer _creatureBySpawnIdStore;
|
||||||
GameObjectBySpawnIdContainer _gameObjectBySpawnIdStore;
|
GameObjectBySpawnIdContainer _gameObjectBySpawnIdStore;
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ struct SpawnData : public SpawnMetadata
|
|||||||
{
|
{
|
||||||
uint32 id = 0; // entry in respective _template table
|
uint32 id = 0; // entry in respective _template table
|
||||||
Position spawnPoint;
|
Position spawnPoint;
|
||||||
|
uint32 poolId = 0;
|
||||||
int32 spawntimesecs = 0;
|
int32 spawntimesecs = 0;
|
||||||
uint8 spawnMask = 0;
|
uint8 spawnMask = 0;
|
||||||
uint8 phaseUseFlags = 0;
|
uint8 phaseUseFlags = 0;
|
||||||
|
|||||||
+222
-143
@@ -21,67 +21,80 @@
|
|||||||
#include "DatabaseEnv.h"
|
#include "DatabaseEnv.h"
|
||||||
#include "GameObject.h"
|
#include "GameObject.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "MapManager.h"
|
#include "Map.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// template class ActivePoolData
|
// template class SpawnedPoolData
|
||||||
|
|
||||||
ActivePoolData::ActivePoolData() = default;
|
SpawnedPoolData::SpawnedPoolData(Map* owner) : mOwner(owner) { }
|
||||||
ActivePoolData::~ActivePoolData() = default;
|
SpawnedPoolData::~SpawnedPoolData() = default;
|
||||||
|
|
||||||
// Method that tell amount spawned objects/subpools
|
// Method that tell amount spawned objects/subpools
|
||||||
uint32 ActivePoolData::GetActiveObjectCount(uint32 pool_id) const
|
uint32 SpawnedPoolData::GetSpawnedObjects(uint32 pool_id) const
|
||||||
{
|
{
|
||||||
ActivePoolPools::const_iterator itr = mSpawnedPools.find(pool_id);
|
SpawnedPoolPools::const_iterator itr = mSpawnedPools.find(pool_id);
|
||||||
return itr != mSpawnedPools.end() ? itr->second : 0;
|
return itr != mSpawnedPools.end() ? itr->second : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method that tell if a creature is spawned currently
|
// Method that tell if a creature is spawned currently
|
||||||
template<>
|
template<>
|
||||||
TC_GAME_API bool ActivePoolData::IsActiveObject<Creature>(uint32 db_guid) const
|
TC_GAME_API bool SpawnedPoolData::IsSpawnedObject<Creature>(uint32 db_guid) const
|
||||||
{
|
{
|
||||||
return mSpawnedCreatures.find(db_guid) != mSpawnedCreatures.end();
|
return mSpawnedCreatures.find(db_guid) != mSpawnedCreatures.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method that tell if a gameobject is spawned currently
|
// Method that tell if a gameobject is spawned currently
|
||||||
template<>
|
template<>
|
||||||
TC_GAME_API bool ActivePoolData::IsActiveObject<GameObject>(uint32 db_guid) const
|
TC_GAME_API bool SpawnedPoolData::IsSpawnedObject<GameObject>(uint32 db_guid) const
|
||||||
{
|
{
|
||||||
return mSpawnedGameobjects.find(db_guid) != mSpawnedGameobjects.end();
|
return mSpawnedGameobjects.find(db_guid) != mSpawnedGameobjects.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method that tell if a pool is spawned currently
|
// Method that tell if a pool is spawned currently
|
||||||
template<>
|
template<>
|
||||||
TC_GAME_API bool ActivePoolData::IsActiveObject<Pool>(uint32 sub_pool_id) const
|
TC_GAME_API bool SpawnedPoolData::IsSpawnedObject<Pool>(uint32 sub_pool_id) const
|
||||||
{
|
{
|
||||||
return mSpawnedPools.find(sub_pool_id) != mSpawnedPools.end();
|
return mSpawnedPools.find(sub_pool_id) != mSpawnedPools.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SpawnedPoolData::IsSpawnedObject(SpawnObjectType type, uint32 db_guid_or_pool_id) const
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case SPAWN_TYPE_CREATURE:
|
||||||
|
return IsSpawnedObject<Creature>(db_guid_or_pool_id);
|
||||||
|
case SPAWN_TYPE_GAMEOBJECT:
|
||||||
|
return IsSpawnedObject<GameObject>(db_guid_or_pool_id);
|
||||||
|
default:
|
||||||
|
ASSERT(false, "Invalid spawn type %u passed to SpawnedPoolData::IsSpawnedObject (with spawnId %u)", uint32(type), db_guid_or_pool_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void ActivePoolData::ActivateObject<Creature>(uint32 db_guid, uint32 pool_id)
|
void SpawnedPoolData::AddSpawn<Creature>(uint32 db_guid, uint32 pool_id)
|
||||||
{
|
{
|
||||||
mSpawnedCreatures.insert(db_guid);
|
mSpawnedCreatures.insert(db_guid);
|
||||||
++mSpawnedPools[pool_id];
|
++mSpawnedPools[pool_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void ActivePoolData::ActivateObject<GameObject>(uint32 db_guid, uint32 pool_id)
|
void SpawnedPoolData::AddSpawn<GameObject>(uint32 db_guid, uint32 pool_id)
|
||||||
{
|
{
|
||||||
mSpawnedGameobjects.insert(db_guid);
|
mSpawnedGameobjects.insert(db_guid);
|
||||||
++mSpawnedPools[pool_id];
|
++mSpawnedPools[pool_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void ActivePoolData::ActivateObject<Pool>(uint32 sub_pool_id, uint32 pool_id)
|
void SpawnedPoolData::AddSpawn<Pool>(uint32 sub_pool_id, uint32 pool_id)
|
||||||
{
|
{
|
||||||
mSpawnedPools[sub_pool_id] = 0;
|
mSpawnedPools[sub_pool_id] = 0;
|
||||||
++mSpawnedPools[pool_id];
|
++mSpawnedPools[pool_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void ActivePoolData::RemoveObject<Creature>(uint32 db_guid, uint32 pool_id)
|
void SpawnedPoolData::RemoveSpawn<Creature>(uint32 db_guid, uint32 pool_id)
|
||||||
{
|
{
|
||||||
mSpawnedCreatures.erase(db_guid);
|
mSpawnedCreatures.erase(db_guid);
|
||||||
uint32& val = mSpawnedPools[pool_id];
|
uint32& val = mSpawnedPools[pool_id];
|
||||||
@@ -90,7 +103,7 @@ void ActivePoolData::RemoveObject<Creature>(uint32 db_guid, uint32 pool_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void ActivePoolData::RemoveObject<GameObject>(uint32 db_guid, uint32 pool_id)
|
void SpawnedPoolData::RemoveSpawn<GameObject>(uint32 db_guid, uint32 pool_id)
|
||||||
{
|
{
|
||||||
mSpawnedGameobjects.erase(db_guid);
|
mSpawnedGameobjects.erase(db_guid);
|
||||||
uint32& val = mSpawnedPools[pool_id];
|
uint32& val = mSpawnedPools[pool_id];
|
||||||
@@ -99,7 +112,7 @@ void ActivePoolData::RemoveObject<GameObject>(uint32 db_guid, uint32 pool_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void ActivePoolData::RemoveObject<Pool>(uint32 sub_pool_id, uint32 pool_id)
|
void SpawnedPoolData::RemoveSpawn<Pool>(uint32 sub_pool_id, uint32 pool_id)
|
||||||
{
|
{
|
||||||
mSpawnedPools.erase(sub_pool_id);
|
mSpawnedPools.erase(sub_pool_id);
|
||||||
uint32& val = mSpawnedPools[pool_id];
|
uint32& val = mSpawnedPools[pool_id];
|
||||||
@@ -118,6 +131,26 @@ PoolGroup<T>::PoolGroup() : poolId(0)
|
|||||||
template <class T>
|
template <class T>
|
||||||
PoolGroup<T>::~PoolGroup() = default;
|
PoolGroup<T>::~PoolGroup() = default;
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
bool PoolGroup<T>::isEmptyDeepCheck() const
|
||||||
|
{
|
||||||
|
return isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
bool PoolGroup<Pool>::isEmptyDeepCheck() const
|
||||||
|
{
|
||||||
|
for (PoolObject const& explicitlyChanced : ExplicitlyChanced)
|
||||||
|
if (!sPoolMgr->IsEmpty(explicitlyChanced.guid))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (PoolObject const& equalChanced : EqualChanced)
|
||||||
|
if (!sPoolMgr->IsEmpty(equalChanced.guid))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Method to add a gameobject/creature guid to the proper list depending on pool type and chance value
|
// Method to add a gameobject/creature guid to the proper list depending on pool type and chance value
|
||||||
template <class T>
|
template <class T>
|
||||||
void PoolGroup<T>::AddEntry(PoolObject& poolitem, uint32 maxentries)
|
void PoolGroup<T>::AddEntry(PoolObject& poolitem, uint32 maxentries)
|
||||||
@@ -147,99 +180,83 @@ bool PoolGroup<T>::CheckPool() const
|
|||||||
// If no guid is passed, the pool is just removed (event end case)
|
// 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
|
// If guid is filled, cache will be used and no removal will occur, it just fill the cache
|
||||||
template<class T>
|
template<class T>
|
||||||
void PoolGroup<T>::DespawnObject(ActivePoolData& spawns, ObjectGuid::LowType guid, bool alwaysDeleteRespawnTime)
|
void PoolGroup<T>::DespawnObject(SpawnedPoolData& spawns, ObjectGuid::LowType guid, bool alwaysDeleteRespawnTime)
|
||||||
{
|
{
|
||||||
for (size_t i=0; i < EqualChanced.size(); ++i)
|
for (size_t i=0; i < EqualChanced.size(); ++i)
|
||||||
{
|
{
|
||||||
// if spawned
|
// if spawned
|
||||||
if (spawns.IsActiveObject<T>(EqualChanced[i].guid))
|
if (spawns.IsSpawnedObject<T>(EqualChanced[i].guid))
|
||||||
{
|
{
|
||||||
if (!guid || EqualChanced[i].guid == guid)
|
if (!guid || EqualChanced[i].guid == guid)
|
||||||
{
|
{
|
||||||
Despawn1Object(EqualChanced[i].guid, alwaysDeleteRespawnTime);
|
Despawn1Object(spawns, EqualChanced[i].guid, alwaysDeleteRespawnTime);
|
||||||
spawns.RemoveObject<T>(EqualChanced[i].guid, poolId);
|
spawns.RemoveSpawn<T>(EqualChanced[i].guid, poolId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (alwaysDeleteRespawnTime)
|
else if (alwaysDeleteRespawnTime)
|
||||||
RemoveRespawnTimeFromDB(EqualChanced[i].guid);
|
RemoveRespawnTimeFromDB(spawns, EqualChanced[i].guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < ExplicitlyChanced.size(); ++i)
|
for (size_t i = 0; i < ExplicitlyChanced.size(); ++i)
|
||||||
{
|
{
|
||||||
// spawned
|
// spawned
|
||||||
if (spawns.IsActiveObject<T>(ExplicitlyChanced[i].guid))
|
if (spawns.IsSpawnedObject<T>(ExplicitlyChanced[i].guid))
|
||||||
{
|
{
|
||||||
if (!guid || ExplicitlyChanced[i].guid == guid)
|
if (!guid || ExplicitlyChanced[i].guid == guid)
|
||||||
{
|
{
|
||||||
Despawn1Object(ExplicitlyChanced[i].guid, alwaysDeleteRespawnTime);
|
Despawn1Object(spawns, ExplicitlyChanced[i].guid, alwaysDeleteRespawnTime);
|
||||||
spawns.RemoveObject<T>(ExplicitlyChanced[i].guid, poolId);
|
spawns.RemoveSpawn<T>(ExplicitlyChanced[i].guid, poolId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (alwaysDeleteRespawnTime)
|
else if (alwaysDeleteRespawnTime)
|
||||||
RemoveRespawnTimeFromDB(ExplicitlyChanced[i].guid);
|
RemoveRespawnTimeFromDB(spawns, ExplicitlyChanced[i].guid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method that is actualy doing the removal job on one creature
|
// Method that is actualy doing the removal job on one creature
|
||||||
template<>
|
template<>
|
||||||
void PoolGroup<Creature>::Despawn1Object(ObjectGuid::LowType guid, bool alwaysDeleteRespawnTime, bool saveRespawnTime)
|
void PoolGroup<Creature>::Despawn1Object(SpawnedPoolData& spawns, ObjectGuid::LowType guid, bool alwaysDeleteRespawnTime, bool saveRespawnTime)
|
||||||
{
|
{
|
||||||
if (CreatureData const* data = sObjectMgr->GetCreatureData(guid))
|
auto creatureBounds = spawns.GetMap()->GetCreatureBySpawnIdStore().equal_range(guid);
|
||||||
|
for (auto itr = creatureBounds.first; itr != creatureBounds.second;)
|
||||||
{
|
{
|
||||||
sObjectMgr->RemoveCreatureFromGrid(guid, data);
|
Creature* creature = itr->second;
|
||||||
|
++itr;
|
||||||
Map* map = sMapMgr->FindMap(data->mapId, 0);
|
// For dynamic spawns, save respawn time here
|
||||||
if (map && !map->Instanceable())
|
if (saveRespawnTime && !creature->GetRespawnCompatibilityMode())
|
||||||
{
|
creature->SaveRespawnTime();
|
||||||
auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(guid);
|
creature->AddObjectToRemoveList();
|
||||||
for (auto itr = creatureBounds.first; itr != creatureBounds.second; )
|
|
||||||
{
|
|
||||||
Creature* creature = itr->second;
|
|
||||||
++itr;
|
|
||||||
// For dynamic spawns, save respawn time here
|
|
||||||
if (saveRespawnTime && !creature->GetRespawnCompatibilityMode())
|
|
||||||
creature->SaveRespawnTime();
|
|
||||||
creature->AddObjectToRemoveList();
|
|
||||||
}
|
|
||||||
if (alwaysDeleteRespawnTime)
|
|
||||||
map->RemoveRespawnTime(SpawnObjectType::SPAWN_TYPE_CREATURE, guid, nullptr, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (alwaysDeleteRespawnTime)
|
||||||
|
spawns.GetMap()->RemoveRespawnTime(SPAWN_TYPE_CREATURE, guid, nullptr, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same on one gameobject
|
// Same on one gameobject
|
||||||
template<>
|
template<>
|
||||||
void PoolGroup<GameObject>::Despawn1Object(ObjectGuid::LowType guid, bool alwaysDeleteRespawnTime, bool saveRespawnTime)
|
void PoolGroup<GameObject>::Despawn1Object(SpawnedPoolData& spawns, ObjectGuid::LowType guid, bool alwaysDeleteRespawnTime, bool saveRespawnTime)
|
||||||
{
|
{
|
||||||
if (GameObjectData const* data = sObjectMgr->GetGameObjectData(guid))
|
auto gameobjectBounds = spawns.GetMap()->GetGameObjectBySpawnIdStore().equal_range(guid);
|
||||||
|
for (auto itr = gameobjectBounds.first; itr != gameobjectBounds.second;)
|
||||||
{
|
{
|
||||||
sObjectMgr->RemoveGameobjectFromGrid(guid, data);
|
GameObject* go = itr->second;
|
||||||
|
++itr;
|
||||||
|
|
||||||
Map* map = sMapMgr->FindMap(data->mapId, 0);
|
// For dynamic spawns, save respawn time here
|
||||||
if (map && !map->Instanceable())
|
if (saveRespawnTime && !go->GetRespawnCompatibilityMode())
|
||||||
{
|
go->SaveRespawnTime();
|
||||||
auto gameObjectBounds = map->GetGameObjectBySpawnIdStore().equal_range(guid);
|
go->AddObjectToRemoveList();
|
||||||
for (auto itr = gameObjectBounds.first; itr != gameObjectBounds.second; )
|
|
||||||
{
|
|
||||||
GameObject* go = itr->second;
|
|
||||||
++itr;
|
|
||||||
|
|
||||||
// For dynamic spawns, save respawn time here
|
|
||||||
if (saveRespawnTime && !go->GetRespawnCompatibilityMode())
|
|
||||||
go->SaveRespawnTime();
|
|
||||||
go->AddObjectToRemoveList();
|
|
||||||
}
|
|
||||||
if (alwaysDeleteRespawnTime)
|
|
||||||
map->RemoveRespawnTime(SpawnObjectType::SPAWN_TYPE_GAMEOBJECT, guid, nullptr, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (alwaysDeleteRespawnTime)
|
||||||
|
spawns.GetMap()->RemoveRespawnTime(SPAWN_TYPE_GAMEOBJECT, guid, nullptr, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same on one pool
|
// Same on one pool
|
||||||
template<>
|
template<>
|
||||||
void PoolGroup<Pool>::Despawn1Object(uint32 child_pool_id, bool alwaysDeleteRespawnTime, bool /*saveRespawnTime*/)
|
void PoolGroup<Pool>::Despawn1Object(SpawnedPoolData& spawns, uint32 child_pool_id, bool alwaysDeleteRespawnTime, bool /*saveRespawnTime*/)
|
||||||
{
|
{
|
||||||
sPoolMgr->DespawnPool(child_pool_id, alwaysDeleteRespawnTime);
|
sPoolMgr->DespawnPool(spawns, child_pool_id, alwaysDeleteRespawnTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method for a pool only to remove any found record causing a circular dependency loop
|
// Method for a pool only to remove any found record causing a circular dependency loop
|
||||||
@@ -265,9 +282,9 @@ void PoolGroup<Pool>::RemoveOneRelation(uint32 child_pool_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void PoolGroup<T>::SpawnObject(ActivePoolData& spawns, uint32 limit, uint32 triggerFrom)
|
void PoolGroup<T>::SpawnObject(SpawnedPoolData& spawns, uint32 limit, uint32 triggerFrom)
|
||||||
{
|
{
|
||||||
int count = limit - spawns.GetActiveObjectCount(poolId);
|
int count = limit - spawns.GetSpawnedObjects(poolId);
|
||||||
|
|
||||||
// If triggered from some object respawn this object is still marked as spawned
|
// If triggered from some object respawn this object is still marked as spawned
|
||||||
// and also counted into m_SpawnedPoolAmount so we need increase count to be
|
// and also counted into m_SpawnedPoolAmount so we need increase count to be
|
||||||
@@ -290,7 +307,7 @@ void PoolGroup<T>::SpawnObject(ActivePoolData& spawns, uint32 limit, uint32 trig
|
|||||||
roll -= obj.chance;
|
roll -= obj.chance;
|
||||||
// Triggering object is marked as spawned at this time and can be also rolled (respawn case)
|
// Triggering object is marked as spawned at this time and can be also rolled (respawn case)
|
||||||
// so this need explicit check for this case
|
// so this need explicit check for this case
|
||||||
if (roll < 0 && (obj.guid == triggerFrom || !spawns.IsActiveObject<T>(obj.guid)))
|
if (roll < 0 && (obj.guid == triggerFrom || !spawns.IsSpawnedObject<T>(obj.guid)))
|
||||||
{
|
{
|
||||||
rolledObjects.push_back(obj);
|
rolledObjects.push_back(obj);
|
||||||
break;
|
break;
|
||||||
@@ -302,7 +319,7 @@ void PoolGroup<T>::SpawnObject(ActivePoolData& spawns, uint32 limit, uint32 trig
|
|||||||
{
|
{
|
||||||
std::copy_if(EqualChanced.begin(), EqualChanced.end(), std::back_inserter(rolledObjects), [triggerFrom, &spawns](PoolObject const& object)
|
std::copy_if(EqualChanced.begin(), EqualChanced.end(), std::back_inserter(rolledObjects), [triggerFrom, &spawns](PoolObject const& object)
|
||||||
{
|
{
|
||||||
return object.guid == triggerFrom || !spawns.IsActiveObject<T>(object.guid);
|
return object.guid == triggerFrom || !spawns.IsSpawnedObject<T>(object.guid);
|
||||||
});
|
});
|
||||||
|
|
||||||
Trinity::Containers::RandomResize(rolledObjects, count);
|
Trinity::Containers::RandomResize(rolledObjects, count);
|
||||||
@@ -313,13 +330,13 @@ void PoolGroup<T>::SpawnObject(ActivePoolData& spawns, uint32 limit, uint32 trig
|
|||||||
{
|
{
|
||||||
if (obj.guid == triggerFrom)
|
if (obj.guid == triggerFrom)
|
||||||
{
|
{
|
||||||
ReSpawn1Object(&obj);
|
ReSpawn1Object(spawns, &obj);
|
||||||
triggerFrom = 0;
|
triggerFrom = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
spawns.ActivateObject<T>(obj.guid, poolId);
|
spawns.AddSpawn<T>(obj.guid, poolId);
|
||||||
Spawn1Object(&obj);
|
Spawn1Object(spawns, &obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -330,20 +347,17 @@ void PoolGroup<T>::SpawnObject(ActivePoolData& spawns, uint32 limit, uint32 trig
|
|||||||
|
|
||||||
// Method that is actualy doing the spawn job on 1 creature
|
// Method that is actualy doing the spawn job on 1 creature
|
||||||
template <>
|
template <>
|
||||||
void PoolGroup<Creature>::Spawn1Object(PoolObject* obj)
|
void PoolGroup<Creature>::Spawn1Object(SpawnedPoolData& spawns, PoolObject* obj)
|
||||||
{
|
{
|
||||||
if (CreatureData const* data = sObjectMgr->GetCreatureData(obj->guid))
|
if (CreatureData const* data = sObjectMgr->GetCreatureData(obj->guid))
|
||||||
{
|
{
|
||||||
sObjectMgr->AddCreatureToGrid(obj->guid, data);
|
|
||||||
|
|
||||||
// Spawn if necessary (loaded grids only)
|
// Spawn if necessary (loaded grids only)
|
||||||
Map* map = sMapMgr->FindMap(data->mapId, 0);
|
|
||||||
// We use spawn coords to spawn
|
// We use spawn coords to spawn
|
||||||
if (map && !map->Instanceable() && map->IsGridLoaded(data->spawnPoint))
|
if (spawns.GetMap()->IsGridLoaded(data->spawnPoint))
|
||||||
{
|
{
|
||||||
Creature* creature = new Creature();
|
Creature* creature = new Creature();
|
||||||
//TC_LOG_DEBUG("pool", "Spawning creature %u", guid);
|
//TC_LOG_DEBUG("pool", "Spawning creature %u", guid);
|
||||||
if (!creature->LoadFromDB(obj->guid, map, true, false))
|
if (!creature->LoadFromDB(obj->guid, spawns.GetMap(), true, false))
|
||||||
{
|
{
|
||||||
delete creature;
|
delete creature;
|
||||||
return;
|
return;
|
||||||
@@ -354,28 +368,26 @@ void PoolGroup<Creature>::Spawn1Object(PoolObject* obj)
|
|||||||
|
|
||||||
// Same for 1 gameobject
|
// Same for 1 gameobject
|
||||||
template <>
|
template <>
|
||||||
void PoolGroup<GameObject>::Spawn1Object(PoolObject* obj)
|
void PoolGroup<GameObject>::Spawn1Object(SpawnedPoolData& spawns, PoolObject* obj)
|
||||||
{
|
{
|
||||||
if (GameObjectData const* data = sObjectMgr->GetGameObjectData(obj->guid))
|
if (GameObjectData const* data = sObjectMgr->GetGameObjectData(obj->guid))
|
||||||
{
|
{
|
||||||
sObjectMgr->AddGameobjectToGrid(obj->guid, data);
|
|
||||||
// Spawn if necessary (loaded grids only)
|
// Spawn if necessary (loaded grids only)
|
||||||
// this base map checked as non-instanced and then only existed
|
|
||||||
Map* map = sMapMgr->FindMap(data->mapId, 0);
|
|
||||||
// We use current coords to unspawn, not spawn coords since creature can have changed grid
|
// We use current coords to unspawn, not spawn coords since creature can have changed grid
|
||||||
if (map && !map->Instanceable() && map->IsGridLoaded(data->spawnPoint))
|
if (spawns.GetMap()->IsGridLoaded(data->spawnPoint))
|
||||||
{
|
{
|
||||||
GameObject* pGameobject = new GameObject;
|
GameObject* go = new GameObject;
|
||||||
//TC_LOG_DEBUG("pool", "Spawning gameobject %u", guid);
|
//TC_LOG_DEBUG("pool", "Spawning gameobject %u", guid);
|
||||||
if (!pGameobject->LoadFromDB(obj->guid, map, false))
|
if (!go->LoadFromDB(obj->guid, spawns.GetMap(), false))
|
||||||
{
|
{
|
||||||
delete pGameobject;
|
delete go;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (pGameobject->isSpawnedByDefault())
|
if (go->isSpawnedByDefault())
|
||||||
map->AddToMap(pGameobject);
|
if (!spawns.GetMap()->AddToMap(go))
|
||||||
|
delete go;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -383,59 +395,45 @@ void PoolGroup<GameObject>::Spawn1Object(PoolObject* obj)
|
|||||||
|
|
||||||
// Same for 1 pool
|
// Same for 1 pool
|
||||||
template <>
|
template <>
|
||||||
void PoolGroup<Pool>::Spawn1Object(PoolObject* obj)
|
void PoolGroup<Pool>::Spawn1Object(SpawnedPoolData& spawns, PoolObject* obj)
|
||||||
{
|
{
|
||||||
sPoolMgr->SpawnPool(obj->guid);
|
sPoolMgr->SpawnPool(spawns, obj->guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method that does the respawn job on the specified creature
|
// Method that does the respawn job on the specified creature
|
||||||
template <>
|
template <>
|
||||||
void PoolGroup<Creature>::ReSpawn1Object(PoolObject* obj)
|
void PoolGroup<Creature>::ReSpawn1Object(SpawnedPoolData& spawns, PoolObject* obj)
|
||||||
{
|
{
|
||||||
Despawn1Object(obj->guid, false, false);
|
Despawn1Object(spawns, obj->guid, false, false);
|
||||||
Spawn1Object(obj);
|
Spawn1Object(spawns, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method that does the respawn job on the specified gameobject
|
// Method that does the respawn job on the specified gameobject
|
||||||
template <>
|
template <>
|
||||||
void PoolGroup<GameObject>::ReSpawn1Object(PoolObject* obj)
|
void PoolGroup<GameObject>::ReSpawn1Object(SpawnedPoolData& spawns, PoolObject* obj)
|
||||||
{
|
{
|
||||||
Despawn1Object(obj->guid, false, false);
|
Despawn1Object(spawns, obj->guid, false, false);
|
||||||
Spawn1Object(obj);
|
Spawn1Object(spawns, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing to do for a child Pool
|
// Nothing to do for a child Pool
|
||||||
template <>
|
template <>
|
||||||
void PoolGroup<Pool>::ReSpawn1Object(PoolObject* /*obj*/) { }
|
void PoolGroup<Pool>::ReSpawn1Object(SpawnedPoolData& /*spawns*/, PoolObject* /*obj*/) { }
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void PoolGroup<Creature>::RemoveRespawnTimeFromDB(ObjectGuid::LowType guid)
|
void PoolGroup<Creature>::RemoveRespawnTimeFromDB(SpawnedPoolData& spawns, ObjectGuid::LowType guid)
|
||||||
{
|
{
|
||||||
if (CreatureData const* data = sObjectMgr->GetCreatureData(guid))
|
spawns.GetMap()->RemoveRespawnTime(SPAWN_TYPE_CREATURE, guid, nullptr, true);
|
||||||
{
|
|
||||||
Map* map = sMapMgr->CreateBaseMap(data->mapId);
|
|
||||||
if (!map->Instanceable())
|
|
||||||
{
|
|
||||||
map->RemoveRespawnTime(SPAWN_TYPE_CREATURE, guid, nullptr, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void PoolGroup<GameObject>::RemoveRespawnTimeFromDB(ObjectGuid::LowType guid)
|
void PoolGroup<GameObject>::RemoveRespawnTimeFromDB(SpawnedPoolData& spawns, ObjectGuid::LowType guid)
|
||||||
{
|
{
|
||||||
if (GameObjectData const* data = sObjectMgr->GetGameObjectData(guid))
|
spawns.GetMap()->RemoveRespawnTime(SPAWN_TYPE_GAMEOBJECT, guid, nullptr, true);
|
||||||
{
|
|
||||||
Map* map = sMapMgr->CreateBaseMap(data->mapId);
|
|
||||||
if (!map->Instanceable())
|
|
||||||
{
|
|
||||||
map->RemoveRespawnTime(SPAWN_TYPE_GAMEOBJECT, guid, nullptr, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void PoolGroup<Pool>::RemoveRespawnTimeFromDB(ObjectGuid::LowType /*guid*/) { }
|
void PoolGroup<Pool>::RemoveRespawnTimeFromDB(SpawnedPoolData& /*spawns*/, ObjectGuid::LowType /*guid*/) { }
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Methods of class PoolMgr
|
// Methods of class PoolMgr
|
||||||
@@ -478,6 +476,7 @@ void PoolMgr::LoadFromDB()
|
|||||||
|
|
||||||
PoolTemplateData& pPoolTemplate = mPoolTemplate[pool_id];
|
PoolTemplateData& pPoolTemplate = mPoolTemplate[pool_id];
|
||||||
pPoolTemplate.MaxLimit = fields[1].GetUInt32();
|
pPoolTemplate.MaxLimit = fields[1].GetUInt32();
|
||||||
|
pPoolTemplate.MapId = -1;
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
@@ -528,6 +527,15 @@ void PoolMgr::LoadFromDB()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
PoolTemplateData* pPoolTemplate = &mPoolTemplate[pool_id];
|
PoolTemplateData* pPoolTemplate = &mPoolTemplate[pool_id];
|
||||||
|
if (pPoolTemplate->MapId == -1)
|
||||||
|
pPoolTemplate->MapId = int32(data->mapId);
|
||||||
|
|
||||||
|
if (pPoolTemplate->MapId != int32(data->mapId))
|
||||||
|
{
|
||||||
|
TC_LOG_ERROR("sql.sql", "`pool_creature` has creature spawns on multiple different maps for creature guid %u in pool id (%u), skipped.", guid, pool_id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
PoolObject plObject = PoolObject(guid, chance);
|
PoolObject plObject = PoolObject(guid, chance);
|
||||||
PoolGroup<Creature>& cregroup = mPoolCreatureGroups[pool_id];
|
PoolGroup<Creature>& cregroup = mPoolCreatureGroups[pool_id];
|
||||||
cregroup.SetPoolId(pool_id);
|
cregroup.SetPoolId(pool_id);
|
||||||
@@ -597,6 +605,15 @@ void PoolMgr::LoadFromDB()
|
|||||||
}
|
}
|
||||||
|
|
||||||
PoolTemplateData* pPoolTemplate = &mPoolTemplate[pool_id];
|
PoolTemplateData* pPoolTemplate = &mPoolTemplate[pool_id];
|
||||||
|
if (pPoolTemplate->MapId == -1)
|
||||||
|
pPoolTemplate->MapId = int32(data->mapId);
|
||||||
|
|
||||||
|
if (pPoolTemplate->MapId != int32(data->mapId))
|
||||||
|
{
|
||||||
|
TC_LOG_ERROR("sql.sql", "`pool_gameobject` has gameobject spawns on multiple different maps for gameobject guid (%u) in pool id (%u), skipped.", guid, pool_id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
PoolObject plObject = PoolObject(guid, chance);
|
PoolObject plObject = PoolObject(guid, chance);
|
||||||
PoolGroup<GameObject>& gogroup = mPoolGameobjectGroups[pool_id];
|
PoolGroup<GameObject>& gogroup = mPoolGameobjectGroups[pool_id];
|
||||||
gogroup.SetPoolId(pool_id);
|
gogroup.SetPoolId(pool_id);
|
||||||
@@ -681,6 +698,21 @@ void PoolMgr::LoadFromDB()
|
|||||||
std::set<uint32> checkedPools;
|
std::set<uint32> checkedPools;
|
||||||
for (SearchMap::iterator poolItr = mPoolSearchMap.find(it.first); poolItr != mPoolSearchMap.end(); poolItr = mPoolSearchMap.find(poolItr->second))
|
for (SearchMap::iterator poolItr = mPoolSearchMap.find(it.first); poolItr != mPoolSearchMap.end(); poolItr = mPoolSearchMap.find(poolItr->second))
|
||||||
{
|
{
|
||||||
|
if (mPoolTemplate[poolItr->first].MapId != -1)
|
||||||
|
{
|
||||||
|
if (mPoolTemplate[poolItr->second].MapId == -1)
|
||||||
|
mPoolTemplate[poolItr->second].MapId = mPoolTemplate[poolItr->first].MapId;
|
||||||
|
|
||||||
|
if (mPoolTemplate[poolItr->second].MapId != mPoolTemplate[poolItr->first].MapId)
|
||||||
|
{
|
||||||
|
TC_LOG_ERROR("sql.sql", "`pool_pool` has child pools on multiple maps in pool id (%u), skipped.", poolItr->second);
|
||||||
|
mPoolPoolGroups[poolItr->second].RemoveOneRelation(poolItr->first);
|
||||||
|
mPoolSearchMap.erase(poolItr);
|
||||||
|
--count;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
checkedPools.insert(poolItr->first);
|
checkedPools.insert(poolItr->first);
|
||||||
if (checkedPools.find(poolItr->second) != checkedPools.end())
|
if (checkedPools.find(poolItr->second) != checkedPools.end())
|
||||||
{
|
{
|
||||||
@@ -703,6 +735,16 @@ void PoolMgr::LoadFromDB()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto const& [poolId, templateData] : mPoolTemplate)
|
||||||
|
{
|
||||||
|
if (IsEmpty(poolId))
|
||||||
|
{
|
||||||
|
TC_LOG_ERROR("sql.sql", "Pool Id %u is empty (has no creatures and no gameobects and either no child pools or child pools are all empty. The pool will not be spawned", poolId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ASSERT(templateData.MapId != -1);
|
||||||
|
}
|
||||||
|
|
||||||
// The initialize method will spawn all pools not in an event and not in another pool, this is why there is 2 left joins with 2 null checks
|
// The initialize method will spawn all pools not in an event and not in another pool, this is why there is 2 left joins with 2 null checks
|
||||||
TC_LOG_INFO("server.loading", "Starting objects pooling system...");
|
TC_LOG_INFO("server.loading", "Starting objects pooling system...");
|
||||||
{
|
{
|
||||||
@@ -725,6 +767,9 @@ void PoolMgr::LoadFromDB()
|
|||||||
uint32 pool_entry = fields[0].GetUInt32();
|
uint32 pool_entry = fields[0].GetUInt32();
|
||||||
uint32 pool_pool_id = fields[1].GetUInt32();
|
uint32 pool_pool_id = fields[1].GetUInt32();
|
||||||
|
|
||||||
|
if (IsEmpty(pool_entry))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!CheckPool(pool_entry))
|
if (!CheckPool(pool_entry))
|
||||||
{
|
{
|
||||||
if (pool_pool_id)
|
if (pool_pool_id)
|
||||||
@@ -739,14 +784,13 @@ void PoolMgr::LoadFromDB()
|
|||||||
// Don't spawn child pools, they are spawned recursively by their parent pools
|
// Don't spawn child pools, they are spawned recursively by their parent pools
|
||||||
if (!pool_pool_id)
|
if (!pool_pool_id)
|
||||||
{
|
{
|
||||||
SpawnPool(pool_entry);
|
mAutoSpawnPoolsPerMap[mPoolTemplate[pool_entry].MapId].push_back(pool_entry);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (result->NextRow());
|
while (result->NextRow());
|
||||||
|
|
||||||
TC_LOG_DEBUG("pool", "Pool handling system initialized, %u pools spawned in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
TC_LOG_DEBUG("pool", "Pool handling system initialized, %u pools will be spawned by default in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -754,57 +798,57 @@ void PoolMgr::LoadFromDB()
|
|||||||
// Call to spawn a pool, if cache if true the method will spawn only if cached entry is different
|
// Call to spawn a pool, if cache if true the method will spawn only if cached entry is different
|
||||||
// If it's same, the creature is respawned only (added back to map)
|
// If it's same, the creature is respawned only (added back to map)
|
||||||
template<>
|
template<>
|
||||||
void PoolMgr::SpawnPool<Creature>(uint32 pool_id, uint32 db_guid)
|
void PoolMgr::SpawnPool<Creature>(SpawnedPoolData& spawnedPoolData, uint32 pool_id, uint32 db_guid)
|
||||||
{
|
{
|
||||||
auto it = mPoolCreatureGroups.find(pool_id);
|
auto it = mPoolCreatureGroups.find(pool_id);
|
||||||
if (it != mPoolCreatureGroups.end() && !it->second.isEmpty())
|
if (it != mPoolCreatureGroups.end() && !it->second.isEmpty())
|
||||||
it->second.SpawnObject(mSpawnedData, mPoolTemplate[pool_id].MaxLimit, db_guid);
|
it->second.SpawnObject(spawnedPoolData, mPoolTemplate[pool_id].MaxLimit, db_guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call to spawn a pool, if cache if true the method will spawn only if cached entry is different
|
// Call to spawn a pool, if cache if true the method will spawn only if cached entry is different
|
||||||
// If it's same, the gameobject is respawned only (added back to map)
|
// If it's same, the gameobject is respawned only (added back to map)
|
||||||
template<>
|
template<>
|
||||||
void PoolMgr::SpawnPool<GameObject>(uint32 pool_id, uint32 db_guid)
|
void PoolMgr::SpawnPool<GameObject>(SpawnedPoolData& spawnedPoolData, uint32 pool_id, uint32 db_guid)
|
||||||
{
|
{
|
||||||
auto it = mPoolGameobjectGroups.find(pool_id);
|
auto it = mPoolGameobjectGroups.find(pool_id);
|
||||||
if (it != mPoolGameobjectGroups.end() && !it->second.isEmpty())
|
if (it != mPoolGameobjectGroups.end() && !it->second.isEmpty())
|
||||||
it->second.SpawnObject(mSpawnedData, mPoolTemplate[pool_id].MaxLimit, db_guid);
|
it->second.SpawnObject(spawnedPoolData, mPoolTemplate[pool_id].MaxLimit, db_guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call to spawn a pool, if cache if true the method will spawn only if cached entry is different
|
// Call to spawn a pool, if cache if true the method will spawn only if cached entry is different
|
||||||
// If it's same, the pool is respawned only
|
// If it's same, the pool is respawned only
|
||||||
template<>
|
template<>
|
||||||
void PoolMgr::SpawnPool<Pool>(uint32 pool_id, uint32 sub_pool_id)
|
void PoolMgr::SpawnPool<Pool>(SpawnedPoolData& spawnedPoolData, uint32 pool_id, uint32 sub_pool_id)
|
||||||
{
|
{
|
||||||
auto it = mPoolPoolGroups.find(pool_id);
|
auto it = mPoolPoolGroups.find(pool_id);
|
||||||
if (it != mPoolPoolGroups.end() && !it->second.isEmpty())
|
if (it != mPoolPoolGroups.end() && !it->second.isEmpty())
|
||||||
it->second.SpawnObject(mSpawnedData, mPoolTemplate[pool_id].MaxLimit, sub_pool_id);
|
it->second.SpawnObject(spawnedPoolData, mPoolTemplate[pool_id].MaxLimit, sub_pool_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PoolMgr::SpawnPool(uint32 pool_id)
|
void PoolMgr::SpawnPool(SpawnedPoolData& spawnedPoolData, uint32 pool_id)
|
||||||
{
|
{
|
||||||
SpawnPool<Pool>(pool_id, 0);
|
SpawnPool<Pool>(spawnedPoolData, pool_id, 0);
|
||||||
SpawnPool<GameObject>(pool_id, 0);
|
SpawnPool<GameObject>(spawnedPoolData, pool_id, 0);
|
||||||
SpawnPool<Creature>(pool_id, 0);
|
SpawnPool<Creature>(spawnedPoolData, pool_id, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call to despawn a pool, all gameobjects/creatures in this pool are removed
|
// Call to despawn a pool, all gameobjects/creatures in this pool are removed
|
||||||
void PoolMgr::DespawnPool(uint32 pool_id, bool alwaysDeleteRespawnTime)
|
void PoolMgr::DespawnPool(SpawnedPoolData& spawnedPoolData, uint32 pool_id, bool alwaysDeleteRespawnTime)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
auto it = mPoolCreatureGroups.find(pool_id);
|
auto it = mPoolCreatureGroups.find(pool_id);
|
||||||
if (it != mPoolCreatureGroups.end() && !it->second.isEmpty())
|
if (it != mPoolCreatureGroups.end() && !it->second.isEmpty())
|
||||||
it->second.DespawnObject(mSpawnedData, 0, alwaysDeleteRespawnTime);
|
it->second.DespawnObject(spawnedPoolData, 0, alwaysDeleteRespawnTime);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto it = mPoolGameobjectGroups.find(pool_id);
|
auto it = mPoolGameobjectGroups.find(pool_id);
|
||||||
if (it != mPoolGameobjectGroups.end() && !it->second.isEmpty())
|
if (it != mPoolGameobjectGroups.end() && !it->second.isEmpty())
|
||||||
it->second.DespawnObject(mSpawnedData, 0, alwaysDeleteRespawnTime);
|
it->second.DespawnObject(spawnedPoolData, 0, alwaysDeleteRespawnTime);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto it = mPoolPoolGroups.find(pool_id);
|
auto it = mPoolPoolGroups.find(pool_id);
|
||||||
if (it != mPoolPoolGroups.end() && !it->second.isEmpty())
|
if (it != mPoolPoolGroups.end() && !it->second.isEmpty())
|
||||||
it->second.DespawnObject(mSpawnedData, 0, alwaysDeleteRespawnTime);
|
it->second.DespawnObject(spawnedPoolData, 0, alwaysDeleteRespawnTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -823,6 +867,26 @@ uint32 PoolMgr::IsPartOfAPool(SpawnObjectType type, ObjectGuid::LowType spawnId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PoolMgr::IsEmpty(uint32 pool_id) const
|
||||||
|
{
|
||||||
|
{
|
||||||
|
auto it = mPoolGameobjectGroups.find(pool_id);
|
||||||
|
if (it != mPoolGameobjectGroups.end() && !it->second.isEmptyDeepCheck())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto it = mPoolCreatureGroups.find(pool_id);
|
||||||
|
if (it != mPoolCreatureGroups.end() && !it->second.isEmptyDeepCheck())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto it = mPoolPoolGroups.find(pool_id);
|
||||||
|
if (it != mPoolPoolGroups.end() && !it->second.isEmptyDeepCheck())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Method that check chance integrity of the creatures and gameobjects in this pool
|
// Method that check chance integrity of the creatures and gameobjects in this pool
|
||||||
bool PoolMgr::CheckPool(uint32 pool_id) const
|
bool PoolMgr::CheckPool(uint32 pool_id) const
|
||||||
{
|
{
|
||||||
@@ -848,29 +912,44 @@ bool PoolMgr::CheckPool(uint32 pool_id) const
|
|||||||
// Here we cache only the creature/gameobject whose guid is passed as parameter
|
// Here we cache only the creature/gameobject whose guid is passed as parameter
|
||||||
// Then the spawn pool call will use this cache to decide
|
// Then the spawn pool call will use this cache to decide
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void PoolMgr::UpdatePool(uint32 pool_id, uint32 db_guid_or_pool_id)
|
void PoolMgr::UpdatePool(SpawnedPoolData& spawnedPoolData, uint32 pool_id, uint32 db_guid_or_pool_id)
|
||||||
{
|
{
|
||||||
if (uint32 motherpoolid = IsPartOfAPool<Pool>(pool_id))
|
if (uint32 motherpoolid = IsPartOfAPool<Pool>(pool_id))
|
||||||
SpawnPool<Pool>(motherpoolid, pool_id);
|
SpawnPool<Pool>(spawnedPoolData, motherpoolid, pool_id);
|
||||||
else
|
else
|
||||||
SpawnPool<T>(pool_id, db_guid_or_pool_id);
|
SpawnPool<T>(spawnedPoolData, pool_id, db_guid_or_pool_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
template void PoolMgr::UpdatePool<Pool>(uint32 pool_id, uint32 db_guid_or_pool_id);
|
template void PoolMgr::UpdatePool<Pool>(SpawnedPoolData& spawnedPoolData, uint32 pool_id, uint32 db_guid_or_pool_id);
|
||||||
template void PoolMgr::UpdatePool<GameObject>(uint32 pool_id, uint32 db_guid_or_pool_id);
|
template void PoolMgr::UpdatePool<GameObject>(SpawnedPoolData& spawnedPoolData, uint32 pool_id, uint32 db_guid_or_pool_id);
|
||||||
template void PoolMgr::UpdatePool<Creature>(uint32 pool_id, uint32 db_guid_or_pool_id);
|
template void PoolMgr::UpdatePool<Creature>(SpawnedPoolData& spawnedPoolData, uint32 pool_id, uint32 db_guid_or_pool_id);
|
||||||
|
|
||||||
void PoolMgr::UpdatePool(uint32 pool_id, SpawnObjectType type, uint32 spawnId)
|
void PoolMgr::UpdatePool(SpawnedPoolData& spawnedPoolData, uint32 pool_id, SpawnObjectType type, uint32 spawnId)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case SPAWN_TYPE_CREATURE:
|
case SPAWN_TYPE_CREATURE:
|
||||||
UpdatePool<Creature>(pool_id, spawnId);
|
UpdatePool<Creature>(spawnedPoolData, pool_id, spawnId);
|
||||||
break;
|
break;
|
||||||
case SPAWN_TYPE_GAMEOBJECT:
|
case SPAWN_TYPE_GAMEOBJECT:
|
||||||
UpdatePool<GameObject>(pool_id, spawnId);
|
UpdatePool<GameObject>(spawnedPoolData, pool_id, spawnId);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT(false, "Invalid spawn type %u passed to PoolMgr::IsPartOfPool (with spawnId %u)", uint32(type), spawnId);
|
ASSERT(false, "Invalid spawn type %u passed to PoolMgr::IsPartOfPool (with spawnId %u)", uint32(type), spawnId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<SpawnedPoolData> PoolMgr::InitPoolsForMap(Map* map)
|
||||||
|
{
|
||||||
|
std::unique_ptr<SpawnedPoolData> spawnedPoolData = std::make_unique<SpawnedPoolData>(map);
|
||||||
|
if (std::vector<uint32> const* poolIds = Trinity::Containers::MapGetValuePtr(mAutoSpawnPoolsPerMap, spawnedPoolData->GetMap()->GetId()))
|
||||||
|
for (uint32 poolId : *poolIds)
|
||||||
|
SpawnPool(*spawnedPoolData, poolId);
|
||||||
|
|
||||||
|
return spawnedPoolData;
|
||||||
|
}
|
||||||
|
|
||||||
|
PoolTemplateData const* PoolMgr::GetPoolTemplate(uint16 pool_id) const
|
||||||
|
{
|
||||||
|
return Trinity::Containers::MapGetValuePtr(mPoolTemplate, pool_id);
|
||||||
|
}
|
||||||
@@ -21,17 +21,20 @@
|
|||||||
#include "Define.h"
|
#include "Define.h"
|
||||||
#include "SpawnData.h"
|
#include "SpawnData.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class Creature;
|
class Creature;
|
||||||
class GameObject;
|
class GameObject;
|
||||||
|
class Map;
|
||||||
class Quest;
|
class Quest;
|
||||||
|
|
||||||
struct PoolTemplateData
|
struct PoolTemplateData
|
||||||
{
|
{
|
||||||
uint32 MaxLimit;
|
uint32 MaxLimit;
|
||||||
|
int32 MapId;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PoolObject
|
struct PoolObject
|
||||||
@@ -45,34 +48,39 @@ class Pool // for Pool of Pool
|
|||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::set<ObjectGuid::LowType> ActivePoolObjects;
|
typedef std::set<ObjectGuid::LowType> SpawnedPoolObjects;
|
||||||
typedef std::map<uint32, uint32> ActivePoolPools;
|
typedef std::map<uint32, uint32> SpawnedPoolPools;
|
||||||
|
|
||||||
class TC_GAME_API ActivePoolData
|
class TC_GAME_API SpawnedPoolData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ActivePoolData();
|
explicit SpawnedPoolData(Map* owner);
|
||||||
~ActivePoolData();
|
~SpawnedPoolData();
|
||||||
|
|
||||||
ActivePoolData(ActivePoolData const& right) = delete;
|
SpawnedPoolData(SpawnedPoolData const& right) = delete;
|
||||||
ActivePoolData(ActivePoolData&& right) = delete;
|
SpawnedPoolData(SpawnedPoolData&& right) = delete;
|
||||||
ActivePoolData& operator=(ActivePoolData const& right) = delete;
|
SpawnedPoolData& operator=(SpawnedPoolData const& right) = delete;
|
||||||
ActivePoolData& operator=(ActivePoolData&& right) = delete;
|
SpawnedPoolData& operator=(SpawnedPoolData&& right) = delete;
|
||||||
|
|
||||||
|
Map* GetMap() const { return mOwner; }
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool IsActiveObject(uint32 db_guid_or_pool_id) const;
|
bool IsSpawnedObject(uint32 db_guid_or_pool_id) const;
|
||||||
|
|
||||||
uint32 GetActiveObjectCount(uint32 pool_id) const;
|
bool IsSpawnedObject(SpawnObjectType type, uint32 db_guid_or_pool_id) const;
|
||||||
|
|
||||||
|
uint32 GetSpawnedObjects(uint32 pool_id) const;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void ActivateObject(uint32 db_guid_or_pool_id, uint32 pool_id);
|
void AddSpawn(uint32 db_guid_or_pool_id, uint32 pool_id);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void RemoveObject(uint32 db_guid_or_pool_id, uint32 pool_id);
|
void RemoveSpawn(uint32 db_guid_or_pool_id, uint32 pool_id);
|
||||||
private:
|
private:
|
||||||
ActivePoolObjects mSpawnedCreatures;
|
Map* mOwner;
|
||||||
ActivePoolObjects mSpawnedGameobjects;
|
SpawnedPoolObjects mSpawnedCreatures;
|
||||||
ActivePoolPools mSpawnedPools;
|
SpawnedPoolObjects mSpawnedGameobjects;
|
||||||
|
SpawnedPoolPools mSpawnedPools;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
@@ -90,22 +98,17 @@ class TC_GAME_API PoolGroup
|
|||||||
|
|
||||||
void SetPoolId(uint32 pool_id) { poolId = pool_id; }
|
void SetPoolId(uint32 pool_id) { poolId = pool_id; }
|
||||||
bool isEmpty() const { return ExplicitlyChanced.empty() && EqualChanced.empty(); }
|
bool isEmpty() const { return ExplicitlyChanced.empty() && EqualChanced.empty(); }
|
||||||
|
bool isEmptyDeepCheck() const;
|
||||||
void AddEntry(PoolObject& poolitem, uint32 maxentries);
|
void AddEntry(PoolObject& poolitem, uint32 maxentries);
|
||||||
bool CheckPool() const;
|
bool CheckPool() const;
|
||||||
void DespawnObject(ActivePoolData& spawns, ObjectGuid::LowType guid = 0, bool alwaysDeleteRespawnTime = false);
|
void DespawnObject(SpawnedPoolData& spawns, ObjectGuid::LowType guid = 0, bool alwaysDeleteRespawnTime = false);
|
||||||
void Despawn1Object(ObjectGuid::LowType guid, bool alwaysDeleteRespawnTime = false, bool saveRespawnTime = true);
|
void Despawn1Object(SpawnedPoolData& spawns, ObjectGuid::LowType guid, bool alwaysDeleteRespawnTime = false, bool saveRespawnTime = true);
|
||||||
void SpawnObject(ActivePoolData& spawns, uint32 limit, uint32 triggerFrom);
|
void SpawnObject(SpawnedPoolData& spawns, uint32 limit, uint32 triggerFrom);
|
||||||
void RemoveRespawnTimeFromDB(ObjectGuid::LowType guid);
|
void RemoveRespawnTimeFromDB(SpawnedPoolData& spawns, ObjectGuid::LowType guid);
|
||||||
|
|
||||||
void Spawn1Object(PoolObject* obj);
|
void Spawn1Object(SpawnedPoolData& spawns, PoolObject* obj);
|
||||||
void ReSpawn1Object(PoolObject* obj);
|
void ReSpawn1Object(SpawnedPoolData& spawns, PoolObject* obj);
|
||||||
void RemoveOneRelation(uint32 child_pool_id);
|
void RemoveOneRelation(uint32 child_pool_id);
|
||||||
uint32 GetFirstEqualChancedObjectId()
|
|
||||||
{
|
|
||||||
if (EqualChanced.empty())
|
|
||||||
return 0;
|
|
||||||
return EqualChanced.front().guid;
|
|
||||||
}
|
|
||||||
uint32 GetPoolId() const { return poolId; }
|
uint32 GetPoolId() const { return poolId; }
|
||||||
private:
|
private:
|
||||||
uint32 poolId;
|
uint32 poolId;
|
||||||
@@ -136,20 +139,25 @@ class TC_GAME_API PoolMgr
|
|||||||
uint32 IsPartOfAPool(SpawnObjectType type, ObjectGuid::LowType spawnId) const;
|
uint32 IsPartOfAPool(SpawnObjectType type, ObjectGuid::LowType spawnId) const;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool IsSpawnedObject(uint32 db_guid_or_pool_id) const { return mSpawnedData.IsActiveObject<T>(db_guid_or_pool_id); }
|
bool IsSpawnedObject(SpawnedPoolData& spawnedPoolData, uint32 db_guid_or_pool_id) const { return spawnedPoolData.IsSpawnedObject<T>(db_guid_or_pool_id); }
|
||||||
|
|
||||||
|
bool IsEmpty(uint32 pool_id) const;
|
||||||
bool CheckPool(uint32 pool_id) const;
|
bool CheckPool(uint32 pool_id) const;
|
||||||
|
|
||||||
void SpawnPool(uint32 pool_id);
|
void SpawnPool(SpawnedPoolData& spawnedPoolData, uint32 pool_id);
|
||||||
void DespawnPool(uint32 pool_id, bool alwaysDeleteRespawnTime = false);
|
void DespawnPool(SpawnedPoolData& spawnedPoolData, uint32 pool_id, bool alwaysDeleteRespawnTime = false);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void UpdatePool(uint32 pool_id, uint32 db_guid_or_pool_id);
|
void UpdatePool(SpawnedPoolData& spawnedPoolData, uint32 pool_id, uint32 db_guid_or_pool_id);
|
||||||
void UpdatePool(uint32 pool_id, SpawnObjectType type, ObjectGuid::LowType spawnId);
|
void UpdatePool(SpawnedPoolData& spawnedPoolData, uint32 pool_id, SpawnObjectType type, ObjectGuid::LowType spawnId);
|
||||||
|
|
||||||
|
std::unique_ptr<SpawnedPoolData> InitPoolsForMap(Map* map);
|
||||||
|
|
||||||
|
PoolTemplateData const* GetPoolTemplate(uint16 pool_id) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void SpawnPool(uint32 pool_id, uint32 db_guid_or_pool_id);
|
void SpawnPool(SpawnedPoolData& spawnedPoolData, uint32 pool_id, uint32 db_guid_or_pool_id);
|
||||||
|
|
||||||
typedef std::unordered_map<uint32, PoolTemplateData> PoolTemplateDataMap;
|
typedef std::unordered_map<uint32, PoolTemplateData> PoolTemplateDataMap;
|
||||||
typedef std::unordered_map<uint32, PoolGroup<Creature>> PoolGroupCreatureMap;
|
typedef std::unordered_map<uint32, PoolGroup<Creature>> PoolGroupCreatureMap;
|
||||||
@@ -165,9 +173,7 @@ class TC_GAME_API PoolMgr
|
|||||||
SearchMap mCreatureSearchMap;
|
SearchMap mCreatureSearchMap;
|
||||||
SearchMap mGameobjectSearchMap;
|
SearchMap mGameobjectSearchMap;
|
||||||
SearchMap mPoolSearchMap;
|
SearchMap mPoolSearchMap;
|
||||||
|
std::unordered_map<uint32, std::vector<uint32>> mAutoSpawnPoolsPerMap;
|
||||||
// dynamic data
|
|
||||||
ActivePoolData mSpawnedData;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define sPoolMgr PoolMgr::instance()
|
#define sPoolMgr PoolMgr::instance()
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ public:
|
|||||||
mapId = fields[6].GetUInt16();
|
mapId = fields[6].GetUInt16();
|
||||||
phase = fields[7].GetUInt32();
|
phase = fields[7].GetUInt32();
|
||||||
poolId = sPoolMgr->IsPartOfAPool<GameObject>(guidLow);
|
poolId = sPoolMgr->IsPartOfAPool<GameObject>(guidLow);
|
||||||
if (!poolId || sPoolMgr->IsSpawnedObject<GameObject>(guidLow))
|
if (!poolId || sPoolMgr->IsSpawnedObject<GameObject>(player->GetMap()->GetPoolData(), guidLow))
|
||||||
found = true;
|
found = true;
|
||||||
} while (result->NextRow() && !found);
|
} while (result->NextRow() && !found);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user