mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-29 06:03:33 -04:00
Merge pull request #76 from danny8376/somefix
fix chat problem with multi-byte characters
This commit is contained in:
commit
36b57663b6
19
lib/protocol.js
Normal file → Executable file
19
lib/protocol.js
Normal file → Executable file
@ -470,7 +470,7 @@ var packets = {
|
|||||||
],
|
],
|
||||||
0x02: [
|
0x02: [
|
||||||
{ name: "target", type: "int" },
|
{ name: "target", type: "int" },
|
||||||
{ name: "leftClick", type: "byte" }
|
{ name: "mouse", type: "byte" }
|
||||||
],
|
],
|
||||||
0x03: [
|
0x03: [
|
||||||
{ name: "onGround", type: "bool" }
|
{ name: "onGround", type: "bool" }
|
||||||
@ -1352,19 +1352,22 @@ function writeSlot(value, buffer, offset) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sizeOfString(value) {
|
function sizeOfString(value) {
|
||||||
assert.ok(value.length < STRING_MAX_LENGTH, "string greater than max length");
|
var length = Buffer.byteLength(value, 'utf8');
|
||||||
return sizeOfVarInt(value.length) + value.length;
|
assert.ok(length < STRING_MAX_LENGTH, "string greater than max length");
|
||||||
|
return sizeOfVarInt(length) + length;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sizeOfUString(value) {
|
function sizeOfUString(value) {
|
||||||
assert.ok(value.length < SRV_STRING_MAX_LENGTH, "string greater than max length");
|
var length = Buffer.byteLength(value, 'utf8');
|
||||||
return sizeOfVarInt(value.length) + value.length;
|
assert.ok(length < SRV_STRING_MAX_LENGTH, "string greater than max length");
|
||||||
|
return sizeOfVarInt(length) + length;
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeString(value, buffer, offset) {
|
function writeString(value, buffer, offset) {
|
||||||
offset = writeVarInt(value.length, buffer, offset);
|
var length = Buffer.byteLength(value, 'utf8');
|
||||||
buffer.write(value, offset, value.length, 'utf8');
|
offset = writeVarInt(length, buffer, offset);
|
||||||
return offset + value.length;
|
buffer.write(value, offset, length, 'utf8');
|
||||||
|
return offset + length;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sizeOfAscii(value) {
|
function sizeOfAscii(value) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user