142 lines
4.8 KiB
TypeScript
142 lines
4.8 KiB
TypeScript
// This file has been automatically generated by writeMessageClasses.js
|
|
|
|
import { UUID } from '../UUID';
|
|
import * as Long from 'long';
|
|
import { MessageFlags } from '../../enums/MessageFlags';
|
|
import { MessageBase } from '../MessageBase';
|
|
import { Message } from '../../enums/Message';
|
|
|
|
export class AvatarGroupsReplyMessage implements MessageBase
|
|
{
|
|
name = 'AvatarGroupsReply';
|
|
messageFlags = MessageFlags.Trusted | MessageFlags.Zerocoded | MessageFlags.FrequencyLow;
|
|
id = Message.AvatarGroupsReply;
|
|
|
|
AgentData: {
|
|
AgentID: UUID;
|
|
AvatarID: UUID;
|
|
};
|
|
GroupData: {
|
|
GroupPowers: Long;
|
|
AcceptNotices: boolean;
|
|
GroupTitle: Buffer;
|
|
GroupID: UUID;
|
|
GroupName: Buffer;
|
|
GroupInsigniaID: UUID;
|
|
}[];
|
|
NewGroupData: {
|
|
ListInProfile: boolean;
|
|
};
|
|
|
|
getSize(): number
|
|
{
|
|
return this.calculateVarVarSize(this.GroupData, 'GroupTitle', 1) + this.calculateVarVarSize(this.GroupData, 'GroupName', 1) + ((41) * this.GroupData.length) + 34;
|
|
}
|
|
|
|
calculateVarVarSize(block: {[key: string]: any}[], paramName: string, extraPerVar: number): number
|
|
{
|
|
let size = 0;
|
|
for (const bl of block)
|
|
{
|
|
size += bl[paramName].length + extraPerVar;
|
|
}
|
|
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.writeUInt8(this.GroupData[i]['GroupTitle'].length, pos++);
|
|
this.GroupData[i]['GroupTitle'].copy(buf, pos);
|
|
pos += this.GroupData[i]['GroupTitle'].length;
|
|
this.GroupData[i]['GroupID'].writeToBuffer(buf, pos);
|
|
pos += 16;
|
|
buf.writeUInt8(this.GroupData[i]['GroupName'].length, pos++);
|
|
this.GroupData[i]['GroupName'].copy(buf, 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;
|
|
let varLength = 0;
|
|
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;
|
|
if (pos >= buf.length)
|
|
{
|
|
return pos - startPos;
|
|
}
|
|
const count = buf.readUInt8(pos++);
|
|
this.GroupData = [];
|
|
for (let i = 0; i < count; i++)
|
|
{
|
|
const newObjGroupData: {
|
|
GroupPowers: Long,
|
|
AcceptNotices: boolean,
|
|
GroupTitle: Buffer,
|
|
GroupID: UUID,
|
|
GroupName: Buffer,
|
|
GroupInsigniaID: UUID
|
|
} = {
|
|
GroupPowers: Long.ZERO,
|
|
AcceptNotices: false,
|
|
GroupTitle: Buffer.allocUnsafe(0),
|
|
GroupID: UUID.zero(),
|
|
GroupName: Buffer.allocUnsafe(0),
|
|
GroupInsigniaID: UUID.zero()
|
|
};
|
|
newObjGroupData['GroupPowers'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4));
|
|
pos += 8;
|
|
newObjGroupData['AcceptNotices'] = (buf.readUInt8(pos++) === 1);
|
|
varLength = buf.readUInt8(pos++);
|
|
newObjGroupData['GroupTitle'] = buf.slice(pos, pos + varLength);
|
|
pos += varLength;
|
|
newObjGroupData['GroupID'] = new UUID(buf, pos);
|
|
pos += 16;
|
|
varLength = buf.readUInt8(pos++);
|
|
newObjGroupData['GroupName'] = buf.slice(pos, pos + varLength);
|
|
pos += varLength;
|
|
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;
|
|
}
|
|
}
|
|
|