From 08f71f11dc94f67e00d40290d103b510ab17c645 Mon Sep 17 00:00:00 2001
From: Andrew Kelley <superjoe30@gmail.com>
Date: Sat, 5 Jan 2013 16:51:42 -0500
Subject: [PATCH] add chunkCount to 0x38

changed some more things for more API consistency

 * 0x33: compressedData -> compressedChunkData
 * 0x38: meta.chunkX -> meta.x
 * 0x38: meta.chunkZ -> meta.z
 * 0x38: meta.primaryBitMap -> meta.bitMap
 * 0x38: add chunkCount
---
 lib/protocol.js | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/lib/protocol.js b/lib/protocol.js
index 6e2d12a..2adac4f 100644
--- a/lib/protocol.js
+++ b/lib/protocol.js
@@ -264,7 +264,7 @@ var packets = {
     { name: "groundUp", type: "bool" },
     { name: "bitMap", type: "ushort" },
     { name: "addBitMap", type: "ushort" },
-    { name: "compressedData", type: "byteArray32" }
+    { name: "compressedChunkData", type: "byteArray32" }
   ],
   0x34: [
     { name: "chunkX", type: "int" },
@@ -635,21 +635,21 @@ function readMapChunkBulk (buffer, offset) {
   cursor = compressedChunkDataEnd;
 
   var meta = [];
-  var i, chunkX, chunkZ, primaryBitMap, addBitMap;
+  var i, chunkX, chunkZ, bitMap, addBitMap;
   for (i = 0; i < chunkCount; ++i) {
     chunkX = buffer.readInt32BE(cursor);
     cursor += 4;
     chunkZ = buffer.readInt32BE(cursor);
     cursor += 4;
-    primaryBitMap = buffer.readUInt16BE(cursor);
+    bitMap = buffer.readUInt16BE(cursor);
     cursor += 2;
     addBitMap = buffer.readUInt16BE(cursor);
     cursor += 2;
 
     meta.push({
-      chunkX: chunkX,
-      chunkZ: chunkZ,
-      primaryBitMap: primaryBitMap,
+      x: chunkX,
+      z: chunkZ,
+      bitMap: bitMap,
       addBitMap: addBitMap,
     });
   }
@@ -657,6 +657,7 @@ function readMapChunkBulk (buffer, offset) {
   return {
     value: {
       skyLightSent: skyLightSent,
+      chunkCount: chunkCount,
       compressedChunkData: compressedChunkData,
       meta: meta,
     },