mirror of
https://github.com/sbrl/Nibriboard.git
synced 2018-01-10 21:33:49 +00:00
[server] Rework ChunkUpdateRequest logic
This commit is contained in:
parent
334acdbc18
commit
55cdcf982c
3 changed files with 21 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Nibriboard.RippleSpace;
|
||||
|
||||
namespace Nibriboard.Client.Messages
|
||||
|
@ -10,10 +11,26 @@ namespace Nibriboard.Client.Messages
|
|||
/// A list of chunks that the client has intentionally forgotten about, and will need
|
||||
/// to be resent to the client.
|
||||
/// </summary>
|
||||
public List<dynamic> ForgottenChunks = new List<dynamic>();
|
||||
public List<RawChunkReference> ForgottenChunks = new List<RawChunkReference>();
|
||||
|
||||
public ChunkUpdateRequestMessage()
|
||||
{
|
||||
}
|
||||
|
||||
public List<ChunkReference> ForgottenChunksAsReferences(Plane plane)
|
||||
{
|
||||
List<ChunkReference> result = new List<ChunkReference>();
|
||||
foreach(RawChunkReference rawRef in ForgottenChunks)
|
||||
{
|
||||
if(rawRef.planeName as string != plane.Name)
|
||||
throw new InvalidDataException($"Error: A raw reference was for the plane " +
|
||||
"'{rawRef.planeName}', but the plane '{plane.Name}' " +
|
||||
"was specified as the plane to lay the chunk references onto!");
|
||||
|
||||
result.Add(new ChunkReference(plane, rawRef.x, rawRef.y));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -354,7 +354,7 @@ namespace Nibriboard.Client
|
|||
/// <param name="message">The message to process.</param>
|
||||
protected async Task handleChunkUpdateRequestMessage(ChunkUpdateRequestMessage message)
|
||||
{
|
||||
chunkCache.Remove(message.ForgottenChunks);
|
||||
chunkCache.Remove(message.ForgottenChunksAsReferences(this.CurrentPlane));
|
||||
|
||||
ChunkUpdateMessage response = new ChunkUpdateMessage();
|
||||
List<ChunkReference> missingChunks = ChunkTools.GetContainingChunkReferences(CurrentPlane, CurrentViewPort);
|
||||
|
|
|
@ -100,6 +100,7 @@
|
|||
<Compile Include="Client\Messages\LineCompleteMessage.cs" />
|
||||
<Compile Include="Client\Messages\ErrorMessage.cs" />
|
||||
<Compile Include="Client\Messages\PlaneChangeOkMessage.cs" />
|
||||
<Compile Include="Client\RawChunkReference.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="ClientFiles\index.html" />
|
||||
|
|
Loading…
Reference in a new issue