Skip to content

Commit

Permalink
Merge pull request runejs#299 from runejs/feature/fix-xtea-loading
Browse files Browse the repository at this point in the history
Fixing xtea loading
  • Loading branch information
Promises authored Apr 17, 2021
2 parents 39529db + c683dfa commit d49c43b
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/game-engine/net/outbound-packets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,22 +566,22 @@ export class OutboundPackets {

public updateCurrentMapChunk(): void {
const packet = new Packet(166, PacketType.DYNAMIC_LARGE);
packet.put(this.player.position.chunkLocalY, 'SHORT');
packet.put(this.player.position.chunkX + 6, 'SHORT', 'LITTLE_ENDIAN');
packet.put(this.player.position.chunkLocalX, 'SHORT');
packet.put(this.player.position.chunkY + 6, 'SHORT', 'LITTLE_ENDIAN');
packet.put(this.player.position.chunkLocalY, 'short');
packet.put(this.player.position.chunkX + 6, 'short', 'le');
packet.put(this.player.position.chunkLocalX, 'short');
packet.put(this.player.position.chunkY + 6, 'short', 'le');
packet.put(this.player.position.level);

for(let xCalc = Math.floor(this.player.position.chunkX / 8); xCalc <= Math.floor((this.player.position.chunkX + 12) / 8); xCalc++) {
for(let yCalc = Math.floor(this.player.position.chunkY / 8); yCalc <= Math.floor((this.player.position.chunkY + 12) / 8); yCalc++) {
const regionid = (xCalc << 8 | yCalc);
const xteaRegion = xteaRegions[regionid]
const startX = Math.floor(this.player.position.chunkX / 8);
const endX = Math.floor((this.player.position.chunkX + 12) / 8);
const startY = Math.floor(this.player.position.chunkY / 8);
const endY = Math.floor((this.player.position.chunkY + 12) / 8);

for(let mapX = startX; mapX <= endX; mapX++) {
for(let mapY = startY; mapY <= endY; mapY++) {
const xteaRegion = xteaRegions[`l${mapX}_${mapY}`];
for(let seeds = 0; seeds < 4; seeds++) {
if(xteaRegion) {
packet.put(xteaRegion.key[seeds], 'INT');
} else {
packet.put(0, 'INT');
}
packet.put(xteaRegion?.key[seeds] || 0, 'int');
}
}
}
Expand Down

0 comments on commit d49c43b

Please sign in to comment.