Skip to content

Commit

Permalink
Added fix for crash that gets caused by one grid being tracked multip…
Browse files Browse the repository at this point in the history
…le times.
  • Loading branch information
thorwin99 committed Oct 12, 2021
1 parent c26c18e commit 0e940b8
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions SEWorldGenPlugin/Session/MyEntityTrackerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,7 @@ public override void UpdateBeforeSimulation()

foreach(var entity in entities)
{
if(entity is MyCharacter)
{
TrackEntity(entity);
}
if(entity is MyCubeGrid grid)
{
if(grid.PlayerPresenceTier == VRage.Game.ModAPI.MyUpdateTiersPlayerPresence.Normal)
{
TrackEntity(entity);
grid.PlayerPresenceTierChanged += OnGridPlayerPresenceUpdate;
}
}
TrackEntity(entity);
}

lock (m_toUntrackEntities) lock (m_entityTrackers)
Expand Down Expand Up @@ -120,8 +109,20 @@ public void TrackEntity(MyEntity entity)
{
if (m_trackedEntities != null && m_newTrackedEntities != null && !m_trackedEntities.Contains(entity))
{
m_newTrackedEntities.Add(entity);
entity.OnMarkForClose += OnEntityClose;
if (entity is MyCharacter)
{
m_newTrackedEntities.Add(entity);
entity.OnMarkForClose += OnEntityClose;
}
if (entity is MyCubeGrid grid)
{
if (grid.PlayerPresenceTier == VRage.Game.ModAPI.MyUpdateTiersPlayerPresence.Normal)
{
m_newTrackedEntities.Add(entity);
entity.OnMarkForClose += OnEntityClose;
grid.PlayerPresenceTierChanged += OnGridPlayerPresenceUpdate;
}
}
}
}

Expand Down

0 comments on commit 0e940b8

Please sign in to comment.