mirror of
https://github.com/sbrl/Nibriboard.git
synced 2018-01-10 21:33:49 +00:00
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:
parent
1935f6350e
commit
334acdbc18
2 changed files with 16 additions and 2 deletions
|
@ -10,7 +10,7 @@ namespace Nibriboard.Client.Messages
|
||||||
/// A list of chunks that the client has intentionally forgotten about, and will need
|
/// A list of chunks that the client has intentionally forgotten about, and will need
|
||||||
/// to be resent to the client.
|
/// to be resent to the client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ChunkReference> ForgottenChunks = new List<ChunkReference>();
|
public List<dynamic> ForgottenChunks = new List<dynamic>();
|
||||||
|
|
||||||
public ChunkUpdateRequestMessage()
|
public ChunkUpdateRequestMessage()
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,13 +40,27 @@ class ChunkCache
|
||||||
let chunkSize = this.boardWindow.gridSize;
|
let chunkSize = this.boardWindow.gridSize;
|
||||||
let chunkArea = this.CalculateChunkArea(visibleArea, chunkSize);
|
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 cx = chunkArea.x; cx <= chunkArea.x + chunkArea.width; cx += chunkSize)
|
||||||
{
|
{
|
||||||
for(let cy = chunkArea.y; cy <= chunkArea.y + chunkArea.height; cy += 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
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue