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

@@ -22,4 +22,40 @@ export class SimulatorSetMapPacket implements Packet
return 28;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
buf.writeInt32LE(this.MapData['RegionHandle'].low, pos);
pos += 4;
buf.writeInt32LE(this.MapData['RegionHandle'].high, pos);
pos += 4;
buf.writeInt32LE(this.MapData['Type'], pos);
pos += 4;
this.MapData['MapImage'].writeToBuffer(buf, pos);
pos += 16;
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
const newObjMapData: {
RegionHandle: Long,
Type: number,
MapImage: UUID
} = {
RegionHandle: Long.ZERO,
Type: 0,
MapImage: UUID.zero()
};
newObjMapData['RegionHandle'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4));
pos += 8;
newObjMapData['Type'] = buf.readInt32LE(pos);
pos += 4;
newObjMapData['MapImage'] = new UUID(buf, pos);
pos += 16;
this.MapData = newObjMapData;
return pos - startPos;
}
}