fix incorrectly swapped stance and y on 0x0d

add test that would have caught the bug
This commit is contained in:
Andrew Kelley 2013-01-10 20:34:56 -05:00
parent af98e294f8
commit 5a85aa454f
2 changed files with 5 additions and 2 deletions

View file

@ -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) {

View file

@ -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");
});
});
});
});