Core/Misc: Fixed thread-unsafe access to list of objects that should be spawned in a cell

Closes #29372
This commit is contained in:
Shauren
2023-10-17 15:48:02 +02:00
parent 9fc4e2ba5c
commit 7b6589c1ec
5 changed files with 46 additions and 36 deletions

View File

@@ -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());
}
}
}