mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-28 13:45:37 -04:00
Revert "Add some debug information (useful to update to an updated protocol)"
This reverts commit d2435c8dcdf6de9441a38cf7f605fbda691359be.
This commit is contained in:
parent
d2435c8dcd
commit
5743cd8b64
@ -140,8 +140,6 @@ srv.on('login', function(client) {
|
|||||||
console.log("client<-server: Error in packetId " + state + ".0x" + packetId.value.toString(16));
|
console.log("client<-server: Error in packetId " + state + ".0x" + packetId.value.toString(16));
|
||||||
console.log(buffer.toString('hex'));
|
console.log(buffer.toString('hex'));
|
||||||
console.log(packetBuff.toString('hex'));
|
console.log(packetBuff.toString('hex'));
|
||||||
console.log(buffer.length);
|
|
||||||
console.log(packetBuff.length);
|
|
||||||
}
|
}
|
||||||
/*if (client.state == states.PLAY && brokenPackets.indexOf(packetId.value) !== -1)
|
/*if (client.state == states.PLAY && brokenPackets.indexOf(packetId.value) !== -1)
|
||||||
{
|
{
|
||||||
|
@ -24,14 +24,7 @@ function generateFunctions(bufferReader,bufferWriter,size)
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
var writer=function(value, buffer, offset) {
|
var writer=function(value, buffer, offset) {
|
||||||
try {
|
buffer[bufferWriter](value, offset);
|
||||||
buffer[bufferWriter](value, offset);
|
|
||||||
}
|
|
||||||
catch(err)
|
|
||||||
{
|
|
||||||
console.log("value:"+ value);
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
return offset + size;
|
return offset + size;
|
||||||
};
|
};
|
||||||
return [reader, writer, size];
|
return [reader, writer, size];
|
||||||
|
@ -84,16 +84,7 @@ function writeContainer(value, buffer, offset, typeArgs, rootNode) {
|
|||||||
debug(new Error("Missing Property " + typeArgs.fields[index].name).stack);
|
debug(new Error("Missing Property " + typeArgs.fields[index].name).stack);
|
||||||
console.log(context);
|
console.log(context);
|
||||||
}
|
}
|
||||||
try {
|
offset = this.write(context[typeArgs.fields[index].name], buffer, offset, typeArgs.fields[index], rootNode);
|
||||||
offset = this.write(context[typeArgs.fields[index].name], buffer, offset, typeArgs.fields[index], rootNode);
|
|
||||||
}
|
|
||||||
catch(err)
|
|
||||||
{
|
|
||||||
console.log("typeArgs : " + JSON.stringify(typeArgs.fields[index]));
|
|
||||||
console.log("context : "+JSON.stringify(context));
|
|
||||||
console.log("value : " + JSON.stringify(context[typeArgs.fields[index].name]));
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
rootNode.this = backupThis;;
|
rootNode.this = backupThis;;
|
||||||
return offset;
|
return offset;
|
||||||
|
@ -16,7 +16,9 @@ NMProtocols.prototype.addTypes = function(types) {
|
|||||||
NMProtocols.prototype.read = function(buffer, cursor, fieldInfo, rootNodes) {
|
NMProtocols.prototype.read = function(buffer, cursor, fieldInfo, rootNodes) {
|
||||||
var type = this.types[fieldInfo.type];
|
var type = this.types[fieldInfo.type];
|
||||||
if(!type) {
|
if(!type) {
|
||||||
throw new Error("missing data type: " + fieldInfo.type);
|
return {
|
||||||
|
error: new Error("missing data type: " + fieldInfo.type)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
var readResults = type[0].call(this, buffer, cursor, fieldInfo.typeArgs, rootNodes);
|
var readResults = type[0].call(this, buffer, cursor, fieldInfo.typeArgs, rootNodes);
|
||||||
if(readResults == null) {
|
if(readResults == null) {
|
||||||
@ -29,7 +31,9 @@ NMProtocols.prototype.read = function(buffer, cursor, fieldInfo, rootNodes) {
|
|||||||
NMProtocols.prototype.write = function(value, buffer, offset, fieldInfo, rootNode) {
|
NMProtocols.prototype.write = function(value, buffer, offset, fieldInfo, rootNode) {
|
||||||
var type = this.types[fieldInfo.type];
|
var type = this.types[fieldInfo.type];
|
||||||
if(!type) {
|
if(!type) {
|
||||||
throw new Error("missing data type: " + fieldInfo.type);
|
return {
|
||||||
|
error: new Error("missing data type: " + fieldInfo.type)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return type[1].call(this, value, buffer, offset, fieldInfo.typeArgs, rootNode);
|
return type[1].call(this, value, buffer, offset, fieldInfo.typeArgs, rootNode);
|
||||||
};
|
};
|
||||||
|
@ -84,25 +84,13 @@ function createPacketBuffer(packetId, state, params, isServer) {
|
|||||||
var buffer = new Buffer(size);
|
var buffer = new Buffer(size);
|
||||||
var offset = 0;//utils.varint[1](length, buffer, 0);
|
var offset = 0;//utils.varint[1](length, buffer, 0);
|
||||||
offset = utils.varint[1](packetId, buffer, offset);
|
offset = utils.varint[1](packetId, buffer, offset);
|
||||||
packet.forEach(function(fieldInfo) {
|
packet.forEach(function(fieldInfo) {
|
||||||
var value = params[fieldInfo.name];
|
var value = params[fieldInfo.name];
|
||||||
// TODO : A better check is probably needed
|
// TODO : A better check is probably needed
|
||||||
if(typeof value === "undefined" && fieldInfo.type != "count" && (fieldInfo.type != "condition" || evalCondition(fieldInfo.typeArgs, params)))
|
if(typeof value === "undefined" && fieldInfo.type != "count" && (fieldInfo.type != "condition" || evalCondition(fieldInfo.typeArgs, params)))
|
||||||
debug(new Error("Missing Property " + fieldInfo.name).stack);
|
debug(new Error("Missing Property " + fieldInfo.name).stack);
|
||||||
|
offset = proto.write(value, buffer, offset, fieldInfo, params);
|
||||||
try {
|
});
|
||||||
offset = proto.write(value, buffer, offset, fieldInfo, params);
|
|
||||||
}
|
|
||||||
catch(err)
|
|
||||||
{
|
|
||||||
console.log("Error in creating packet 0x"+packetId.toString(16)+" with params "+JSON.stringify(params));
|
|
||||||
console.log("In particular :");
|
|
||||||
|
|
||||||
console.log("fieldInfo : " + JSON.stringify(fieldInfo));
|
|
||||||
console.log("value : " + JSON.stringify(value));
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,16 +139,7 @@ function parsePacketData(buffer, state, isServer, packetsToParse = {"packet": tr
|
|||||||
var i, fieldInfo, readResults;
|
var i, fieldInfo, readResults;
|
||||||
for(i = 0; i < packetInfo.length; ++i) {
|
for(i = 0; i < packetInfo.length; ++i) {
|
||||||
fieldInfo = packetInfo[i];
|
fieldInfo = packetInfo[i];
|
||||||
try {
|
readResults = proto.read(buffer, cursor, fieldInfo, results);
|
||||||
readResults = proto.read(buffer, cursor, fieldInfo, results);
|
|
||||||
}
|
|
||||||
catch(err) {
|
|
||||||
console.log("Error in parsing packet 0x" + packetId.toString(16));
|
|
||||||
console.log("In particular :");
|
|
||||||
|
|
||||||
console.log("fieldInfo : " + JSON.stringify(fieldInfo));
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
/* A deserializer cannot return null anymore. Besides, proto.read() returns
|
/* A deserializer cannot return null anymore. Besides, proto.read() returns
|
||||||
* null when the condition is not fulfilled.
|
* null when the condition is not fulfilled.
|
||||||
if (!!!readResults) {
|
if (!!!readResults) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user