mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-29 14:13:45 -04:00
TypeArgs should default to an empty object in case it is undefined
This commit is contained in:
parent
f91da617d7
commit
3d6db80593
@ -20,7 +20,8 @@ NMProtocols.prototype.read = function(buffer, cursor, fieldInfo, rootNodes) {
|
|||||||
error: new Error("missing data type: " + fieldInfo.type)
|
error: new Error("missing data type: " + fieldInfo.type)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var readResults = type[0].call(this, buffer, cursor, fieldInfo.typeArgs, rootNodes);
|
var typeArgs = fieldInfo.typeArgs || {};
|
||||||
|
var readResults = type[0].call(this, buffer, cursor, typeArgs, rootNodes);
|
||||||
if(readResults == null) {
|
if(readResults == null) {
|
||||||
throw new Error("Reader returned null : " + JSON.stringify(fieldInfo));
|
throw new Error("Reader returned null : " + JSON.stringify(fieldInfo));
|
||||||
}
|
}
|
||||||
@ -35,7 +36,8 @@ NMProtocols.prototype.write = function(value, buffer, offset, fieldInfo, rootNod
|
|||||||
error: new Error("missing data type: " + fieldInfo.type)
|
error: new Error("missing data type: " + fieldInfo.type)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return type[1].call(this, value, buffer, offset, fieldInfo.typeArgs, rootNode);
|
var typeArgs = fieldInfo.typeArgs || {};
|
||||||
|
return type[1].call(this, value, buffer, offset, typeArgs, rootNode);
|
||||||
};
|
};
|
||||||
|
|
||||||
NMProtocols.prototype.sizeOf = function(value, fieldInfo, rootNode) {
|
NMProtocols.prototype.sizeOf = function(value, fieldInfo, rootNode) {
|
||||||
@ -44,7 +46,8 @@ NMProtocols.prototype.sizeOf = function(value, fieldInfo, rootNode) {
|
|||||||
throw new Error("missing data type: " + fieldInfo.type);
|
throw new Error("missing data type: " + fieldInfo.type);
|
||||||
}
|
}
|
||||||
if(typeof type[2] === 'function') {
|
if(typeof type[2] === 'function') {
|
||||||
return type[2].call(this, value, fieldInfo.typeArgs, rootNode);
|
var typeArgs = fieldInfo.typeArgs || {};
|
||||||
|
return type[2].call(this, value, typeArgs, rootNode);
|
||||||
} else {
|
} else {
|
||||||
return type[2];
|
return type[2];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user