Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -23,4 +23,52 @@ export class ChangeUserRightsPacket implements Packet
|
||||
return ((20) * this.Rights.length) + 17;
|
||||
}
|
||||
|
||||
writeToBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
this.AgentData['AgentID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
const count = this.Rights.length;
|
||||
buf.writeUInt8(this.Rights.length, pos++);
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
this.Rights[i]['AgentRelated'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeInt32LE(this.Rights[i]['RelatedRights'], pos);
|
||||
pos += 4;
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
|
||||
readFromBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
const newObjAgentData: {
|
||||
AgentID: UUID
|
||||
} = {
|
||||
AgentID: UUID.zero()
|
||||
};
|
||||
newObjAgentData['AgentID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
this.AgentData = newObjAgentData;
|
||||
const count = buf.readUInt8(pos++);
|
||||
this.Rights = [];
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
const newObjRights: {
|
||||
AgentRelated: UUID,
|
||||
RelatedRights: number
|
||||
} = {
|
||||
AgentRelated: UUID.zero(),
|
||||
RelatedRights: 0
|
||||
};
|
||||
newObjRights['AgentRelated'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjRights['RelatedRights'] = buf.readInt32LE(pos);
|
||||
pos += 4;
|
||||
this.Rights.push(newObjRights);
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user