1
0
Fork 0

Start work on the chunk update request handling.

There's a thorny issue with deserialising into ChunkReference in the server.... that should be fun to solve. I'll have to do some head scratching\!
This commit is contained in:
Starbeamrainbowlabs 2017-06-23 21:32:29 +01:00
parent 1935f6350e
commit 334acdbc18
2 changed files with 16 additions and 2 deletions

View File

@ -10,7 +10,7 @@ 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<ChunkReference> ForgottenChunks = new List<ChunkReference>();
public List<dynamic> ForgottenChunks = new List<dynamic>();
public ChunkUpdateRequestMessage()
{

View File

@ -40,13 +40,27 @@ class ChunkCache
let chunkSize = this.boardWindow.gridSize;
let chunkArea = this.CalculateChunkArea(visibleArea, chunkSize);
// Collect a list of missing chunks
let missingChunks = [];
for(let cx = chunkArea.x; cx <= chunkArea.x + chunkArea.width; cx += chunkSize)
{
for(let cy = chunkArea.y; cy <= chunkArea.y + chunkArea.height; cy += chunkSize)
{
let cChunk = new ChunkReference(
this.boardWindow.currentPlaneName,
cx / chunkSize, cy / chunkSize
);
if(!this.cache.has(cChunk)) {
missingChunks.push(cChunk);
}
}
}
// Asynchronously request them from the server
this.boardWindow.rippleLink.send({
"Event": "ChunkUpdateRequest",
"ForgottenChunks": missingChunks
})
}
/**