Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -33,4 +33,56 @@ export class GroupDataUpdatePacket implements Packet
|
||||
return size;
|
||||
}
|
||||
|
||||
writeToBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
const count = this.AgentGroupData.length;
|
||||
buf.writeUInt8(this.AgentGroupData.length, pos++);
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
this.AgentGroupData[i]['AgentID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
this.AgentGroupData[i]['GroupID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeInt32LE(this.AgentGroupData[i]['AgentPowers'].low, pos);
|
||||
pos += 4;
|
||||
buf.writeInt32LE(this.AgentGroupData[i]['AgentPowers'].high, pos);
|
||||
pos += 4;
|
||||
buf.write(this.AgentGroupData[i]['GroupTitle'], pos);
|
||||
pos += this.AgentGroupData[i]['GroupTitle'].length;
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
|
||||
readFromBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
const count = buf.readUInt8(pos++);
|
||||
this.AgentGroupData = [];
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
const newObjAgentGroupData: {
|
||||
AgentID: UUID,
|
||||
GroupID: UUID,
|
||||
AgentPowers: Long,
|
||||
GroupTitle: string
|
||||
} = {
|
||||
AgentID: UUID.zero(),
|
||||
GroupID: UUID.zero(),
|
||||
AgentPowers: Long.ZERO,
|
||||
GroupTitle: ''
|
||||
};
|
||||
newObjAgentGroupData['AgentID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjAgentGroupData['GroupID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjAgentGroupData['AgentPowers'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4));
|
||||
pos += 8;
|
||||
newObjAgentGroupData['GroupTitle'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
this.AgentGroupData.push(newObjAgentGroupData);
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user