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

@@ -33,4 +33,78 @@ export class CrossedRegionPacket implements Packet
return (this.RegionData['SeedCapability'].length + 2) + 70;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
this.AgentData['AgentID'].writeToBuffer(buf, pos);
pos += 16;
this.AgentData['SessionID'].writeToBuffer(buf, pos);
pos += 16;
this.RegionData['SimIP'].writeToBuffer(buf, pos);
pos += 4;
buf.writeUInt16LE(this.RegionData['SimPort'], pos);
pos += 2;
buf.writeInt32LE(this.RegionData['RegionHandle'].low, pos);
pos += 4;
buf.writeInt32LE(this.RegionData['RegionHandle'].high, pos);
pos += 4;
buf.write(this.RegionData['SeedCapability'], pos);
pos += this.RegionData['SeedCapability'].length;
this.Info['Position'].writeToBuffer(buf, pos, false);
pos += 12;
this.Info['LookAt'].writeToBuffer(buf, pos, false);
pos += 12;
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
const newObjAgentData: {
AgentID: UUID,
SessionID: UUID
} = {
AgentID: UUID.zero(),
SessionID: UUID.zero()
};
newObjAgentData['AgentID'] = new UUID(buf, pos);
pos += 16;
newObjAgentData['SessionID'] = new UUID(buf, pos);
pos += 16;
this.AgentData = newObjAgentData;
const newObjRegionData: {
SimIP: IPAddress,
SimPort: number,
RegionHandle: Long,
SeedCapability: string
} = {
SimIP: IPAddress.zero(),
SimPort: 0,
RegionHandle: Long.ZERO,
SeedCapability: ''
};
newObjRegionData['SimIP'] = new IPAddress(buf, pos);
pos += 4;
newObjRegionData['SimPort'] = buf.readUInt16LE(pos);
pos += 2;
newObjRegionData['RegionHandle'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4));
pos += 8;
newObjRegionData['SeedCapability'] = buf.toString('utf8', pos, length);
pos += length;
this.RegionData = newObjRegionData;
const newObjInfo: {
Position: Vector3,
LookAt: Vector3
} = {
Position: Vector3.getZero(),
LookAt: Vector3.getZero()
};
newObjInfo['Position'] = new Vector3(buf, pos, false);
pos += 12;
newObjInfo['LookAt'] = new Vector3(buf, pos, false);
pos += 12;
this.Info = newObjInfo;
return pos - startPos;
}
}