diff --git a/Client/CentrEDClient.cs b/Client/CentrEDClient.cs index b4f0276..b0997b4 100644 --- a/Client/CentrEDClient.cs +++ b/Client/CentrEDClient.cs @@ -22,6 +22,7 @@ public sealed class CentrEDClient : BaseCentrED, IDisposable public ushort X { get; private set; } public ushort Y { get; private set; } internal Stack UndoStack = new(); + internal List RequestedBlocks = new(); public List Clients { get; } = new(); public bool Running; private string? _status; @@ -129,10 +130,11 @@ public void InitLandscape(ushort width, ushort height) public void LoadBlocks(List blockCoords) { var filteredBlockCoords = blockCoords.FindAll - (b => !Landscape.BlockCache.Contains(Block.Id(b.X, b.Y)) && isValidX(b.X) && isValidY(b.Y)); + (b => !Landscape.BlockCache.Contains(Block.Id(b.X, b.Y)) && !RequestedBlocks.Contains(b) && isValidX(b.X) && isValidY(b.Y)); if (filteredBlockCoords.Count <= 0) return; Send(new RequestBlocksPacket(filteredBlockCoords)); + RequestedBlocks.AddRange(filteredBlockCoords); } public bool isValidX(int x) diff --git a/Client/Map/ClientLandscapePacketHandlers.cs b/Client/Map/ClientLandscapePacketHandlers.cs index b9a969a..37057dd 100644 --- a/Client/Map/ClientLandscapePacketHandlers.cs +++ b/Client/Map/ClientLandscapePacketHandlers.cs @@ -25,6 +25,7 @@ private void OnBlockPacket(BinaryReader reader, NetState ns) var block = new Block(landBlock, staticBlock); if(BlockCache.Add(Block.Id(block), block)) ns.Parent.OnBlockLoaded(block); + ns.Parent.RequestedBlocks.Remove(coords); } }