From 5a85aa454f248b04a7d44969b0ef3e29ebe5ae1a Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 10 Jan 2013 20:34:56 -0500 Subject: [PATCH] fix incorrectly swapped stance and y on 0x0d add test that would have caught the bug --- lib/protocol.js | 4 ++-- test/test.js | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/protocol.js b/lib/protocol.js index 0d2f984..b660973 100644 --- a/lib/protocol.js +++ b/lib/protocol.js @@ -1173,7 +1173,7 @@ function get(packetId, toServer) { function createPacketBuffer(packetId, params, isServer) { var size = 1; var fields = [ new UByteWriter(packetId) ]; - var packet = get(packetId, isServer); + var packet = get(packetId, !isServer); packet.forEach(function(fieldInfo) { var value = params[fieldInfo.name]; var Writer = types[fieldInfo.type][1]; @@ -1196,7 +1196,7 @@ function parsePacket(buffer, isServer) { var packetId = buffer.readUInt8(0); var size = 1; var results = { id: packetId }; - var packetInfo = get(packetId, !isServer); + var packetInfo = get(packetId, isServer); assert.ok(packetInfo, "Unrecognized packetId: " + packetId); var i, fieldInfo, read, readResults; for (i = 0; i < packetInfo.length; ++i) { diff --git a/test/test.js b/test/test.js index ee24f41..9b401b3 100644 --- a/test/test.js +++ b/test/test.js @@ -359,6 +359,9 @@ describe("client", function() { done(); }, SURVIVE_TIME); }); + client.on(0x0d, function(packet) { + assert.ok(packet.stance > packet.y, "stance should be > y"); + }); }); }); });