Files

37 lines
2.7 KiB
Python

"""#59 boats on e64b; template from #28 (2026-11-25): Tauren male /rude from Octo TaurenMale anim 73 with explicit digitigrade leg map (hip/knee/hock), replacing 9e58 (Undead source, legs mis-chained: ankle->knee)."""
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
C=fs.casc
SP=Path('/tmp/claude-1000/-home-praxis-Projects/8c775e16-46f6-4cfc-9a63-844a8b79c754/scratchpad')
BAKE=Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/db2-bake-20261122')
INPUTS={8573211:('ts_boat_02.m2',H/'inputs/before-8573211.m2',H/'inputs/after-8573211.m2','#59: restore native sequence hash [0,-1] on Icepoint Rock Boat creature model (f59e restored unterminated [0]; creature Walk lookup probes forever, ERROR #109)'),
8573240:('tuskarboat.m2',H/'inputs/before-8573240.m2',H/'inputs/after-8573240.m2','#59: restore native sequence hash [0,-1] on Icepoint Rock Boat creature model (f59e restored unterminated [0]; creature Walk lookup probes forever, ERROR #109)')}
root=(fs.PARENT/'decoded/root.bin').read_bytes(); lay=C.root_groups(root); assert lay['root_md5']==fs.ROOT
md5=lambda b:hashlib.md5(b).hexdigest(); sha=lambda b:hashlib.sha256(b).hexdigest()
cells={f:[] for f in INPUTS}
for g in lay['groups']:
f=0
for i,(delta,) in enumerate(struct.iter_unpack('<I',memoryview(root)[g['ids_offset']:g['ckeys_offset']])):
f+=delta
if f in cells: cells[f].append((g,g['ckeys_offset']+i*16))
f+=1
patched=bytearray(root);pins=[]
for fid,(name,before,after,why) in sorted(INPUTS.items()):
old=before.read_bytes();new=after.read_bytes()
en=[(g,at) for g,at in cells[fid] if g['locale']&2 and not g.get('flags1')]
assert len(en)==1,(fid,len(en)); g,at=en[0]; ckey=root[at:at+16].hex()
assert ckey==md5(old),(fid,ckey,md5(old))
assert sum(1 for g2,a2 in cells[fid] if root[a2:a2+16].hex()==ckey)==1
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=ckey,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'))
(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))