diff --git a/Nibriboard/Client/NibriClient.cs b/Nibriboard/Client/NibriClient.cs
index daf1273..b18de53 100644
--- a/Nibriboard/Client/NibriClient.cs
+++ b/Nibriboard/Client/NibriClient.cs
@@ -366,18 +366,10 @@ namespace Nibriboard.Client
/// The message to process.
protected async Task handleChunkUpdateRequestMessage(ChunkUpdateRequestMessage message)
{
- chunkCache.Remove(message.ForgottenChunksAsReferences(this.CurrentPlane));
+ List requestedChunkRefs = message.ForgottenChunksAsReferences(this.CurrentPlane);
+ chunkCache.Remove(requestedChunkRefs);
- ChunkUpdateMessage response = new ChunkUpdateMessage();
- List missingChunks = ChunkTools.GetContainingChunkReferences(CurrentPlane, CurrentViewPort);
- missingChunks = chunkCache.FindMissing(missingChunks);
-
- await SendChunks(missingChunks);
- /*response.Chunks = await CurrentPlane.FetchChunks(missingChunks);
- Console.WriteLine(JsonConvert.SerializeObject(response));
- Send(response);*/
-
- chunkCache.Add(missingChunks);
+ await SendChunks(requestedChunkRefs);
}
///
@@ -553,6 +545,14 @@ namespace Nibriboard.Client
return;
}
+ if(chunkRefs.Count() == 0) {
+ Log.WriteLine("[NibriClient#{0}/SendChunks] Can't send 0 chunks!", Id);
+ return;
+ }
+
+ // Keep track of the fact that we've sent the client a bunch of chunks
+ chunkCache.Add(chunkRefs);
+
ChunkUpdateMessage updateMessage = new ChunkUpdateMessage();
foreach(ChunkReference chunkRef in chunkRefs)
updateMessage.Chunks.Add(await CurrentPlane.FetchChunk(chunkRef));