diff --git a/lib/protocol.js b/lib/protocol.js index 2adac4f..4684e1e 100644 --- a/lib/protocol.js +++ b/lib/protocol.js @@ -623,11 +623,11 @@ function readObjectData(buffer, offset) { function readMapChunkBulk (buffer, offset) { var cursor = offset + 7; if (cursor > buffer.length) return null; - var chunkCount = buffer.readInt16BE(offset); + var chunkColumnCount = buffer.readInt16BE(offset); var dataSize = buffer.readInt32BE(offset + 2); var skyLightSent = !!buffer.readInt8(offset + 6); - var cursorEnd = cursor + dataSize + 12 * chunkCount; + var cursorEnd = cursor + dataSize + 12 * chunkColumnCount; if (cursorEnd > buffer.length) return null; var compressedChunkDataEnd = cursor + dataSize; @@ -636,7 +636,7 @@ function readMapChunkBulk (buffer, offset) { var meta = []; var i, chunkX, chunkZ, bitMap, addBitMap; - for (i = 0; i < chunkCount; ++i) { + for (i = 0; i < chunkColumnCount; ++i) { chunkX = buffer.readInt32BE(cursor); cursor += 4; chunkZ = buffer.readInt32BE(cursor); @@ -654,10 +654,11 @@ function readMapChunkBulk (buffer, offset) { }); } + assert.strictEqual(chunkColumnCount, meta.length); + return { value: { skyLightSent: skyLightSent, - chunkCount: chunkCount, compressedChunkData: compressedChunkData, meta: meta, },