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

@@ -22,4 +22,44 @@ export class EstateCovenantReplyPacket implements Packet
return (this.Data['EstateName'].length + 1) + 36;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
this.Data['CovenantID'].writeToBuffer(buf, pos);
pos += 16;
buf.writeUInt32LE(this.Data['CovenantTimestamp'], pos);
pos += 4;
buf.write(this.Data['EstateName'], pos);
pos += this.Data['EstateName'].length;
this.Data['EstateOwnerID'].writeToBuffer(buf, pos);
pos += 16;
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
const newObjData: {
CovenantID: UUID,
CovenantTimestamp: number,
EstateName: string,
EstateOwnerID: UUID
} = {
CovenantID: UUID.zero(),
CovenantTimestamp: 0,
EstateName: '',
EstateOwnerID: UUID.zero()
};
newObjData['CovenantID'] = new UUID(buf, pos);
pos += 16;
newObjData['CovenantTimestamp'] = buf.readUInt32LE(pos);
pos += 4;
newObjData['EstateName'] = buf.toString('utf8', pos, length);
pos += length;
newObjData['EstateOwnerID'] = new UUID(buf, pos);
pos += 16;
this.Data = newObjData;
return pos - startPos;
}
}