Created
September 9, 2019 05:00
-
-
Save NWPlayer123/32483ea8e7e2c3b0175b610a9627762a to your computer and use it in GitHub Desktop.
Astral Chain dat(/dtt?)
This file contains hidden or 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
| #too lazy to finish this, throwing it here | |
| from struct import unpack | |
| def full(f): | |
| return unpack("<I", f.read(4))[0] | |
| def getstr(f): | |
| ret = b"";char = f.read(1) | |
| while char != b"\x00": | |
| ret += char | |
| char = f.read(1) | |
| return ret | |
| do_debug = False | |
| with open("wp/wp/wp0000.dat", "rb") as f: | |
| assert f.read(4) == b"DAT\x00" | |
| file_count, file_table_offset, ext_table_offset, name_table_offset, \ | |
| size_table_offset, unk_table = unpack("<6I", f.read(0x18)) | |
| assert full(f) == 0 | |
| f.seek(file_table_offset) | |
| file_table = [full(f) for i in range(file_count)] | |
| f.seek(ext_table_offset) | |
| ext_table = [getstr(f) for i in range(file_count)] | |
| f.seek(name_table_offset) | |
| name_size = full(f) | |
| name_table = [f.read(name_size).rstrip("\x00") for i in range(file_count)] | |
| f.seek(size_table_offset) | |
| size_table = [full(f) for i in range(file_count)] | |
| if do_debug: | |
| for i in range(file_count): | |
| print("%08X %08X %s" % (file_table[i], size_table[i], name_table[i])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment