Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -31,4 +31,84 @@ export class LogParcelChangesPacket implements Packet
|
||||
return ((54) * this.ParcelData.length) + 25;
|
||||
}
|
||||
|
||||
writeToBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
this.AgentData['AgentID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeInt32LE(this.RegionData['RegionHandle'].low, pos);
|
||||
pos += 4;
|
||||
buf.writeInt32LE(this.RegionData['RegionHandle'].high, pos);
|
||||
pos += 4;
|
||||
const count = this.ParcelData.length;
|
||||
buf.writeUInt8(this.ParcelData.length, pos++);
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
this.ParcelData[i]['ParcelID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
this.ParcelData[i]['OwnerID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeUInt8((this.ParcelData[i]['IsOwnerGroup']) ? 1 : 0, pos++);
|
||||
buf.writeInt32LE(this.ParcelData[i]['ActualArea'], pos);
|
||||
pos += 4;
|
||||
buf.writeInt8(this.ParcelData[i]['Action'], pos++);
|
||||
this.ParcelData[i]['TransactionID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
|
||||
readFromBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
const newObjAgentData: {
|
||||
AgentID: UUID
|
||||
} = {
|
||||
AgentID: UUID.zero()
|
||||
};
|
||||
newObjAgentData['AgentID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
this.AgentData = newObjAgentData;
|
||||
const newObjRegionData: {
|
||||
RegionHandle: Long
|
||||
} = {
|
||||
RegionHandle: Long.ZERO
|
||||
};
|
||||
newObjRegionData['RegionHandle'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4));
|
||||
pos += 8;
|
||||
this.RegionData = newObjRegionData;
|
||||
const count = buf.readUInt8(pos++);
|
||||
this.ParcelData = [];
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
const newObjParcelData: {
|
||||
ParcelID: UUID,
|
||||
OwnerID: UUID,
|
||||
IsOwnerGroup: boolean,
|
||||
ActualArea: number,
|
||||
Action: number,
|
||||
TransactionID: UUID
|
||||
} = {
|
||||
ParcelID: UUID.zero(),
|
||||
OwnerID: UUID.zero(),
|
||||
IsOwnerGroup: false,
|
||||
ActualArea: 0,
|
||||
Action: 0,
|
||||
TransactionID: UUID.zero()
|
||||
};
|
||||
newObjParcelData['ParcelID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjParcelData['OwnerID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjParcelData['IsOwnerGroup'] = (buf.readUInt8(pos++) === 1);
|
||||
newObjParcelData['ActualArea'] = buf.readInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjParcelData['Action'] = buf.readInt8(pos++);
|
||||
newObjParcelData['TransactionID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
this.ParcelData.push(newObjParcelData);
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user