Created
April 21, 2024 04:12
-
-
Save ultraviolet-jordan/bd3bdcb51951459c1f13226f2979277c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private decodeLocs = async (js5: Js5[], lands: Int8Array, buf: Packet, mapsquareX: number, mapsquareZ: number): Promise<void> => { | |
let locId: number = -1; | |
let locIdOffset: number = buf.gExtended1or2(); | |
while (locIdOffset !== 0) { | |
locId += locIdOffset; | |
let coord: number = 0; | |
let coordOffset: number = buf.gSmart1or2(); | |
while (coordOffset !== 0) { | |
const {x, z, level} = this.unpackCoord(coord += coordOffset - 1); | |
const info: number = buf.g1(); | |
if ((info & 0x80) !== 0) { | |
const scalerottrans: number = buf.g1(); | |
if ((scalerottrans & 0x1) !== 0) { | |
buf.pos += 8; | |
} | |
if ((scalerottrans & 0x2) !== 0) { | |
buf.pos += 2; | |
} | |
if ((scalerottrans & 0x4) !== 0) { | |
buf.pos += 2; | |
} | |
if ((scalerottrans & 0x8) !== 0) { | |
buf.pos += 2; | |
} | |
if ((scalerottrans & 0x10) === 0) { | |
if ((scalerottrans & 0x20) !== 0) { | |
buf.pos += 2; | |
} | |
if ((scalerottrans & 0x40) !== 0) { | |
buf.pos += 2; | |
} | |
if ((scalerottrans & 0x80) !== 0) { | |
buf.pos += 2; | |
} | |
} else { | |
buf.pos += 2; | |
} | |
} | |
coordOffset = buf.gSmart1or2(); | |
const absoluteX: number = x + mapsquareX; | |
const absoluteZ: number = z + mapsquareZ; | |
const adjustedLevel: number = (lands[this.packCoord(x, z, 1)] & 0x2) === 2 ? level - 1 : level; | |
if (adjustedLevel < 0) { | |
continue; | |
} | |
const locType: LocType = await LocType.list(locId, js5); | |
if (locType.blockwalk === 1) { | |
this.changeLocCollision(info >> 2, info & 0x3, locType.blockrange, locType.breakroutefinding, locType.length, locType.width, locType.active, absoluteX, absoluteZ, level, true); | |
} | |
} | |
locIdOffset = buf.gExtended1or2(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment