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:
@@ -591,18 +591,22 @@ namespace Game.Entities
|
|||||||
void LoadStaticPassengers()
|
void LoadStaticPassengers()
|
||||||
{
|
{
|
||||||
uint mapId = (uint)GetGoInfo().MoTransport.SpawnMap;
|
uint mapId = (uint)GetGoInfo().MoTransport.SpawnMap;
|
||||||
|
if (mapId == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
var cells = Global.ObjectMgr.GetMapObjectGuids(mapId, GetMap().GetDifficultyID());
|
var cells = Global.ObjectMgr.GetMapObjectGuids(mapId, GetMap().GetDifficultyID());
|
||||||
if (cells == null)
|
if (cells == null)
|
||||||
return;
|
return;
|
||||||
foreach (var cell in cells)
|
|
||||||
{
|
|
||||||
// Creatures on transport
|
|
||||||
foreach (var npc in cell.Value.creatures)
|
|
||||||
CreateNPCPassenger(npc, Global.ObjectMgr.GetCreatureData(npc));
|
|
||||||
|
|
||||||
|
foreach (var (_, guids) in cells)
|
||||||
|
{
|
||||||
// GameObjects on transport
|
// GameObjects on transport
|
||||||
foreach (var go in cell.Value.gameobjects)
|
foreach (var spawnId in guids.gameobjects)
|
||||||
CreateGOPassenger(go, Global.ObjectMgr.GetGameObjectData(go));
|
CreateGOPassenger(spawnId, Global.ObjectMgr.GetGameObjectData(spawnId));
|
||||||
|
|
||||||
|
// Creatures on transport
|
||||||
|
foreach (var spawnId in guids.creatures)
|
||||||
|
CreateNPCPassenger(spawnId, Global.ObjectMgr.GetCreatureData(spawnId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -738,20 +738,24 @@ namespace Game.Garrisons
|
|||||||
|
|
||||||
if (go.GetGoType() == GameObjectTypes.GarrisonBuilding && go.GetGoInfo().GarrisonBuilding.SpawnMap != 0)
|
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);
|
foreach (var spawnId in guids.creatures)
|
||||||
if (spawn != null)
|
{
|
||||||
BuildingInfo.Spawns.Add(spawn.GetGUID());
|
Creature spawn = BuildingSpawnHelper<Creature>(go, spawnId, map);
|
||||||
}
|
if (spawn != null)
|
||||||
|
BuildingInfo.Spawns.Add(spawn.GetGUID());
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var spawnId in cellGuids.Value.gameobjects)
|
foreach (var spawnId in guids.gameobjects)
|
||||||
{
|
{
|
||||||
GameObject spawn = BuildingSpawnHelper<GameObject>(go, spawnId, map);
|
GameObject spawn = BuildingSpawnHelper<GameObject>(go, spawnId, map);
|
||||||
if (spawn != null)
|
if (spawn != null)
|
||||||
BuildingInfo.Spawns.Add(spawn.GetGUID());
|
BuildingInfo.Spawns.Add(spawn.GetGUID());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10376,16 +10376,15 @@ namespace Game
|
|||||||
{
|
{
|
||||||
var key = (mapid, difficulty);
|
var key = (mapid, difficulty);
|
||||||
|
|
||||||
if (mapObjectGuidsStore.ContainsKey(key) && mapObjectGuidsStore[key].ContainsKey(cellid))
|
if (mapObjectGuidsStore.ContainsKey(key) && mapObjectGuidsStore[key].TryGetValue(cellid, out CellObjectGuids guids))
|
||||||
return mapObjectGuidsStore[key][cellid];
|
return guids;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<uint, CellObjectGuids> GetMapObjectGuids(uint mapid, Difficulty difficulty)
|
public Dictionary<uint, CellObjectGuids> GetMapObjectGuids(uint mapid, Difficulty difficulty)
|
||||||
{
|
{
|
||||||
var key = (mapid, difficulty);
|
return mapObjectGuidsStore.LookupByKey((mapid, difficulty));
|
||||||
return mapObjectGuidsStore.LookupByKey(key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PageText GetPageText(uint pageEntry)
|
public PageText GetPageText(uint pageEntry)
|
||||||
|
|||||||
@@ -101,20 +101,16 @@ namespace Game.Maps
|
|||||||
{
|
{
|
||||||
CellCoord cellCoord = i_cell.GetCellCoord();
|
CellCoord cellCoord = i_cell.GetCellCoord();
|
||||||
CellObjectGuids cellguids = Global.ObjectMgr.GetCellObjectGuids(i_map.GetId(), i_map.GetDifficultyID(), cellCoord.GetId());
|
CellObjectGuids cellguids = Global.ObjectMgr.GetCellObjectGuids(i_map.GetId(), i_map.GetDifficultyID(), cellCoord.GetId());
|
||||||
if (cellguids == null)
|
if (cellguids != null)
|
||||||
return;
|
LoadHelper<GameObject>(cellguids.gameobjects, cellCoord, ref i_gameObjects, i_map);
|
||||||
|
|
||||||
LoadHelper<GameObject>(cellguids.gameobjects, cellCoord, ref i_gameObjects, i_map);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Visit(IList<Creature> objs)
|
public override void Visit(IList<Creature> objs)
|
||||||
{
|
{
|
||||||
CellCoord cellCoord = i_cell.GetCellCoord();
|
CellCoord cellCoord = i_cell.GetCellCoord();
|
||||||
CellObjectGuids cellguids = Global.ObjectMgr.GetCellObjectGuids(i_map.GetId(), i_map.GetDifficultyID(), cellCoord.GetId());
|
CellObjectGuids cellguids = Global.ObjectMgr.GetCellObjectGuids(i_map.GetId(), i_map.GetDifficultyID(), cellCoord.GetId());
|
||||||
if (cellguids == null)
|
if (cellguids != null)
|
||||||
return;
|
LoadHelper<Creature>(cellguids.creatures, cellCoord, ref i_creatures, i_map);
|
||||||
|
|
||||||
LoadHelper<Creature>(cellguids.creatures, cellCoord, ref i_creatures, i_map);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Visit(IList<AreaTrigger> objs)
|
public override void Visit(IList<AreaTrigger> objs)
|
||||||
@@ -221,7 +217,7 @@ namespace Game.Maps
|
|||||||
{
|
{
|
||||||
// stop any fights at grid de-activation and remove dynobjects/areatriggers created at cast by creatures
|
// stop any fights at grid de-activation and remove dynobjects/areatriggers created at cast by creatures
|
||||||
for (var i = 0; i < objs.Count; ++i)
|
for (var i = 0; i < objs.Count; ++i)
|
||||||
{
|
{
|
||||||
Creature creature = objs[i];
|
Creature creature = objs[i];
|
||||||
creature.RemoveAllDynObjects();
|
creature.RemoveAllDynObjects();
|
||||||
creature.RemoveAllAreaTriggers();
|
creature.RemoveAllAreaTriggers();
|
||||||
@@ -274,7 +270,7 @@ namespace Game.Maps
|
|||||||
|
|
||||||
obj.SetDestroyedObject(true);
|
obj.SetDestroyedObject(true);
|
||||||
obj.CleanupsBeforeDelete();
|
obj.CleanupsBeforeDelete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user