diff options
author | Treeston <treeston.mmoc@gmail.com> | 2020-02-08 20:22:37 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-12-21 15:16:26 +0100 |
commit | 94a79bac7a06aa0f931e9d651928de7eea0a8b5c (patch) | |
tree | 0f28508689237d951d0a44ae05c85ab3a29d8c62 /src/server/game/Grids/ObjectGridLoader.cpp | |
parent | fe489e2be1312bc559d0c38691c9741ad69cfec8 (diff) |
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 9304e496cbf6ab6c028671fb8526c732ae5d799f)
Diffstat (limited to 'src/server/game/Grids/ObjectGridLoader.cpp')
-rw-r--r-- | src/server/game/Grids/ObjectGridLoader.cpp | 52 |
1 files changed, 10 insertions, 42 deletions
diff --git a/src/server/game/Grids/ObjectGridLoader.cpp b/src/server/game/Grids/ObjectGridLoader.cpp index 00d590467a1..a718f455dab 100644 --- a/src/server/game/Grids/ObjectGridLoader.cpp +++ b/src/server/game/Grids/ObjectGridLoader.cpp @@ -124,51 +124,19 @@ void LoadHelper(CellGuidSet const& guid_set, CellCoord &cell, GridRefManager<T> { for (CellGuidSet::const_iterator i_guid = guid_set.begin(); i_guid != guid_set.end(); ++i_guid) { - T* obj = new T; + // Don't spawn at all if there's a respawn timer + ObjectGuid::LowType guid = *i_guid; + if (!map->ShouldBeSpawnedOnGridLoad<T>(guid)) + continue; - // Don't spawn at all if there's a respawn time - if ((obj->GetTypeId() == TYPEID_UNIT && !map->GetCreatureRespawnTime(*i_guid)) || - (obj->GetTypeId() == TYPEID_GAMEOBJECT && !map->GetGORespawnTime(*i_guid)) || - (obj->GetTypeId() == TYPEID_AREATRIGGER)) + T* obj = new T; + //TC_LOG_INFO("misc", "DEBUG: LoadHelper from table: %s for (guid: " UI64FMTD ") Loading", table, guid); + if (!obj->LoadFromDB(guid, map, false, false)) { - ObjectGuid::LowType guid = *i_guid; - //TC_LOG_INFO("misc", "DEBUG: LoadHelper from table: %s for (guid: %u) Loading", table, guid); - - if (obj->GetTypeId() == TYPEID_UNIT) - { - CreatureData const* cdata = sObjectMgr->GetCreatureData(guid); - ASSERT(cdata, "Tried to load creature with spawnId " UI64FMTD ", but no such creature exists.", guid); - SpawnGroupTemplateData const* const group = cdata->spawnGroupData; - // If creature in manual spawn group, don't spawn here, unless group is already active. - if (!(group->flags & SPAWNGROUP_FLAG_SYSTEM)) - if (!map->IsSpawnGroupActive(group->groupId)) - { - delete obj; - continue; - } - } - else if (obj->GetTypeId() == TYPEID_GAMEOBJECT) - { - // If gameobject in manual spawn group, don't spawn here, unless group is already active. - GameObjectData const* godata = sObjectMgr->GetGameObjectData(guid); - ASSERT(godata, "Tried to load gameobject with spawnId " UI64FMTD ", but no such object exists.", guid); - if (!(godata->spawnGroupData->flags & SPAWNGROUP_FLAG_SYSTEM)) - if (!map->IsSpawnGroupActive(godata->spawnGroupData->groupId)) - { - delete obj; - continue; - } - } - - if (!obj->LoadFromDB(guid, map, false, false)) - { - delete obj; - continue; - } - AddObjectHelper(cell, m, count, map, obj); - } - else delete obj; + continue; + } + AddObjectHelper(cell, m, count, map, obj); } } |