Revert "Add some debug information (useful to update to an updated protocol)"

This reverts commit d2435c8dcdf6de9441a38cf7f605fbda691359be.
This commit is contained in:
Romain Beaumont 2015-08-05 23:30:04 +02:00
parent d2435c8dcd
commit 5743cd8b64
5 changed files with 16 additions and 51 deletions

View File

@ -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)
{

View File

@ -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;
}
return offset + size;
};
return [reader, writer, size];

View File

@ -84,17 +84,8 @@ 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;
}
}
rootNode.this = backupThis;;
return offset;
}

View File

@ -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);
};

View File

@ -89,19 +89,7 @@ function createPacketBuffer(packetId, state, params, isServer) {
// 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;
}
});
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;
}
/* A deserializer cannot return null anymore. Besides, proto.read() returns
* null when the condition is not fulfilled.
if (!!!readResults) {