From 95bacd4bfd2b68b0084c3e3b186e796838223a20 Mon Sep 17 00:00:00 2001 From: Luke Young Date: Tue, 13 May 2014 23:42:13 -0500 Subject: [PATCH 1/3] Fix team scoreboard Because the team scoreboard values are optional, they should not always be included in the written response. --- lib/protocol.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/protocol.js b/lib/protocol.js index 4296cab..1040435 100644 --- a/lib/protocol.js +++ b/lib/protocol.js @@ -1275,8 +1275,10 @@ function createPacketBuffer(packetId, state, params, isServer) { offset = writeVarInt(packetId, buffer, offset); packet.forEach(function(fieldInfo) { var value = params[fieldInfo.name]; - if(typeof value === "undefined") value = 0; // TODO : Why ? - offset = write(value, buffer, offset, fieldInfo, params); + if (!fieldInfo.condition || fieldInfo.condition(params)) { + if(typeof value === "undefined") value = 0; // TODO : Why ? + offset = write(value, buffer, offset, fieldInfo, params); + } }); return buffer; } From 5f349d338d6210b663a2e9fd72107d95851e0c90 Mon Sep 17 00:00:00 2001 From: Luke Young Date: Wed, 14 May 2014 13:45:46 -0500 Subject: [PATCH 2/3] Revert "Fix team scoreboard" This reverts commit 95bacd4bfd2b68b0084c3e3b186e796838223a20. --- lib/protocol.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/protocol.js b/lib/protocol.js index 1040435..4296cab 100644 --- a/lib/protocol.js +++ b/lib/protocol.js @@ -1275,10 +1275,8 @@ function createPacketBuffer(packetId, state, params, isServer) { offset = writeVarInt(packetId, buffer, offset); packet.forEach(function(fieldInfo) { var value = params[fieldInfo.name]; - if (!fieldInfo.condition || fieldInfo.condition(params)) { - if(typeof value === "undefined") value = 0; // TODO : Why ? - offset = write(value, buffer, offset, fieldInfo, params); - } + if(typeof value === "undefined") value = 0; // TODO : Why ? + offset = write(value, buffer, offset, fieldInfo, params); }); return buffer; } From 61b7a0c20a6a264d5e08865fced6f12f4e85a163 Mon Sep 17 00:00:00 2001 From: Luke Young Date: Wed, 14 May 2014 13:46:29 -0500 Subject: [PATCH 3/3] Better condition fix --- lib/protocol.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/protocol.js b/lib/protocol.js index 4296cab..ee49cdb 100644 --- a/lib/protocol.js +++ b/lib/protocol.js @@ -1218,7 +1218,7 @@ function read(buffer, cursor, fieldInfo, rootNodes) { function write(value, buffer, offset, fieldInfo, rootNode) { if (fieldInfo.condition && !fieldInfo.condition(rootNode)) { - return null; + return offset; } var type = types[fieldInfo.type]; if (!type) {