Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -31,4 +31,76 @@ export class ParcelBuyPacket implements Packet
|
||||
return 63;
|
||||
}
|
||||
|
||||
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['RemoveContribution']) ? 1 : 0, pos++);
|
||||
buf.writeInt32LE(this.Data['LocalID'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt8((this.Data['Final']) ? 1 : 0, pos++);
|
||||
buf.writeInt32LE(this.ParcelData['Price'], pos);
|
||||
pos += 4;
|
||||
buf.writeInt32LE(this.ParcelData['Area'], 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,
|
||||
RemoveContribution: boolean,
|
||||
LocalID: number,
|
||||
Final: boolean
|
||||
} = {
|
||||
GroupID: UUID.zero(),
|
||||
IsGroupOwned: false,
|
||||
RemoveContribution: false,
|
||||
LocalID: 0,
|
||||
Final: false
|
||||
};
|
||||
newObjData['GroupID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjData['IsGroupOwned'] = (buf.readUInt8(pos++) === 1);
|
||||
newObjData['RemoveContribution'] = (buf.readUInt8(pos++) === 1);
|
||||
newObjData['LocalID'] = buf.readInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjData['Final'] = (buf.readUInt8(pos++) === 1);
|
||||
this.Data = newObjData;
|
||||
const newObjParcelData: {
|
||||
Price: number,
|
||||
Area: number
|
||||
} = {
|
||||
Price: 0,
|
||||
Area: 0
|
||||
};
|
||||
newObjParcelData['Price'] = buf.readInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjParcelData['Area'] = buf.readInt32LE(pos);
|
||||
pos += 4;
|
||||
this.ParcelData = newObjParcelData;
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user