aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-10-17 15:48:02 +0200
committerShauren <shauren.trinity@gmail.com>2023-10-17 15:48:02 +0200
commit7b6589c1ecc159f6949c5535785fba79a04b2c4a (patch)
treea4effc10887ee0e6eb4fbfd4c36179fd0cb72316 /src/server/game/Entities
parent9fc4e2ba5cffa2eaac8cdb20c9400ad666132b48 (diff)
Core/Misc: Fixed thread-unsafe access to list of objects that should be spawned in a cell
Closes #29372
Diffstat (limited to 'src/server/game/Entities')
-rw-r--r--src/server/game/Entities/Transport/Transport.cpp31
1 files changed, 16 insertions, 15 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));
}
}