Latest packet handling, parsing, enums, generators, etc..

This commit is contained in:
Casper Warden
2017-11-24 17:45:34 +00:00
parent ec300e33ac
commit 261f28698a
496 changed files with 30448 additions and 57 deletions

View File

@@ -42,4 +42,90 @@ export class AvatarGroupsReplyPacket implements Packet
return size;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
this.AgentData['AgentID'].writeToBuffer(buf, pos);
pos += 16;
this.AgentData['AvatarID'].writeToBuffer(buf, pos);
pos += 16;
const count = this.GroupData.length;
buf.writeUInt8(this.GroupData.length, pos++);
for (let i = 0; i < count; i++)
{
buf.writeInt32LE(this.GroupData[i]['GroupPowers'].low, pos);
pos += 4;
buf.writeInt32LE(this.GroupData[i]['GroupPowers'].high, pos);
pos += 4;
buf.writeUInt8((this.GroupData[i]['AcceptNotices']) ? 1 : 0, pos++);
buf.write(this.GroupData[i]['GroupTitle'], pos);
pos += this.GroupData[i]['GroupTitle'].length;
this.GroupData[i]['GroupID'].writeToBuffer(buf, pos);
pos += 16;
buf.write(this.GroupData[i]['GroupName'], pos);
pos += this.GroupData[i]['GroupName'].length;
this.GroupData[i]['GroupInsigniaID'].writeToBuffer(buf, pos);
pos += 16;
}
buf.writeUInt8((this.NewGroupData['ListInProfile']) ? 1 : 0, pos++);
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
const newObjAgentData: {
AgentID: UUID,
AvatarID: UUID
} = {
AgentID: UUID.zero(),
AvatarID: UUID.zero()
};
newObjAgentData['AgentID'] = new UUID(buf, pos);
pos += 16;
newObjAgentData['AvatarID'] = new UUID(buf, pos);
pos += 16;
this.AgentData = newObjAgentData;
const count = buf.readUInt8(pos++);
this.GroupData = [];
for (let i = 0; i < count; i++)
{
const newObjGroupData: {
GroupPowers: Long,
AcceptNotices: boolean,
GroupTitle: string,
GroupID: UUID,
GroupName: string,
GroupInsigniaID: UUID
} = {
GroupPowers: Long.ZERO,
AcceptNotices: false,
GroupTitle: '',
GroupID: UUID.zero(),
GroupName: '',
GroupInsigniaID: UUID.zero()
};
newObjGroupData['GroupPowers'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4));
pos += 8;
newObjGroupData['AcceptNotices'] = (buf.readUInt8(pos++) === 1);
newObjGroupData['GroupTitle'] = buf.toString('utf8', pos, length);
pos += length;
newObjGroupData['GroupID'] = new UUID(buf, pos);
pos += 16;
newObjGroupData['GroupName'] = buf.toString('utf8', pos, length);
pos += length;
newObjGroupData['GroupInsigniaID'] = new UUID(buf, pos);
pos += 16;
this.GroupData.push(newObjGroupData);
}
const newObjNewGroupData: {
ListInProfile: boolean
} = {
ListInProfile: false
};
newObjNewGroupData['ListInProfile'] = (buf.readUInt8(pos++) === 1);
this.NewGroupData = newObjNewGroupData;
return pos - startPos;
}
}