Skip to content

Commit

Permalink
Tweak grid state slightly (#5644)
Browse files Browse the repository at this point in the history
  • Loading branch information
metalgearsloth authored Feb 3, 2025
1 parent bd69d51 commit 2719b9f
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions Robust.Shared/GameObjects/Systems/SharedMapSystem.Grid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ private void ApplyChunkData(

if (data.IsDeleted())
{
if (!component.Chunks.TryGetValue(index, out var deletedChunk))
if (!component.Chunks.Remove(index, out var deletedChunk))
return;

// Deleted chunks still need to raise tile-changed events.
Expand All @@ -330,11 +330,13 @@ private void ApplyChunkData(
}
}

component.Chunks.Remove(index);
return;
}

var chunk = GetOrAddChunk(uid, component, index);
chunk.Fixtures.Clear();
chunk.Fixtures.UnionWith(data.Fixtures);

chunk.SuppressCollisionRegeneration = true;
DebugTools.Assert(data.TileData.Any(x => !x.IsEmpty));
DebugTools.Assert(data.TileData.Length == component.ChunkSize * component.ChunkSize);
Expand All @@ -355,12 +357,6 @@ private void ApplyChunkData(
// These should never refer to the same object
DebugTools.AssertNotEqual(chunk.Fixtures, data.Fixtures);

if (!chunk.Fixtures.SetEquals(data.Fixtures))
{
chunk.Fixtures.Clear();
chunk.Fixtures.UnionWith(data.Fixtures);
}

chunk.CachedBounds = data.CachedBounds!.Value;
chunk.SuppressCollisionRegeneration = false;
}
Expand Down

0 comments on commit 2719b9f

Please sign in to comment.