Latest packet handling, parsing, enums, generators, etc..

This commit is contained in:
Casper Warden
2017-11-24 17:45:34 +00:00
parent ec300e33ac
commit 261f28698a
496 changed files with 30448 additions and 57 deletions

View File

@@ -23,4 +23,52 @@ export class PayPriceReplyPacket implements Packet
return ((4) * this.ButtonData.length) + 21;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
this.ObjectData['ObjectID'].writeToBuffer(buf, pos);
pos += 16;
buf.writeInt32LE(this.ObjectData['DefaultPayPrice'], pos);
pos += 4;
const count = this.ButtonData.length;
buf.writeUInt8(this.ButtonData.length, pos++);
for (let i = 0; i < count; i++)
{
buf.writeInt32LE(this.ButtonData[i]['PayButton'], pos);
pos += 4;
}
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
const newObjObjectData: {
ObjectID: UUID,
DefaultPayPrice: number
} = {
ObjectID: UUID.zero(),
DefaultPayPrice: 0
};
newObjObjectData['ObjectID'] = new UUID(buf, pos);
pos += 16;
newObjObjectData['DefaultPayPrice'] = buf.readInt32LE(pos);
pos += 4;
this.ObjectData = newObjObjectData;
const count = buf.readUInt8(pos++);
this.ButtonData = [];
for (let i = 0; i < count; i++)
{
const newObjButtonData: {
PayButton: number
} = {
PayButton: 0
};
newObjButtonData['PayButton'] = buf.readInt32LE(pos);
pos += 4;
this.ButtonData.push(newObjButtonData);
}
return pos - startPos;
}
}