Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -46,4 +46,116 @@ export class RezMultipleAttachmentsFromInvPacket implements Packet
|
||||
return size;
|
||||
}
|
||||
|
||||
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.HeaderData['CompoundMsgID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeUInt8(this.HeaderData['TotalObjects'], pos++);
|
||||
buf.writeUInt8((this.HeaderData['FirstDetachAll']) ? 1 : 0, pos++);
|
||||
const count = this.ObjectData.length;
|
||||
buf.writeUInt8(this.ObjectData.length, pos++);
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
this.ObjectData[i]['ItemID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
this.ObjectData[i]['OwnerID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeUInt8(this.ObjectData[i]['AttachmentPt'], pos++);
|
||||
buf.writeUInt32LE(this.ObjectData[i]['ItemFlags'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt32LE(this.ObjectData[i]['GroupMask'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt32LE(this.ObjectData[i]['EveryoneMask'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt32LE(this.ObjectData[i]['NextOwnerMask'], pos);
|
||||
pos += 4;
|
||||
buf.write(this.ObjectData[i]['Name'], pos);
|
||||
pos += this.ObjectData[i]['Name'].length;
|
||||
buf.write(this.ObjectData[i]['Description'], pos);
|
||||
pos += this.ObjectData[i]['Description'].length;
|
||||
}
|
||||
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 newObjHeaderData: {
|
||||
CompoundMsgID: UUID,
|
||||
TotalObjects: number,
|
||||
FirstDetachAll: boolean
|
||||
} = {
|
||||
CompoundMsgID: UUID.zero(),
|
||||
TotalObjects: 0,
|
||||
FirstDetachAll: false
|
||||
};
|
||||
newObjHeaderData['CompoundMsgID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjHeaderData['TotalObjects'] = buf.readUInt8(pos++);
|
||||
newObjHeaderData['FirstDetachAll'] = (buf.readUInt8(pos++) === 1);
|
||||
this.HeaderData = newObjHeaderData;
|
||||
const count = buf.readUInt8(pos++);
|
||||
this.ObjectData = [];
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
const newObjObjectData: {
|
||||
ItemID: UUID,
|
||||
OwnerID: UUID,
|
||||
AttachmentPt: number,
|
||||
ItemFlags: number,
|
||||
GroupMask: number,
|
||||
EveryoneMask: number,
|
||||
NextOwnerMask: number,
|
||||
Name: string,
|
||||
Description: string
|
||||
} = {
|
||||
ItemID: UUID.zero(),
|
||||
OwnerID: UUID.zero(),
|
||||
AttachmentPt: 0,
|
||||
ItemFlags: 0,
|
||||
GroupMask: 0,
|
||||
EveryoneMask: 0,
|
||||
NextOwnerMask: 0,
|
||||
Name: '',
|
||||
Description: ''
|
||||
};
|
||||
newObjObjectData['ItemID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjObjectData['OwnerID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjObjectData['AttachmentPt'] = buf.readUInt8(pos++);
|
||||
newObjObjectData['ItemFlags'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjObjectData['GroupMask'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjObjectData['EveryoneMask'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjObjectData['NextOwnerMask'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjObjectData['Name'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
newObjObjectData['Description'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
this.ObjectData.push(newObjObjectData);
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user