Files
2026-11-23 04:26:37 +02:00

22 lines
1.2 KiB
Python

"""Extract the 88 baked DB2 tables (enUS ROOT cells) from content fe8cc5d8 into base/ as the re-bake input."""
import json, struct, sys
from pathlib import Path
H = Path(__file__).resolve().parent; sys.path.insert(0, str(H))
import frozen_store as fs
T = json.load(open('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/db2-bake-20261122/tables.json'))
want = {v['fdid']: k for k, v in T.items()}
store = fs.Store(); root = store.root; lay = store.layout; assert lay['root_md5'] == fs.ROOT
cells = {}
for g in lay['groups']:
if not (g['locale'] & 2) or g.get('flags1'): continue
f = 0
for i, (d,) in enumerate(struct.iter_unpack('<I', memoryview(root)[g['ids_offset']:g['ckeys_offset']])):
f += d
if f in want: cells.setdefault(f, []).append(root[g['ckeys_offset'] + i * 16:g['ckeys_offset'] + i * 16 + 16].hex())
f += 1
out = H / 'base'; out.mkdir(exist_ok=True); keys = {}
for fid, name in want.items():
ck = cells.get(fid, []); assert len(set(ck)) == 1, (name, ck)
(out / f'{name}.db2').write_bytes(store.read(ck[0])[2]); keys[name] = dict(fdid=fid, content_key=ck[0])
(H / 'base-keys.json').write_text(json.dumps(keys, indent=1) + '\n'); print('extracted', len(keys))