42 lines
4.0 KiB
Python
42 lines
4.0 KiB
Python
"""Write the enUS pin for onyxiamount.m2 (Octo-style jump/fall wing flap) on dece."""
|
|
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={841604:('dbfilesclient/broadcasttext.db2',Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/octo-dbc-diff-20261122')/'bt/BroadcastText.db2',Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/db2-bake-20261122')/'extra/BroadcastText.db2','13417 NPC/gossip texts the gateway served at runtime (pinned enUS index 78566423)'),
|
|
1343602:('dbfilesclient/emotes.db2',Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/octo-dbc-diff-20261122')/'em/Emotes.db2',Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/db2-bake-20261122')/'extra/Emotes.db2','40 Turtle emote states (400/401 -> 1160/1161)'),
|
|
1347273:('dbfilesclient/emotestext.db2',Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/octo-dbc-diff-20261122')/'em/EmotesText.db2',Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/db2-bake-20261122')/'extra/EmotesText.db2','DANCESPECIAL 523, READYJOUST 366'),
|
|
1283024:('dbfilesclient/emotestextdata.db2',Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/octo-dbc-diff-20261122')/'em/EmotesTextData.db2',Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/db2-bake-20261122')/'extra/EmotesTextData.db2','messages for the two text emotes'),
|
|
1394440:('dbfilesclient/globalstrings.db2',Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/octo-dbc-diff-20261122')/'em/GlobalStrings.db2',Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/db2-bake-20261122')/'extra/GlobalStrings.db2','EMOTE172/173 TOKEN+CMD1: /dancespecial /readyjoust')}
|
|
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()
|
|
encrypted=ckey!=md5(old)
|
|
if encrypted: # undecryptable sections read back as zeros (db2-bake rule): require a WDC5 section with a TACT key
|
|
sc=struct.unpack_from('<I',old,200)[0]; assert old[:4]==b'WDC5' and any(struct.unpack_from('<Q',old,204+k*40)[0] for k in range(sc)),(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=encrypted,
|
|
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))
|