From d0b644d8d84aad8fe14d92f8e52b8172ecc99b0c Mon Sep 17 00:00:00 2001 From: GeffDev Date: Sat, 24 Feb 2024 14:21:51 +0800 Subject: [PATCH] update readme for tools and fix extraction --- README.md | 5 ++++- src/extract.c | 13 +++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 30d8b56..e47a0de 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,7 @@ Does the bare minimum of unpacking all data packs based off of `Pack.db` (converted to plain text). I plan on fleshing this out soon. ## Instructions -Compile, copy `files.txt` and the `Pack` folder from game files next to the executable. \ No newline at end of file +Compile, copy `files.txt` and the `Pack` folder from game files next to the executable. + +## Tools +`decompress_gzip.sh` - Run from inside `Pack/` to decompress all gzipped files (PVR texture files). \ No newline at end of file diff --git a/src/extract.c b/src/extract.c index b2498a9..9db5ac1 100644 --- a/src/extract.c +++ b/src/extract.c @@ -139,15 +139,20 @@ i32 extractPacks() { strcat(full_file_path, path); FILE *unpacked_file = fopen(full_file_path, "wb+"); - // TODO: some files are under 48 bytes? which is the size of the file header? - if (remove_header && size > 0x30) { + if (remove_header) { offset += 0x30; - size -= 0x30; } fseek(data_packs[pack], offset, SEEK_SET); - u8 *file_buffer = malloc(size); + u8 *file_buffer; + if (remove_header) { + file_buffer = malloc(size); + } else { + // size doesn't account for file header + file_buffer = malloc(size + 0x30); + } + if (file_buffer == NULL) { printLog("ERROR: failed to allocate file buffer"); break;