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

@@ -33,4 +33,92 @@ export class PickInfoUpdatePacket implements Packet
return (this.Data['Name'].length + 1 + this.Data['Desc'].length + 2) + 126;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
this.AgentData['AgentID'].writeToBuffer(buf, pos);
pos += 16;
this.AgentData['SessionID'].writeToBuffer(buf, pos);
pos += 16;
this.Data['PickID'].writeToBuffer(buf, pos);
pos += 16;
this.Data['CreatorID'].writeToBuffer(buf, pos);
pos += 16;
buf.writeUInt8((this.Data['TopPick']) ? 1 : 0, pos++);
this.Data['ParcelID'].writeToBuffer(buf, pos);
pos += 16;
buf.write(this.Data['Name'], pos);
pos += this.Data['Name'].length;
buf.write(this.Data['Desc'], pos);
pos += this.Data['Desc'].length;
this.Data['SnapshotID'].writeToBuffer(buf, pos);
pos += 16;
this.Data['PosGlobal'].writeToBuffer(buf, pos, true);
pos += 24;
buf.writeInt32LE(this.Data['SortOrder'], pos);
pos += 4;
buf.writeUInt8((this.Data['Enabled']) ? 1 : 0, pos++);
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
const newObjAgentData: {
AgentID: UUID,
SessionID: UUID
} = {
AgentID: UUID.zero(),
SessionID: UUID.zero()
};
newObjAgentData['AgentID'] = new UUID(buf, pos);
pos += 16;
newObjAgentData['SessionID'] = new UUID(buf, pos);
pos += 16;
this.AgentData = newObjAgentData;
const newObjData: {
PickID: UUID,
CreatorID: UUID,
TopPick: boolean,
ParcelID: UUID,
Name: string,
Desc: string,
SnapshotID: UUID,
PosGlobal: Vector3,
SortOrder: number,
Enabled: boolean
} = {
PickID: UUID.zero(),
CreatorID: UUID.zero(),
TopPick: false,
ParcelID: UUID.zero(),
Name: '',
Desc: '',
SnapshotID: UUID.zero(),
PosGlobal: Vector3.getZero(),
SortOrder: 0,
Enabled: false
};
newObjData['PickID'] = new UUID(buf, pos);
pos += 16;
newObjData['CreatorID'] = new UUID(buf, pos);
pos += 16;
newObjData['TopPick'] = (buf.readUInt8(pos++) === 1);
newObjData['ParcelID'] = new UUID(buf, pos);
pos += 16;
newObjData['Name'] = buf.toString('utf8', pos, length);
pos += length;
newObjData['Desc'] = buf.toString('utf8', pos, length);
pos += length;
newObjData['SnapshotID'] = new UUID(buf, pos);
pos += 16;
newObjData['PosGlobal'] = new Vector3(buf, pos, true);
pos += 24;
newObjData['SortOrder'] = buf.readInt32LE(pos);
pos += 4;
newObjData['Enabled'] = (buf.readUInt8(pos++) === 1);
this.Data = newObjData;
return pos - startPos;
}
}