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(buffer.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)
|
||||
{
|
||||
|
@ -24,14 +24,7 @@ function generateFunctions(bufferReader,bufferWriter,size)
|
||||
};
|
||||
};
|
||||
var writer=function(value, buffer, offset) {
|
||||
try {
|
||||
buffer[bufferWriter](value, offset);
|
||||
}
|
||||
catch(err)
|
||||
{
|
||||
console.log("value:"+ value);
|
||||
throw err;
|
||||
}
|
||||
buffer[bufferWriter](value, offset);
|
||||
return offset + 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);
|
||||
console.log(context);
|
||||
}
|
||||
try {
|
||||
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;
|
||||
}
|
||||
offset = this.write(context[typeArgs.fields[index].name], buffer, offset, typeArgs.fields[index], rootNode);
|
||||
}
|
||||
rootNode.this = backupThis;;
|
||||
return offset;
|
||||
|
@ -16,7 +16,9 @@ NMProtocols.prototype.addTypes = function(types) {
|
||||
NMProtocols.prototype.read = function(buffer, cursor, fieldInfo, rootNodes) {
|
||||
var type = this.types[fieldInfo.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);
|
||||
if(readResults == null) {
|
||||
@ -29,7 +31,9 @@ NMProtocols.prototype.read = function(buffer, cursor, fieldInfo, rootNodes) {
|
||||
NMProtocols.prototype.write = function(value, buffer, offset, fieldInfo, rootNode) {
|
||||
var type = this.types[fieldInfo.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);
|
||||
};
|
||||
|
@ -84,25 +84,13 @@ function createPacketBuffer(packetId, state, params, isServer) {
|
||||
var buffer = new Buffer(size);
|
||||
var offset = 0;//utils.varint[1](length, buffer, 0);
|
||||
offset = utils.varint[1](packetId, buffer, offset);
|
||||
packet.forEach(function(fieldInfo) {
|
||||
var value = params[fieldInfo.name];
|
||||
// TODO : A better check is probably needed
|
||||
if(typeof value === "undefined" && fieldInfo.type != "count" && (fieldInfo.type != "condition" || evalCondition(fieldInfo.typeArgs, params)))
|
||||
debug(new Error("Missing Property " + fieldInfo.name).stack);
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
packet.forEach(function(fieldInfo) {
|
||||
var value = params[fieldInfo.name];
|
||||
// TODO : A better check is probably needed
|
||||
if(typeof value === "undefined" && fieldInfo.type != "count" && (fieldInfo.type != "condition" || evalCondition(fieldInfo.typeArgs, params)))
|
||||
debug(new Error("Missing Property " + fieldInfo.name).stack);
|
||||
offset = proto.write(value, buffer, offset, fieldInfo, params);
|
||||
});
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@ -151,16 +139,7 @@ function parsePacketData(buffer, state, isServer, packetsToParse = {"packet": tr
|
||||
var i, fieldInfo, readResults;
|
||||
for(i = 0; i < packetInfo.length; ++i) {
|
||||
fieldInfo = packetInfo[i];
|
||||
try {
|
||||
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;
|
||||
}
|
||||
readResults = proto.read(buffer, cursor, fieldInfo, results);
|
||||
/* A deserializer cannot return null anymore. Besides, proto.read() returns
|
||||
* null when the condition is not fulfilled.
|
||||
if (!!!readResults) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user