Core/Pools: Implemented pooling for instances

Port From (https://github.com/TrinityCore/TrinityCore/commit/94d829c84fb184990e26178551d10ecdca049efd)
This commit is contained in:
hondacrx
2022-06-15 22:56:12 -04:00
parent 04caa3e757
commit 4038b93aa1
7 changed files with 286 additions and 197 deletions
+4 -4
View File
@@ -1968,9 +1968,9 @@ namespace Game.Entities
triggerJustAppeared = true;
uint poolid = GetSpawnId() != 0 ? Global.PoolMgr.IsPartOfAPool<Creature>(GetSpawnId()) : 0;
uint poolid = GetCreatureData() != null ? GetCreatureData().poolId : 0;
if (poolid != 0)
Global.PoolMgr.UpdatePool<Creature>(poolid, GetSpawnId());
Global.PoolMgr.UpdatePool<Creature>(GetMap().GetPoolData(), poolid, GetSpawnId());
}
UpdateObjectVisibility();
}
@@ -3238,7 +3238,7 @@ namespace Game.Entities
if (!m_respawnCompatibilityMode)
{
// @todo pools need fixing! this is just a temporary thing, but they violate dynspawn principles
if (Global.PoolMgr.IsPartOfAPool<Creature>(spawnId) == 0)
if (data.poolId == 0)
{
Log.outError(LogFilter.Unit, $"Creature (SpawnID {spawnId}) trying to load in inactive spawn group '{data.spawnGroupData.name}':\n{GetDebugInfo()}");
return false;
@@ -3253,7 +3253,7 @@ namespace Game.Entities
if (!m_respawnCompatibilityMode)
{
// @todo same as above
if (Global.PoolMgr.IsPartOfAPool<Creature>(spawnId) == 0)
if (data.poolId == 0)
{
Log.outError(LogFilter.Unit, $"Creature (SpawnID {spawnId}) trying to load despite a respawn timer in progress:\n{GetDebugInfo()}");
return false;
@@ -558,9 +558,9 @@ namespace Game.Entities
GetAI().Reset();
// respawn timer
uint poolid = GetSpawnId() != 0 ? Global.PoolMgr.IsPartOfAPool<GameObject>(GetSpawnId()) : 0;
uint poolid = GetGameObjectData() != null ? GetGameObjectData().poolId : 0;
if (poolid != 0)
Global.PoolMgr.UpdatePool<GameObject>(poolid, GetSpawnId());
Global.PoolMgr.UpdatePool<GameObject>(GetMap().GetPoolData(), poolid, GetSpawnId());
else
GetMap().AddToMap(this);
}
@@ -941,9 +941,9 @@ namespace Game.Entities
if (goOverride != null)
ReplaceAllFlags(goOverride.Flags);
uint poolid = GetSpawnId() != 0 ? Global.PoolMgr.IsPartOfAPool<GameObject>(GetSpawnId()) : 0;
uint poolid = GetGameObjectData() != null ? GetGameObjectData().poolId : 0;
if (poolid != 0)
Global.PoolMgr.UpdatePool<GameObject>(poolid, GetSpawnId());
Global.PoolMgr.UpdatePool<GameObject>(GetMap().GetPoolData(), poolid, GetSpawnId());
else
AddObjectToRemoveList();
}