Skip to content

Commit

Permalink
Tweak grid state slightly
Browse files Browse the repository at this point in the history
Doubt it affects anything but if tile changes throws it at least ensures the fixtures are updated.
  • Loading branch information
metalgearsloth committed Jan 31, 2025
1 parent bdef9e3 commit 5f17139
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 5f17139

Please sign in to comment.