diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Transport/Transport.cpp | 31 | ||||
-rw-r--r-- | src/server/game/Garrison/Garrison.cpp | 17 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 13 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.h | 10 | ||||
-rw-r--r-- | src/server/game/Grids/ObjectGridLoader.cpp | 11 |
5 files changed, 46 insertions, 36 deletions
diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index a535f11756c..18ec7943466 100644 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -561,22 +561,23 @@ void Transport::UpdatePosition(float x, float y, float z, float o) void Transport::LoadStaticPassengers() { - if (uint32 mapId = GetGOInfo()->moTransport.SpawnMap) + uint32 mapId = GetGOInfo()->moTransport.SpawnMap; + if (!mapId) + return; + + CellObjectGuidsMap const* cells = sObjectMgr->GetMapObjectGuids(mapId, GetMap()->GetDifficultyID()); + if (!cells) + return; + + for (auto const& [cellId, guids] : *cells) { - CellObjectGuidsMap const& cells = sObjectMgr->GetMapObjectGuids(mapId, GetMap()->GetDifficultyID()); - CellGuidSet::const_iterator guidEnd; - for (CellObjectGuidsMap::const_iterator cellItr = cells.begin(); cellItr != cells.end(); ++cellItr) - { - // Creatures on transport - guidEnd = cellItr->second.creatures.end(); - for (CellGuidSet::const_iterator guidItr = cellItr->second.creatures.begin(); guidItr != guidEnd; ++guidItr) - CreateNPCPassenger(*guidItr, sObjectMgr->GetCreatureData(*guidItr)); - - // GameObjects on transport - guidEnd = cellItr->second.gameobjects.end(); - for (CellGuidSet::const_iterator guidItr = cellItr->second.gameobjects.begin(); guidItr != guidEnd; ++guidItr) - CreateGOPassenger(*guidItr, sObjectMgr->GetGameObjectData(*guidItr)); - } + // GameObjects on transport + for (ObjectGuid::LowType spawnId : guids.gameobjects) + CreateGOPassenger(spawnId, sObjectMgr->GetGameObjectData(spawnId)); + + // Creatures on transport + for (ObjectGuid::LowType spawnId : guids.creatures) + CreateNPCPassenger(spawnId, sObjectMgr->GetCreatureData(spawnId)); } } diff --git a/src/server/game/Garrison/Garrison.cpp b/src/server/game/Garrison/Garrison.cpp index 031133adfca..ae0bb48ccae 100644 --- a/src/server/game/Garrison/Garrison.cpp +++ b/src/server/game/Garrison/Garrison.cpp @@ -759,15 +759,18 @@ GameObject* Garrison::Plot::CreateGameObject(Map* map, GarrisonFactionIndex fact if (building->GetGoType() == GAMEOBJECT_TYPE_GARRISON_BUILDING && building->GetGOInfo()->garrisonBuilding.SpawnMap) { - for (CellObjectGuidsMap::value_type const& cellGuids : sObjectMgr->GetMapObjectGuids(building->GetGOInfo()->garrisonBuilding.SpawnMap, map->GetDifficultyID())) + if (CellObjectGuidsMap const* cells = sObjectMgr->GetMapObjectGuids(building->GetGOInfo()->garrisonBuilding.SpawnMap, map->GetDifficultyID())) { - for (ObjectGuid::LowType spawnId : cellGuids.second.creatures) - if (Creature* spawn = BuildingSpawnHelper<Creature, &Creature::SetHomePosition>(building, spawnId, map)) - BuildingInfo.Spawns.insert(spawn->GetGUID()); + for (auto const& [cellId, guids] : *cells) + { + for (ObjectGuid::LowType spawnId : guids.gameobjects) + if (GameObject* spawn = BuildingSpawnHelper<GameObject, &GameObject::RelocateStationaryPosition>(building, spawnId, map)) + BuildingInfo.Spawns.insert(spawn->GetGUID()); - for (ObjectGuid::LowType spawnId : cellGuids.second.gameobjects) - if (GameObject* spawn = BuildingSpawnHelper<GameObject, &GameObject::RelocateStationaryPosition>(building, spawnId, map)) - BuildingInfo.Spawns.insert(spawn->GetGUID()); + for (ObjectGuid::LowType spawnId : guids.creatures) + if (Creature* spawn = BuildingSpawnHelper<Creature, &Creature::SetHomePosition>(building, spawnId, map)) + BuildingInfo.Spawns.insert(spawn->GetGUID()); + } } } diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 3f448b6ff7d..e53fbe9730d 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -2380,6 +2380,19 @@ void ObjectMgr::LoadCreatures() TC_LOG_INFO("server.loading", ">> Loaded {} creatures in {} ms", _creatureDataStore.size(), GetMSTimeDiffToNow(oldMSTime)); } +CellObjectGuids const* ObjectMgr::GetCellObjectGuids(uint32 mapid, Difficulty spawnMode, uint32 cell_id) +{ + if (CellObjectGuidsMap const* mapGuids = Trinity::Containers::MapGetValuePtr(_mapObjectGuidsStore, { mapid, spawnMode })) + return Trinity::Containers::MapGetValuePtr(*mapGuids, cell_id); + + return nullptr; +} + +CellObjectGuidsMap const* ObjectMgr::GetMapObjectGuids(uint32 mapid, Difficulty spawnMode) +{ + return Trinity::Containers::MapGetValuePtr(_mapObjectGuidsStore, { mapid, spawnMode }); +} + bool ObjectMgr::HasPersonalSpawns(uint32 mapid, Difficulty spawnMode, uint32 phaseId) const { return Trinity::Containers::MapGetValuePtr(_mapPersonalObjectGuidsStore, { mapid, spawnMode, phaseId }) != nullptr; diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index fd5b9e7b668..a3af1016609 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -1460,15 +1460,9 @@ class TC_GAME_API ObjectMgr return nullptr; } - CellObjectGuids const& GetCellObjectGuids(uint32 mapid, Difficulty spawnMode, uint32 cell_id) - { - return _mapObjectGuidsStore[{ mapid, spawnMode }][cell_id]; - } + CellObjectGuids const* GetCellObjectGuids(uint32 mapid, Difficulty spawnMode, uint32 cell_id); - CellObjectGuidsMap const& GetMapObjectGuids(uint32 mapid, Difficulty spawnMode) - { - return _mapObjectGuidsStore[{ mapid, spawnMode }]; - } + CellObjectGuidsMap const* GetMapObjectGuids(uint32 mapid, Difficulty spawnMode); bool HasPersonalSpawns(uint32 mapid, Difficulty spawnMode, uint32 phaseId) const; CellObjectGuids const* GetCellPersonalObjectGuids(uint32 mapid, Difficulty spawnMode, uint32 phaseId, uint32 cell_id) const; diff --git a/src/server/game/Grids/ObjectGridLoader.cpp b/src/server/game/Grids/ObjectGridLoader.cpp index 3420707fdbe..5fd6d741a90 100644 --- a/src/server/game/Grids/ObjectGridLoader.cpp +++ b/src/server/game/Grids/ObjectGridLoader.cpp @@ -131,22 +131,21 @@ void LoadHelper(CellGuidSet const& guid_set, CellCoord& cell, GridRefManager<T>& void ObjectGridLoader::Visit(GameObjectMapType& m) { CellCoord cellCoord = i_cell.GetCellCoord(); - CellObjectGuids const& cell_guids = sObjectMgr->GetCellObjectGuids(i_map->GetId(), i_map->GetDifficultyID(), cellCoord.GetId()); - LoadHelper(cell_guids.gameobjects, cellCoord, m, i_gameObjects, i_map); + if (CellObjectGuids const* cell_guids = sObjectMgr->GetCellObjectGuids(i_map->GetId(), i_map->GetDifficultyID(), cellCoord.GetId())) + LoadHelper(cell_guids->gameobjects, cellCoord, m, i_gameObjects, i_map); } void ObjectGridLoader::Visit(CreatureMapType &m) { CellCoord cellCoord = i_cell.GetCellCoord(); - CellObjectGuids const& cell_guids = sObjectMgr->GetCellObjectGuids(i_map->GetId(), i_map->GetDifficultyID(), cellCoord.GetId()); - LoadHelper(cell_guids.creatures, cellCoord, m, i_creatures, i_map); + if (CellObjectGuids const* cell_guids = sObjectMgr->GetCellObjectGuids(i_map->GetId(), i_map->GetDifficultyID(), cellCoord.GetId())) + LoadHelper(cell_guids->creatures, cellCoord, m, i_creatures, i_map); } void ObjectGridLoader::Visit(AreaTriggerMapType& m) { CellCoord cellCoord = i_cell.GetCellCoord(); - CellGuidSet const* areaTriggers = sAreaTriggerDataStore->GetAreaTriggersForMapAndCell(i_map->GetId(), i_map->GetDifficultyID(), cellCoord.GetId()); - if (areaTriggers) + if (CellGuidSet const* areaTriggers = sAreaTriggerDataStore->GetAreaTriggersForMapAndCell(i_map->GetId(), i_map->GetDifficultyID(), cellCoord.GetId())) LoadHelper(*areaTriggers, cellCoord, m, i_areaTriggers, i_map); } |