55 lines
3.7 KiB
Python
55 lines
3.7 KiB
Python
"""Octo helms batch 5 (2026-11-23) on content 84918c1c: 16 helm displays / 17 items on per-race heads already in the
|
|
client (build5.py): ModelFileData + ComponentModelFileData per race file, display rows, ItemDisplayInfoModelMatRes."""
|
|
import json, hashlib, struct, sys
|
|
from pathlib import Path
|
|
H = Path(__file__).resolve().parent; sys.path.insert(0, str(H))
|
|
import frozen_store as fs
|
|
md5 = lambda b: hashlib.md5(b).hexdigest(); sha = lambda b: hashlib.sha256(b).hexdigest()
|
|
TABLES = [(f, f'dbfilesclient/{n.lower()}.db2', H/'inputs/before'/f'{n}.db2', H/'inputs/after'/f'{n}.db2') for f, n in
|
|
[(1266429, 'ItemDisplayInfo'), (982459, 'TextureFileData'), (982462, 'ItemAppearance'), (982457, 'ItemModifiedAppearance'),
|
|
(1337833, 'ModelFileData'), (1349053, 'ComponentModelFileData'), (4050937, 'ItemDisplayInfoModelMatRes')]]
|
|
ALIAS = json.load(open('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/item-displays-20261123/add5-alias.json'))
|
|
ART = []
|
|
WHY = 'Octo helms batch 5: 16 helm displays / 17 items on existing per-race heads'
|
|
store = fs.Store(); root = store.root; lay = store.layout; assert lay['root_md5'] == fs.ROOT
|
|
patched = bytearray(root); pins = []
|
|
for fid, name, src, out in TABLES:
|
|
cells = []
|
|
for g in lay['groups']:
|
|
f = 0
|
|
for i, (d,) in enumerate(struct.iter_unpack('<I', memoryview(root)[g['ids_offset']:g['ckeys_offset']])):
|
|
f += d
|
|
if f == fid: cells.append((g, g['ckeys_offset'] + i * 16))
|
|
f += 1
|
|
en = [(g, at) for g, at in cells if g['locale'] & 2 and not g.get('flags1')]; assert len(en) == 1, (fid, len(en))
|
|
g, at = en[0]; ck = root[at:at + 16].hex()
|
|
old = store.read(ck)[2]; assert old == src.read_bytes(), f'parent {name} differs from edited source'
|
|
new = out.read_bytes(); patched[at:at + 16] = bytes.fromhex(md5(new))
|
|
d = H / 'pins' / str(fid); d.mkdir(parents=True, exist_ok=True)
|
|
(d / 'before.bin').write_bytes(old); (d / 'after.bin').write_bytes(new)
|
|
pin = dict(fdid=fid, table=name, parent_root=fs.ROOT, selected_group={}, original_decoded=dict(file='before.bin', md5=ck, sha256=sha(old)),
|
|
encrypted_original=False, after_decoded=dict(file='after.bin', md5=md5(new), sha256=sha(new)), reason=WHY)
|
|
(d / 'pin.json').write_text(json.dumps(pin, indent=1) + '\n')
|
|
pins.append(dict(file=str(d / 'pin.json'), sha256=sha((d / 'pin.json').read_bytes()), type='wdc_enus'))
|
|
want = {x['source_fdid'] for x in ALIAS}; got = {}
|
|
for g in lay['groups']:
|
|
if not (g['locale'] & 2) or g.get('flags1'): continue
|
|
f = 0
|
|
for i, (dd,) in enumerate(struct.iter_unpack('<I', memoryview(root)[g['ids_offset']:g['ckeys_offset']])):
|
|
f += dd
|
|
if f in want and f not in got: at = g['ckeys_offset'] + i * 16; got[f] = store.read(root[at:at + 16].hex())[2]
|
|
f += 1
|
|
(H / 'inputs/alias').mkdir(exist_ok=True)
|
|
for x in ALIAS:
|
|
raw = got[x['source_fdid']]; assert raw[:4] == b'MD21'; p = H / 'inputs/alias' / f"{x['file_data_id']}.m2"; p.write_bytes(raw)
|
|
ART.append(dict(file_data_id=x['file_data_id'], path=x['path'], ckey=md5(raw), kind='M2', file=str(p)))
|
|
assets = []
|
|
for a in ART:
|
|
raw = Path(a['file']).read_bytes(); assert md5(raw) == a['ckey']
|
|
assets.append(dict(a, sha256=sha(raw)))
|
|
art = H / 'pins' / 'models-art.json'; raw = (json.dumps(dict(type='art', parent_root=fs.ROOT, assets=assets), indent=1) + '\n').encode()
|
|
art.parent.mkdir(exist_ok=True); art.write_bytes(raw); pins.append(dict(file=str(art), sha256=sha(raw), type='art'))
|
|
(H / 'components.json').write_text(json.dumps(pins, indent=2) + '\n')
|
|
(H / 'selected-root.json').write_text(json.dumps(dict(parent_build=fs.BUILD, parent_root=fs.ROOT, decoded_root_sha256=sha(bytes(patched)), parent_root_sha256=sha(root)), indent=2) + '\n')
|
|
print('pins', len(pins))
|