From e08cf14b7f1cd2a3a0cf32916cd5f05af3843ca7 Mon Sep 17 00:00:00 2001 From: 8vogt <8vogt@informatik.uni-hamburg.de> Date: Sun, 4 Apr 2021 21:03:20 +0200 Subject: [PATCH] Possible fix for #80 by locking access to untracked Entities for thread safety --- SEWorldGenPlugin/Generator/MyStarSystemGenerator.cs | 1 - SEWorldGenPlugin/Properties/AssemblyInfo.cs | 2 +- SEWorldGenPlugin/Session/MyEntityTrackerComponent.cs | 6 ++++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/SEWorldGenPlugin/Generator/MyStarSystemGenerator.cs b/SEWorldGenPlugin/Generator/MyStarSystemGenerator.cs index 4d09fb8..827dc47 100644 --- a/SEWorldGenPlugin/Generator/MyStarSystemGenerator.cs +++ b/SEWorldGenPlugin/Generator/MyStarSystemGenerator.cs @@ -12,7 +12,6 @@ using System.Collections.Generic; using VRage.Game; using VRage.Game.Components; -using VRage.Game.Entity; using VRage.Library.Utils; using VRageMath; diff --git a/SEWorldGenPlugin/Properties/AssemblyInfo.cs b/SEWorldGenPlugin/Properties/AssemblyInfo.cs index 522f9f1..e3d6198 100644 --- a/SEWorldGenPlugin/Properties/AssemblyInfo.cs +++ b/SEWorldGenPlugin/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, // indem Sie "*" wie unten gezeigt eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.5.1")] +[assembly: AssemblyVersion("2.0.5.3")] [assembly: AssemblyFileVersion("1.0.0")] diff --git a/SEWorldGenPlugin/Session/MyEntityTrackerComponent.cs b/SEWorldGenPlugin/Session/MyEntityTrackerComponent.cs index 5d247fa..81d88f0 100644 --- a/SEWorldGenPlugin/Session/MyEntityTrackerComponent.cs +++ b/SEWorldGenPlugin/Session/MyEntityTrackerComponent.cs @@ -122,7 +122,8 @@ public void TrackEntity(MyEntity entity) m_newTrackedEntities.Add(entity); entity.OnMarkForClose += (e) => { - m_toUntrackEntities.Add(e); + lock(m_toUntrackEntities) + m_toUntrackEntities.Add(e); }; } } @@ -157,7 +158,8 @@ private void OnGridPlayerPresenceUpdate(MyCubeGrid grid) { if(grid.PlayerPresenceTier != VRage.Game.ModAPI.MyUpdateTiersPlayerPresence.Normal) { - m_toUntrackEntities.Add(grid); + lock(m_toUntrackEntities) + m_toUntrackEntities.Add(grid); } } }