Core/Misc: Some refactoring, #23603 prep: (#23676)

- Split SpawnMetadata off from SpawnData
- No longer allocate Creature/Gameobject objects in ObjectGridLoader just to check their typeid and delete them afterwards

Co-authored-by: Giacomo Pozzoni <giacomopoz@gmail.com>
(cherry picked from commit 9304e496cb)
This commit is contained in:
Treeston
2020-02-08 20:22:37 +01:00
committed by Shauren
parent fe489e2be1
commit 94a79bac7a
21 changed files with 488 additions and 394 deletions

View File

@@ -177,7 +177,7 @@ void PoolGroup<Creature>::Despawn1Object(uint64 guid)
{
sObjectMgr->RemoveCreatureFromGrid(guid, data);
Map* map = sMapMgr->FindMap(data->spawnPoint.GetMapId(), 0);
Map* map = sMapMgr->FindMap(data->mapId, 0);
if (map && !map->Instanceable())
{
auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(guid);
@@ -202,7 +202,7 @@ void PoolGroup<GameObject>::Despawn1Object(uint64 guid)
{
sObjectMgr->RemoveGameobjectFromGrid(guid, data);
Map* map = sMapMgr->FindMap(data->spawnPoint.GetMapId(), 0);
Map* map = sMapMgr->FindMap(data->mapId, 0);
if (map && !map->Instanceable())
{
auto gameobjectBounds = map->GetGameObjectBySpawnIdStore().equal_range(guid);
@@ -323,7 +323,7 @@ void PoolGroup<Creature>::Spawn1Object(PoolObject* obj)
sObjectMgr->AddCreatureToGrid(obj->guid, data);
// Spawn if necessary (loaded grids only)
Map* map = sMapMgr->FindMap(data->spawnPoint.GetMapId(), 0);
Map* map = sMapMgr->FindMap(data->mapId, 0);
// We use spawn coords to spawn
if (map && !map->Instanceable() && map->IsGridLoaded(data->spawnPoint))
Creature::CreateCreatureFromDB(obj->guid, map);
@@ -339,7 +339,7 @@ void PoolGroup<GameObject>::Spawn1Object(PoolObject* obj)
sObjectMgr->AddGameobjectToGrid(obj->guid, data);
// Spawn if necessary (loaded grids only)
// this base map checked as non-instanced and then only existed
Map* map = sMapMgr->FindMap(data->spawnPoint.GetMapId(), 0);
Map* map = sMapMgr->FindMap(data->mapId, 0);
// We use current coords to unspawn, not spawn coords since creature can have changed grid
if (map && !map->Instanceable() && map->IsGridLoaded(data->spawnPoint))
{
@@ -760,6 +760,8 @@ uint32 PoolMgr::IsPartOfAPool(SpawnObjectType type, ObjectGuid::LowType spawnId)
return IsPartOfAPool<Creature>(spawnId);
case SPAWN_TYPE_GAMEOBJECT:
return IsPartOfAPool<GameObject>(spawnId);
case SPAWN_TYPE_AREATRIGGER:
return 0;
default:
ASSERT(false, "Invalid spawn type %u passed to PoolMgr::IsPartOfPool (with spawnId " UI64FMTD ")", uint32(type), spawnId);
return 0;