mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-17 19:05:42 +00:00
feat(Core/Misc): implement ObjectGuid class (port from TC) (#4885)
This commit is contained in:
@@ -173,7 +173,7 @@ PoolObject* PoolGroup<T>::RollOne(ActivePoolData& spawns, uint32 triggerFrom)
|
||||
// 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 PoolGroup<T>::DespawnObject(ActivePoolData& spawns, uint32 guid)
|
||||
void PoolGroup<T>::DespawnObject(ActivePoolData& spawns, ObjectGuid::LowType guid)
|
||||
{
|
||||
for (size_t i = 0; i < EqualChanced.size(); ++i)
|
||||
{
|
||||
@@ -204,27 +204,45 @@ void PoolGroup<T>::DespawnObject(ActivePoolData& spawns, uint32 guid)
|
||||
|
||||
// Method that is actualy doing the removal job on one creature
|
||||
template<>
|
||||
void PoolGroup<Creature>::Despawn1Object(uint32 guid)
|
||||
void PoolGroup<Creature>::Despawn1Object(ObjectGuid::LowType guid)
|
||||
{
|
||||
if (CreatureData const* data = sObjectMgr->GetCreatureData(guid))
|
||||
{
|
||||
sObjectMgr->RemoveCreatureFromGrid(guid, data);
|
||||
|
||||
if (Creature* creature = ObjectAccessor::GetObjectInWorld(MAKE_NEW_GUID(guid, data->id, HIGHGUID_UNIT), (Creature*)nullptr))
|
||||
creature->AddObjectToRemoveList();
|
||||
Map* map = sMapMgr->CreateBaseMap(data->mapid);
|
||||
if (!map->Instanceable())
|
||||
{
|
||||
auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(guid);
|
||||
for (auto itr = creatureBounds.first; itr != creatureBounds.second;)
|
||||
{
|
||||
Creature* creature = itr->second;
|
||||
++itr;
|
||||
creature->AddObjectToRemoveList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Same on one gameobject
|
||||
template<>
|
||||
void PoolGroup<GameObject>::Despawn1Object(uint32 guid)
|
||||
void PoolGroup<GameObject>::Despawn1Object(ObjectGuid::LowType guid)
|
||||
{
|
||||
if (GameObjectData const* data = sObjectMgr->GetGOData(guid))
|
||||
{
|
||||
sObjectMgr->RemoveGameobjectFromGrid(guid, data);
|
||||
|
||||
if (GameObject* pGameobject = ObjectAccessor::GetObjectInWorld(MAKE_NEW_GUID(guid, data->id, HIGHGUID_GAMEOBJECT), (GameObject*)nullptr))
|
||||
pGameobject->AddObjectToRemoveList();
|
||||
Map* map = sMapMgr->CreateBaseMap(data->mapid);
|
||||
if (!map->Instanceable())
|
||||
{
|
||||
auto gameobjectBounds = map->GetGameObjectBySpawnIdStore().equal_range(guid);
|
||||
for (auto itr = gameobjectBounds.first; itr != gameobjectBounds.second;)
|
||||
{
|
||||
GameObject* go = itr->second;
|
||||
++itr;
|
||||
go->AddObjectToRemoveList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,20 +520,16 @@ void PoolGroup<Quest>::SpawnObject(ActivePoolData& spawns, uint32 limit, uint32
|
||||
|
||||
// Method that does the respawn job on the specified creature
|
||||
template <>
|
||||
void PoolGroup<Creature>::ReSpawn1Object(PoolObject* obj)
|
||||
void PoolGroup<Creature>::ReSpawn1Object(PoolObject* /*obj*/)
|
||||
{
|
||||
if (CreatureData const* data = sObjectMgr->GetCreatureData(obj->guid))
|
||||
if (Creature* creature = ObjectAccessor::GetObjectInWorld(MAKE_NEW_GUID(obj->guid, data->id, HIGHGUID_UNIT), (Creature*)nullptr))
|
||||
creature->GetMap()->AddToMap(creature);
|
||||
// Creature is still on map, nothing to do
|
||||
}
|
||||
|
||||
// Method that does the respawn job on the specified gameobject
|
||||
template <>
|
||||
void PoolGroup<GameObject>::ReSpawn1Object(PoolObject* obj)
|
||||
void PoolGroup<GameObject>::ReSpawn1Object(PoolObject* /*obj*/)
|
||||
{
|
||||
if (GameObjectData const* data = sObjectMgr->GetGOData(obj->guid))
|
||||
if (GameObject* pGameobject = ObjectAccessor::GetObjectInWorld(MAKE_NEW_GUID(obj->guid, data->id, HIGHGUID_GAMEOBJECT), (GameObject*)nullptr))
|
||||
pGameobject->GetMap()->AddToMap(pGameobject);
|
||||
// Gameobject is still on map, nothing to do
|
||||
}
|
||||
|
||||
// Nothing to do for a child Pool
|
||||
@@ -603,9 +617,9 @@ void PoolMgr::LoadFromDB()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 guid = fields[0].GetUInt32();
|
||||
ObjectGuid::LowType guid = fields[0].GetUInt32();
|
||||
uint32 pool_id = fields[1].GetUInt32();
|
||||
float chance = fields[2].GetFloat();
|
||||
float chance = fields[2].GetFloat();
|
||||
|
||||
CreatureData const* data = sObjectMgr->GetCreatureData(guid);
|
||||
if (!data)
|
||||
@@ -661,9 +675,9 @@ void PoolMgr::LoadFromDB()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 guid = fields[0].GetUInt32();
|
||||
ObjectGuid::LowType guid = fields[0].GetUInt32();
|
||||
uint32 pool_id = fields[1].GetUInt32();
|
||||
float chance = fields[2].GetFloat();
|
||||
float chance = fields[2].GetFloat();
|
||||
|
||||
GameObjectData const* data = sObjectMgr->GetGOData(guid);
|
||||
if (!data)
|
||||
|
||||
Reference in New Issue
Block a user