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

@@ -26,4 +26,64 @@ export class AgentDataUpdatePacket implements Packet
return (this.AgentData['FirstName'].length + 1 + this.AgentData['LastName'].length + 1 + this.AgentData['GroupTitle'].length + 1 + this.AgentData['GroupName'].length + 1) + 40;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
this.AgentData['AgentID'].writeToBuffer(buf, pos);
pos += 16;
buf.write(this.AgentData['FirstName'], pos);
pos += this.AgentData['FirstName'].length;
buf.write(this.AgentData['LastName'], pos);
pos += this.AgentData['LastName'].length;
buf.write(this.AgentData['GroupTitle'], pos);
pos += this.AgentData['GroupTitle'].length;
this.AgentData['ActiveGroupID'].writeToBuffer(buf, pos);
pos += 16;
buf.writeInt32LE(this.AgentData['GroupPowers'].low, pos);
pos += 4;
buf.writeInt32LE(this.AgentData['GroupPowers'].high, pos);
pos += 4;
buf.write(this.AgentData['GroupName'], pos);
pos += this.AgentData['GroupName'].length;
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
const newObjAgentData: {
AgentID: UUID,
FirstName: string,
LastName: string,
GroupTitle: string,
ActiveGroupID: UUID,
GroupPowers: Long,
GroupName: string
} = {
AgentID: UUID.zero(),
FirstName: '',
LastName: '',
GroupTitle: '',
ActiveGroupID: UUID.zero(),
GroupPowers: Long.ZERO,
GroupName: ''
};
newObjAgentData['AgentID'] = new UUID(buf, pos);
pos += 16;
newObjAgentData['FirstName'] = buf.toString('utf8', pos, length);
pos += length;
newObjAgentData['LastName'] = buf.toString('utf8', pos, length);
pos += length;
newObjAgentData['GroupTitle'] = buf.toString('utf8', pos, length);
pos += length;
newObjAgentData['ActiveGroupID'] = new UUID(buf, pos);
pos += 16;
newObjAgentData['GroupPowers'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4));
pos += 8;
newObjAgentData['GroupName'] = buf.toString('utf8', pos, length);
pos += length;
this.AgentData = newObjAgentData;
return pos - startPos;
}
}