Skip to content

Commit

Permalink
Formatting and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
njibhu committed Sep 21, 2024
1 parent 6c5557c commit 78c0fd8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion parser/src/chunk-packs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const fileChunkMap = {
audi: "AUDI",
lght: "LGHT",
exp: "EXP",
watr: "WATR"
watr: "WATR",
},
emoc: { anim: "ANIM_3" },
// STAR: { STAR: "" },
Expand Down
14 changes: 7 additions & 7 deletions parser/src/data-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export class DataParser implements Definition {
for (let i = 0; i < arrayLength; i++) {
const offset = this.offset(dv, currentPosition + i * this.PTR_SIZE);

offsets.push(Number(offset));
offsets.push(offset);
}

// Set pointer to read structures
Expand Down Expand Up @@ -352,21 +352,21 @@ export class DataParser implements Definition {
**/

private offset(dv: DataView, pos: number): number {
if(this.is64Bit) {
if (this.is64Bit) {
const offset = dv.getBigUint64(pos, true);
if(offset === BigInt(0)) {
if (offset === BigInt(0)) {
return 0;
} else if(offset > BigInt(dv.byteLength)) {
} else if (offset > BigInt(dv.byteLength)) {
// Parse negative offset
return -(Number(BigInt('0xFFFFFFFFFFFFFFFF') - offset) + 1);
return -(Number(BigInt("0xFFFFFFFFFFFFFFFF") - offset) + 1);
} else {
return Number(offset);
}
} else {
const offset = dv.getUint32(pos, true);
if(offset > dv.byteLength) {
if (offset > dv.byteLength) {
// Parse negative offset
return -((0xFFFFFFFF - offset) + 1);
return -(0xffffffff - offset + 1);
} else {
return offset;
}
Expand Down
6 changes: 4 additions & 2 deletions parser/src/file-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ export default class FileParser {
this.dataView,
metadata.chunkPosition + metadata.chunkHeader.chunkHeaderSize
);
if(parserResult.error) {
console.error(`Error parsing chunk ${metadata.chunkHeader.type} with version ${metadata.chunkHeader.chunkVersion}: ${parserResult.error}`);
if (parserResult.error) {
console.error(
`Error parsing chunk ${metadata.chunkHeader.type} with version ${metadata.chunkHeader.chunkVersion}: ${parserResult.error}`
);
}
this.chunks.push({
header: metadata.chunkHeader,
Expand Down

0 comments on commit 78c0fd8

Please sign in to comment.