Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -31,4 +31,86 @@ export class DeRezObjectPacket implements Packet
|
||||
return ((4) * this.ObjectData.length) + 84;
|
||||
}
|
||||
|
||||
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.AgentBlock['GroupID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeUInt8(this.AgentBlock['Destination'], pos++);
|
||||
this.AgentBlock['DestinationID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
this.AgentBlock['TransactionID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeUInt8(this.AgentBlock['PacketCount'], pos++);
|
||||
buf.writeUInt8(this.AgentBlock['PacketNumber'], pos++);
|
||||
const count = this.ObjectData.length;
|
||||
buf.writeUInt8(this.ObjectData.length, pos++);
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
buf.writeUInt32LE(this.ObjectData[i]['ObjectLocalID'], pos);
|
||||
pos += 4;
|
||||
}
|
||||
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 newObjAgentBlock: {
|
||||
GroupID: UUID,
|
||||
Destination: number,
|
||||
DestinationID: UUID,
|
||||
TransactionID: UUID,
|
||||
PacketCount: number,
|
||||
PacketNumber: number
|
||||
} = {
|
||||
GroupID: UUID.zero(),
|
||||
Destination: 0,
|
||||
DestinationID: UUID.zero(),
|
||||
TransactionID: UUID.zero(),
|
||||
PacketCount: 0,
|
||||
PacketNumber: 0
|
||||
};
|
||||
newObjAgentBlock['GroupID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjAgentBlock['Destination'] = buf.readUInt8(pos++);
|
||||
newObjAgentBlock['DestinationID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjAgentBlock['TransactionID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjAgentBlock['PacketCount'] = buf.readUInt8(pos++);
|
||||
newObjAgentBlock['PacketNumber'] = buf.readUInt8(pos++);
|
||||
this.AgentBlock = newObjAgentBlock;
|
||||
const count = buf.readUInt8(pos++);
|
||||
this.ObjectData = [];
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
const newObjObjectData: {
|
||||
ObjectLocalID: number
|
||||
} = {
|
||||
ObjectLocalID: 0
|
||||
};
|
||||
newObjObjectData['ObjectLocalID'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
this.ObjectData.push(newObjObjectData);
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user