Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -31,4 +31,88 @@ export class ParcelClaimPacket implements Packet
|
||||
return ((16) * this.ParcelData.length) + 51;
|
||||
}
|
||||
|
||||
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['GroupID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeUInt8((this.Data['IsGroupOwned']) ? 1 : 0, pos++);
|
||||
buf.writeUInt8((this.Data['Final']) ? 1 : 0, pos++);
|
||||
const count = this.ParcelData.length;
|
||||
buf.writeUInt8(this.ParcelData.length, pos++);
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
buf.writeFloatLE(this.ParcelData[i]['West'], pos);
|
||||
pos += 4;
|
||||
buf.writeFloatLE(this.ParcelData[i]['South'], pos);
|
||||
pos += 4;
|
||||
buf.writeFloatLE(this.ParcelData[i]['East'], pos);
|
||||
pos += 4;
|
||||
buf.writeFloatLE(this.ParcelData[i]['North'], pos);
|
||||
pos += 4;
|
||||
}
|
||||
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: {
|
||||
GroupID: UUID,
|
||||
IsGroupOwned: boolean,
|
||||
Final: boolean
|
||||
} = {
|
||||
GroupID: UUID.zero(),
|
||||
IsGroupOwned: false,
|
||||
Final: false
|
||||
};
|
||||
newObjData['GroupID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjData['IsGroupOwned'] = (buf.readUInt8(pos++) === 1);
|
||||
newObjData['Final'] = (buf.readUInt8(pos++) === 1);
|
||||
this.Data = newObjData;
|
||||
const count = buf.readUInt8(pos++);
|
||||
this.ParcelData = [];
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
const newObjParcelData: {
|
||||
West: number,
|
||||
South: number,
|
||||
East: number,
|
||||
North: number
|
||||
} = {
|
||||
West: 0,
|
||||
South: 0,
|
||||
East: 0,
|
||||
North: 0
|
||||
};
|
||||
newObjParcelData['West'] = buf.readFloatLE(pos);
|
||||
pos += 4;
|
||||
newObjParcelData['South'] = buf.readFloatLE(pos);
|
||||
pos += 4;
|
||||
newObjParcelData['East'] = buf.readFloatLE(pos);
|
||||
pos += 4;
|
||||
newObjParcelData['North'] = buf.readFloatLE(pos);
|
||||
pos += 4;
|
||||
this.ParcelData.push(newObjParcelData);
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user