Initial commit: RE tooling and docs for The I of the Dragon localization/HD
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import os
|
||||
base = r"F:\steam\steamapps\common\The I of the Dragon\Data\Misc"
|
||||
out = r"C:\Users\29452\AppData\Local\Temp\opencode\decoded"
|
||||
os.makedirs(out, exist_ok=True)
|
||||
key = b"GBDFYTNE"
|
||||
for f in ["Fonts.dat", "UnitDescription.dat", "AIDescription.dat"]:
|
||||
d = open(os.path.join(base, f), "rb").read()
|
||||
assert d[:2] == b"==", d[:2]
|
||||
body = d[2:]
|
||||
dec = bytes(body[i] ^ key[i % len(key)] for i in range(len(body)))
|
||||
fp = os.path.join(out, f + ".txt")
|
||||
open(fp, "wb").write(dec)
|
||||
print(f, "->", fp, len(dec), "bytes")
|
||||
|
||||
# also prove re-encode round trips
|
||||
def enc(text_bytes):
|
||||
return b"==" + bytes(text_bytes[i] ^ key[i % len(key)] for i in range(len(text_bytes)))
|
||||
for f in ["Fonts.dat", "UnitDescription.dat", "AIDescription.dat"]:
|
||||
d = open(os.path.join(base, f), "rb").read()
|
||||
body = d[2:]
|
||||
dec = bytes(body[i] ^ key[i % len(key)] for i in range(len(body)))
|
||||
assert enc(dec) == d, f
|
||||
print("round-trip OK")
|
||||
Reference in New Issue
Block a user