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

@@ -26,4 +26,58 @@ export class SetStartLocationPacket implements Packet
return 68;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
this.StartLocationData['AgentID'].writeToBuffer(buf, pos);
pos += 16;
this.StartLocationData['RegionID'].writeToBuffer(buf, pos);
pos += 16;
buf.writeUInt32LE(this.StartLocationData['LocationID'], pos);
pos += 4;
buf.writeInt32LE(this.StartLocationData['RegionHandle'].low, pos);
pos += 4;
buf.writeInt32LE(this.StartLocationData['RegionHandle'].high, pos);
pos += 4;
this.StartLocationData['LocationPos'].writeToBuffer(buf, pos, false);
pos += 12;
this.StartLocationData['LocationLookAt'].writeToBuffer(buf, pos, false);
pos += 12;
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
const newObjStartLocationData: {
AgentID: UUID,
RegionID: UUID,
LocationID: number,
RegionHandle: Long,
LocationPos: Vector3,
LocationLookAt: Vector3
} = {
AgentID: UUID.zero(),
RegionID: UUID.zero(),
LocationID: 0,
RegionHandle: Long.ZERO,
LocationPos: Vector3.getZero(),
LocationLookAt: Vector3.getZero()
};
newObjStartLocationData['AgentID'] = new UUID(buf, pos);
pos += 16;
newObjStartLocationData['RegionID'] = new UUID(buf, pos);
pos += 16;
newObjStartLocationData['LocationID'] = buf.readUInt32LE(pos);
pos += 4;
newObjStartLocationData['RegionHandle'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4));
pos += 8;
newObjStartLocationData['LocationPos'] = new Vector3(buf, pos, false);
pos += 12;
newObjStartLocationData['LocationLookAt'] = new Vector3(buf, pos, false);
pos += 12;
this.StartLocationData = newObjStartLocationData;
return pos - startPos;
}
}