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

Port From (https://github.com/TrinityCore/TrinityCore/commit/7b6589c1ecc159f6949c5535785fba79a04b2c4a)
This commit is contained in:
hondacrx
2024-02-01 11:43:10 -05:00
parent d2edbdeecc
commit 2a7273f1ec
4 changed files with 35 additions and 32 deletions
+15 -11
View File
@@ -738,20 +738,24 @@ namespace Game.Garrisons
if (go.GetGoType() == GameObjectTypes.GarrisonBuilding && go.GetGoInfo().GarrisonBuilding.SpawnMap != 0)
{
foreach (var cellGuids in Global.ObjectMgr.GetMapObjectGuids((uint)go.GetGoInfo().GarrisonBuilding.SpawnMap, map.GetDifficultyID()))
var cells = Global.ObjectMgr.GetMapObjectGuids((uint)go.GetGoInfo().GarrisonBuilding.SpawnMap, map.GetDifficultyID());
if (cells != null)
{
foreach (var spawnId in cellGuids.Value.creatures)
foreach (var (_, guids) in cells)
{
Creature spawn = BuildingSpawnHelper<Creature>(go, spawnId, map);
if (spawn != null)
BuildingInfo.Spawns.Add(spawn.GetGUID());
}
foreach (var spawnId in guids.creatures)
{
Creature spawn = BuildingSpawnHelper<Creature>(go, spawnId, map);
if (spawn != null)
BuildingInfo.Spawns.Add(spawn.GetGUID());
}
foreach (var spawnId in cellGuids.Value.gameobjects)
{
GameObject spawn = BuildingSpawnHelper<GameObject>(go, spawnId, map);
if (spawn != null)
BuildingInfo.Spawns.Add(spawn.GetGUID());
foreach (var spawnId in guids.gameobjects)
{
GameObject spawn = BuildingSpawnHelper<GameObject>(go, spawnId, map);
if (spawn != null)
BuildingInfo.Spawns.Add(spawn.GetGUID());
}
}
}
}