fix modtools

This commit is contained in:
HF 2022-09-11 14:20:40 +02:00
parent 93e756cf15
commit 3946614b3a
3 changed files with 7 additions and 9 deletions

View File

@ -129,9 +129,8 @@ class MessageBroker extends SocketEvents {
}
onShardBinaryMessage(buffer, shard) {
if (buffer.byteLength === 0) return;
const opcode = buffer[0];
try {
const opcode = buffer[0];
switch (opcode) {
case PixelUpdateMB.OP_CODE: {
const puData = PixelUpdateMB.hydrate(buffer);

View File

@ -471,10 +471,8 @@ class SocketServer {
}
async onBinaryMessage(buffer, ws) {
if (buffer.byteLength === 0) return;
const opcode = buffer[0];
try {
const opcode = buffer[0];
switch (opcode) {
case PixelUpdate.OP_CODE: {
const { canvasId, user } = ws;

View File

@ -12,19 +12,20 @@ export default {
*/
hydrate(data) {
const canvasId = data[1];
const chunk = [data[2], data[3]];
return [canvasId, chunk];
const i = data.readUInt8(2);
const j = data.readUInt8(3);
return [canvasId, [i, j]];
},
/*
* @param canvasId,
* chunkid id consisting of chunk coordinates
*/
dehydrate(canvasId, [i, j]) {
return Buffer.from({
return Buffer.from([
OP_CODE,
canvasId,
i,
j,
});
]);
},
};