Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -37,4 +37,76 @@ export class CopyInventoryItemPacket 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;
|
||||
const count = this.InventoryData.length;
|
||||
buf.writeUInt8(this.InventoryData.length, pos++);
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
buf.writeUInt32LE(this.InventoryData[i]['CallbackID'], pos);
|
||||
pos += 4;
|
||||
this.InventoryData[i]['OldAgentID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
this.InventoryData[i]['OldItemID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
this.InventoryData[i]['NewFolderID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.write(this.InventoryData[i]['NewName'], pos);
|
||||
pos += this.InventoryData[i]['NewName'].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 count = buf.readUInt8(pos++);
|
||||
this.InventoryData = [];
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
const newObjInventoryData: {
|
||||
CallbackID: number,
|
||||
OldAgentID: UUID,
|
||||
OldItemID: UUID,
|
||||
NewFolderID: UUID,
|
||||
NewName: string
|
||||
} = {
|
||||
CallbackID: 0,
|
||||
OldAgentID: UUID.zero(),
|
||||
OldItemID: UUID.zero(),
|
||||
NewFolderID: UUID.zero(),
|
||||
NewName: ''
|
||||
};
|
||||
newObjInventoryData['CallbackID'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjInventoryData['OldAgentID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjInventoryData['OldItemID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjInventoryData['NewFolderID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjInventoryData['NewName'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
this.InventoryData.push(newObjInventoryData);
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user