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,68 @@ export class SetSimStatusInDatabasePacket implements Packet
return (this.Data['HostName'].length + 1 + this.Data['Status'].length + 1) + 36;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
this.Data['RegionID'].writeToBuffer(buf, pos);
pos += 16;
buf.write(this.Data['HostName'], pos);
pos += this.Data['HostName'].length;
buf.writeInt32LE(this.Data['X'], pos);
pos += 4;
buf.writeInt32LE(this.Data['Y'], pos);
pos += 4;
buf.writeInt32LE(this.Data['PID'], pos);
pos += 4;
buf.writeInt32LE(this.Data['AgentCount'], pos);
pos += 4;
buf.writeInt32LE(this.Data['TimeToLive'], pos);
pos += 4;
buf.write(this.Data['Status'], pos);
pos += this.Data['Status'].length;
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
const newObjData: {
RegionID: UUID,
HostName: string,
X: number,
Y: number,
PID: number,
AgentCount: number,
TimeToLive: number,
Status: string
} = {
RegionID: UUID.zero(),
HostName: '',
X: 0,
Y: 0,
PID: 0,
AgentCount: 0,
TimeToLive: 0,
Status: ''
};
newObjData['RegionID'] = new UUID(buf, pos);
pos += 16;
newObjData['HostName'] = buf.toString('utf8', pos, length);
pos += length;
newObjData['X'] = buf.readInt32LE(pos);
pos += 4;
newObjData['Y'] = buf.readInt32LE(pos);
pos += 4;
newObjData['PID'] = buf.readInt32LE(pos);
pos += 4;
newObjData['AgentCount'] = buf.readInt32LE(pos);
pos += 4;
newObjData['TimeToLive'] = buf.readInt32LE(pos);
pos += 4;
newObjData['Status'] = buf.toString('utf8', pos, length);
pos += length;
this.Data = newObjData;
return pos - startPos;
}
}