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 SimCrashedPacket implements Packet
return ((16) * this.Users.length) + 9;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
buf.writeUInt32LE(this.Data['RegionX'], pos);
pos += 4;
buf.writeUInt32LE(this.Data['RegionY'], pos);
pos += 4;
const count = this.Users.length;
buf.writeUInt8(this.Users.length, pos++);
for (let i = 0; i < count; i++)
{
this.Users[i]['AgentID'].writeToBuffer(buf, pos);
pos += 16;
}
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
const newObjData: {
RegionX: number,
RegionY: number
} = {
RegionX: 0,
RegionY: 0
};
newObjData['RegionX'] = buf.readUInt32LE(pos);
pos += 4;
newObjData['RegionY'] = buf.readUInt32LE(pos);
pos += 4;
this.Data = newObjData;
const count = buf.readUInt8(pos++);
this.Users = [];
for (let i = 0; i < count; i++)
{
const newObjUsers: {
AgentID: UUID
} = {
AgentID: UUID.zero()
};
newObjUsers['AgentID'] = new UUID(buf, pos);
pos += 16;
this.Users.push(newObjUsers);
}
return pos - startPos;
}
}