Files

90 lines
7.8 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[5]/'ops'))
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/stacks-0407-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 = '2f85a7e987698bf473070dfa19ca6ab7'
BUILD = '0407863e1d6ffd6f8023b141be464b99'
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=[d/'physical/Data/data' for d in (PARENT,Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/item-sickle7-0f89-frozen-candidate'),Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/item-helms6-2ecc-frozen-candidate'),Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/item-helms5-8b18-frozen-candidate'),Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/item-models4-8491-frozen-candidate'),Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/client-version-049a-frozen-candidate'),Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/item-modelmat-8931-frozen-candidate'),Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/item-displays3-200f-frozen-candidate'),Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/item-displays2-76ed-frozen-candidate'),Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/item-displays-aba0-frozen-candidate'),Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/loadscreens-f301-frozen-candidate'),Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/shop-previews-1106-frozen-candidate'),Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/octoshop-49a1-frozen-candidate'),Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/db2-rebake-3c64-frozen-candidate'),Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/roar-sync-fe8c-frozen-candidate'),Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/onyx-roar-3aa0-frozen-candidate'),Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/mount-sounds-3e57-frozen-candidate'),Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/helm-hd-78ff-frozen-candidate'),Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/drake-roar-4371-20261122/candidate'),Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/wmo-outdoor-9547-20261122/candidate'),CODEX9547,PORT1,RUDE,DRAKE,BLOB,BAKE45,HELM,BUS/'post-431f-content-20261121/candidate',BUS/'e250-grouped-physical-successor-20261121/candidate',BUS/'catalogue-physical-ac99-20261121/candidate',BUS/'next-content-child-c425-20261121/candidate',BUS/'next-content-child-23f6-20261121/candidate',BUS/'linux-combined-faf3-20261121/candidate')]
self.archives.append(CLIENT)
self.archives.extend(OLDER/n/'Data/data' for n in ('combined-client','charselect-ready-candidate/store','native-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)