merge chunk updates

This commit is contained in:
sebseb7
2026-05-21 09:14:47 +02:00
parent fe1d362ea7
commit bf2bed5599
14 changed files with 591 additions and 76 deletions

View File

@@ -283,17 +283,17 @@ Master coordinator for world cache segments. Integrates and clears sub-caches on
#### 🧩 [ChunkCache](file:///home/seb/flayerproxy/src/state/ChunkCache.js) `class`
Manages loaded map chunks, light maps, and block overlays using an LRU cache.
Manages loaded map chunks using an LRU cache; block and light updates are merged into chunk columns.
| Method | Description |
|---|---|
| `constructor(maxChunks)` | Initializes chunk storage with LRU capacity limit. |
| `_key(x, z)` | Computes string key for map lookups. |
| `handleMapChunk(data, rawBuffer)` | Caches chunk data and marks it as active in the LRU tracking queue. |
| `handleUpdateLight(data, rawBuffer)` | Caches light updates. |
| `handleUpdateLight(data)` | Merges light updates into the cached chunk column. |
| `handleUnloadChunk(data)` | Evicts chunk records from cache. |
| `handleBlockChange(data)` | Appends single block changes as an overlay. |
| `handleMultiBlockChange(data)` | Appends multiblock edits as an overlay. |
| `handleBlockChange(data)` | Merges single block changes into the cached chunk column. |
| `handleMultiBlockChange(data)` | Merges section block updates into the cached chunk column. |
| `_buildChunkEntry(chunkData)` | Assembles raw data, block edits, and light arrays. |
| `getChunksForReplay(centerChunkX, centerChunkZ, viewDistance)` | Returns cached chunks sorting closest-first. |
| `hasChunkAtBlock(x, z)` | Verifies if a chunk is loaded. |
@@ -459,7 +459,7 @@ Replays the cached world state to a connecting client.
| Function | Description |
|---|---|
| `replayChunks(write, writeRaw, chunks, center, totalCached)` | Loops through chunk arrays, sending raw chunk/light buffers and block overlay edits, and issues a final `chunk_batch_finished` packet. |
| `replayChunks(write, writeRaw, chunks, center, totalCached)` | Loops through chunk arrays, sending map_chunk buffers (block/light edits already merged), and issues a final `chunk_batch_finished` packet. |
#### 📄 [replayHelpers.js](file:///home/seb/flayerproxy/src/replay/replayHelpers.js) `functions`