Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -32,4 +32,98 @@ export class ParcelAccessListUpdatePacket implements Packet
|
||||
return ((24) * this.List.length) + 65;
|
||||
}
|
||||
|
||||
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;
|
||||
buf.writeUInt32LE(this.Data['Flags'], pos);
|
||||
pos += 4;
|
||||
buf.writeInt32LE(this.Data['LocalID'], pos);
|
||||
pos += 4;
|
||||
this.Data['TransactionID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeInt32LE(this.Data['SequenceID'], pos);
|
||||
pos += 4;
|
||||
buf.writeInt32LE(this.Data['Sections'], pos);
|
||||
pos += 4;
|
||||
const count = this.List.length;
|
||||
buf.writeUInt8(this.List.length, pos++);
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
this.List[i]['ID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeInt32LE(this.List[i]['Time'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt32LE(this.List[i]['Flags'], 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 newObjData: {
|
||||
Flags: number,
|
||||
LocalID: number,
|
||||
TransactionID: UUID,
|
||||
SequenceID: number,
|
||||
Sections: number
|
||||
} = {
|
||||
Flags: 0,
|
||||
LocalID: 0,
|
||||
TransactionID: UUID.zero(),
|
||||
SequenceID: 0,
|
||||
Sections: 0
|
||||
};
|
||||
newObjData['Flags'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjData['LocalID'] = buf.readInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjData['TransactionID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjData['SequenceID'] = buf.readInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjData['Sections'] = buf.readInt32LE(pos);
|
||||
pos += 4;
|
||||
this.Data = newObjData;
|
||||
const count = buf.readUInt8(pos++);
|
||||
this.List = [];
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
const newObjList: {
|
||||
ID: UUID,
|
||||
Time: number,
|
||||
Flags: number
|
||||
} = {
|
||||
ID: UUID.zero(),
|
||||
Time: 0,
|
||||
Flags: 0
|
||||
};
|
||||
newObjList['ID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjList['Time'] = buf.readInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjList['Flags'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
this.List.push(newObjList);
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user