Created
September 28, 2024 21:43
-
-
Save nta/8a8126743f526859afb8ed6090f7efc9 to your computer and use it in GitHub Desktop.
a patch for critools (https://github.com/kohos/CriTools) to support 4-byte ids
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
diff --git a/src/afs2.js b/src/afs2.js | |
index 59ab4d5..18d0f6e 100644 | |
--- a/src/afs2.js | |
+++ b/src/afs2.js | |
@@ -18,14 +18,19 @@ async function parseAFS2(buffer) { | |
if (config.magic !== 'AFS2') return null; | |
config.unknown1 = buffer.readUInt8(pos); pos += 1; | |
config.sizeLen = buffer.readUInt8(pos); pos += 1; | |
- config.unknown2 = buffer.readUInt8(pos); pos += 1; | |
+ config.idLen = buffer.readUInt8(pos); pos += 1; | |
config.unknown3 = buffer.readUInt8(pos); pos += 1; | |
config.fileCount = buffer.readUInt32LE(pos); pos += 4; | |
config.align = buffer.readUInt16LE(pos); pos += 2; | |
config.key = buffer.readUInt16LE(pos); pos += 2; | |
config.fileIds = []; | |
for (let i = 0; i < config.fileCount; i++) { | |
- const fileId = buffer.readUInt16LE(pos); pos += 2; | |
+ let fileId; | |
+ if (config.idLen === 2) { | |
+ fileId = buffer.readUInt16LE(pos); pos += 2; | |
+ } else if (config.idLen === 4) { | |
+ fileId = buffer.readUInt32LE(pos); pos += 4; | |
+ } else debugger; | |
config.fileIds.push(fileId); | |
} | |
const files = []; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment