88 lines
5.1 KiB
Python
88 lines
5.1 KiB
Python
"""Drake JumpStart roar stage on 4371a22a (WMO outdoor). Read the selected e250 indices and locally archived immutable physical extents."""
|
|
from bisect import bisect_left, bisect_right
|
|
from functools import lru_cache
|
|
from hashlib import md5, sha256
|
|
from pathlib import Path
|
|
import json
|
|
import sys
|
|
sys.path.insert(0,str(Path(__file__).resolve().parents[1]))
|
|
import casc_asset_package as casc
|
|
from casc_local_archive import parse_index, lookup3_api, encoding_bucket
|
|
|
|
HERE = Path(__file__).resolve().parent
|
|
BUS = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/codex')
|
|
PARENT = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/faction124-cccac96c-frozen-candidate')
|
|
CODEX9547 = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/codex/nightelf-swatches-on-bd711-20261122/candidate')
|
|
CLIENT = Path('/mnt/Games/OctoWoW-LOCAL-Client/Data/data')
|
|
PORT1 = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/octo-port1-1ebe-20261122/candidate')
|
|
RUDE = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/emote-rude-9e58-20261122/candidate')
|
|
DRAKE = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/drake-anim-dece-20261122/candidate')
|
|
BLOB = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/model-blob-ee45-20261122/candidate')
|
|
BAKE45 = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/db2-bake-cf2c-20261122/candidate')
|
|
HELM = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/helm-alias-cb30-20261122/candidate')
|
|
ROOT = '49532bea4e5b96c419f424bf366cea3e'
|
|
BUILD = 'cccac96c42c324fd49b9ec88ccf305d6'
|
|
OLDER = Path('/mnt/Games/@wowhybrid/builds/Forever-Local-Disposable-20261110/runtime/faf3-combined-local-gm-20261121')
|
|
def read(path):
|
|
return json.loads(path.read_bytes())
|
|
class Store:
|
|
def __init__(self):
|
|
meta=read(PARENT/'metadata.json')
|
|
assert meta['key']==BUILD
|
|
raw=(PARENT/'decoded/encoding.bin').read_bytes()
|
|
assert md5(raw).hexdigest()==meta['encoding']['content_key']
|
|
layout=casc.encoding_layout(raw)
|
|
self.sections=layout['sections']
|
|
self.first={t:[k for k,_ in v] for t,v in self.sections.items()}
|
|
self.specs=layout['specs'][:-1].split(b'\0')
|
|
plan=read(PARENT/'stage-plan.json')
|
|
self.root=(PARENT/'decoded/root.bin').read_bytes()
|
|
self.layout=casc.root_groups(self.root)
|
|
assert self.layout['root_md5']==ROOT
|
|
api,_=lookup3_api()
|
|
self.archives=[PARENT/'physical/Data/data', CLIENT]
|
|
self.index={}
|
|
self.index_paths={}
|
|
guards={r['target']:r['sha256'] for r in plan['preconditions']['existing_exact_sha256']+plan['forward']['copy_verified_files']}
|
|
for b,name in plan['forward']['selected_index_generation_exact'].items():
|
|
path=next(p for d in (self.archives[0],PARENT/'rollback-preimages/Data/data') if (p:=d/name).is_file())
|
|
raw=path.read_bytes()
|
|
assert sha256(raw).hexdigest()==guards['Data/data/'+name]
|
|
self.index_paths[int(b)]=path
|
|
self.index[int(b)]=parse_index(raw,int(b),api)['rows']
|
|
@lru_cache(maxsize=128)
|
|
def page(self,section,index):
|
|
return dict(casc._encoding_entries(self.sections[section][index][1],section))
|
|
def entry(self,section,key):
|
|
ix=bisect_right(self.first[section],key)-1
|
|
if ix>=0:return self.page(section,ix).get(key)
|
|
def read(self,ck,ek=None):
|
|
rec=self.entry('content',bytes.fromhex(ck))
|
|
if not rec:return
|
|
for i in range(rec[0]):
|
|
key=rec[22+16*i:38+16*i]
|
|
if ek and key.hex()!=ek:continue
|
|
rows=self.index[encoding_bucket(key)]
|
|
ix=bisect_left(rows,key[:9]); enc=self.entry('encoded',key)
|
|
if not enc:continue
|
|
size=int.from_bytes(enc[20:25],'big')
|
|
while ix<len(rows) and rows[ix][:9]==key[:9]:
|
|
r=rows[ix];ix+=1
|
|
pos=int.from_bytes(r[9:14],'big')
|
|
seg=f'data.{pos>>30:03d}'; off=pos%2**30; span=int.from_bytes(r[14:18],'little')
|
|
for folder in self.archives:
|
|
path=folder/seg
|
|
if not path.is_file() or path.stat().st_size < off+span:continue
|
|
with path.open('rb') as f:
|
|
f.seek(off);block=f.read(span)
|
|
if block[:4]==b'BLTE':skip=0
|
|
elif block[30:34]==b'BLTE':skip=30
|
|
else:continue
|
|
frame=block[skip:]
|
|
try:
|
|
if len(frame)!=size or casc.blte_encoding_key(frame)!=key:continue
|
|
body=casc.decode_blte(frame,encoding_key=key.hex(),content_key=ck,max_decoded=536870912)
|
|
except ValueError:continue
|
|
spec=self.specs[int.from_bytes(enc[16:20],'big')].decode()
|
|
return dict(content_key=ck,encoding_key=key.hex(),encoded_size=size,decoded_size=len(body),encoding_spec=spec),frame,body,dict(file=str(path),offset=off,span=span)
|