Files

38 lines
3.0 KiB
Python

"""#60 WMO doodad scale on 5492 (2026-11-25): three converted WMO roots carried one zero-scale MODD doodad each; pin to 0.001 like the C01 converted-WMO rule."""
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={8556932:('wmo-8556932.wmo',H/'inputs/before-8556932.wmo',H/'inputs/after-8556932.wmo','#60: zero-scale MODD doodad -> 0.001 (native_wmo_doodad_scales); scale 0 gives the client a singular doodad transform (BaseModel.cpp:685 assert, orccratebroken03 199105 at -11007,-2061,68)'),
8660540:('wmo-8660540.wmo',H/'inputs/before-8660540.wmo',H/'inputs/after-8660540.wmo','#60: zero-scale MODD doodad -> 0.001 (native_wmo_doodad_scales); scale 0 gives the client a singular doodad transform (BaseModel.cpp:685 assert, orccratebroken03 199105 at -11007,-2061,68)'),
8720613:('wmo-8720613.wmo',H/'inputs/before-8720613.wmo',H/'inputs/after-8720613.wmo','#60: zero-scale MODD doodad -> 0.001 (native_wmo_doodad_scales); scale 0 gives the client a singular doodad transform (BaseModel.cpp:685 assert, orccratebroken03 199105 at -11007,-2061,68)')}
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))