Skip to content

Commit d49c43b

Browse files
authored
Merge pull request #299 from runejs/feature/fix-xtea-loading
Fixing xtea loading
2 parents 39529db + c683dfa commit d49c43b

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/game-engine/net/outbound-packets.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -566,22 +566,22 @@ export class OutboundPackets {
566566

567567
public updateCurrentMapChunk(): void {
568568
const packet = new Packet(166, PacketType.DYNAMIC_LARGE);
569-
packet.put(this.player.position.chunkLocalY, 'SHORT');
570-
packet.put(this.player.position.chunkX + 6, 'SHORT', 'LITTLE_ENDIAN');
571-
packet.put(this.player.position.chunkLocalX, 'SHORT');
572-
packet.put(this.player.position.chunkY + 6, 'SHORT', 'LITTLE_ENDIAN');
569+
packet.put(this.player.position.chunkLocalY, 'short');
570+
packet.put(this.player.position.chunkX + 6, 'short', 'le');
571+
packet.put(this.player.position.chunkLocalX, 'short');
572+
packet.put(this.player.position.chunkY + 6, 'short', 'le');
573573
packet.put(this.player.position.level);
574574

575-
for(let xCalc = Math.floor(this.player.position.chunkX / 8); xCalc <= Math.floor((this.player.position.chunkX + 12) / 8); xCalc++) {
576-
for(let yCalc = Math.floor(this.player.position.chunkY / 8); yCalc <= Math.floor((this.player.position.chunkY + 12) / 8); yCalc++) {
577-
const regionid = (xCalc << 8 | yCalc);
578-
const xteaRegion = xteaRegions[regionid]
575+
const startX = Math.floor(this.player.position.chunkX / 8);
576+
const endX = Math.floor((this.player.position.chunkX + 12) / 8);
577+
const startY = Math.floor(this.player.position.chunkY / 8);
578+
const endY = Math.floor((this.player.position.chunkY + 12) / 8);
579+
580+
for(let mapX = startX; mapX <= endX; mapX++) {
581+
for(let mapY = startY; mapY <= endY; mapY++) {
582+
const xteaRegion = xteaRegions[`l${mapX}_${mapY}`];
579583
for(let seeds = 0; seeds < 4; seeds++) {
580-
if(xteaRegion) {
581-
packet.put(xteaRegion.key[seeds], 'INT');
582-
} else {
583-
packet.put(0, 'INT');
584-
}
584+
packet.put(xteaRegion?.key[seeds] || 0, 'int');
585585
}
586586
}
587587
}

0 commit comments

Comments
 (0)