Files

136 lines
13 KiB
Python

"""#76 item paint (all item types) on 50ca70b5. Before: #76 helm paint (item-slot materials) on 294c9b3d. Before: #64 autocomplete name trim on edadc83e. Before: #73 whisper-inform tab filter trimmed on d157e44a. Before: #63 spell row dedupe on 2213d98f. Before: #56 dance211 Undead full model on 77ddf8d6. Before: #56 dance211 fix (client lookup probe + Undead normal model variant) on bccb5019. Before: dance211 on a2f86df2 (helmnat). Earlier: #12 Octo spell presentation rows on c2bf052d (GO models step). 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/helmpaint-50ca-frozen-candidate')
PREV294C = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/whispertrim-294c-frozen-candidate')
PREVEDAD = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/whisperinform-edad-frozen-candidate')
PREVD157 = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/spelldedup-d157-frozen-candidate')
PREV2213 = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/dance211und-2213-frozen-candidate')
PREV77DD = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/dance211fix-77dd-frozen-candidate')
PREVBCCB = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/dance211-bccb-frozen-candidate')
PREVA2F8 = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/helmnat-a2f8-frozen-candidate')
PREV6784 = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/wmoscale-6784-frozen-candidate')
PREV5492 = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/boats-5492-frozen-candidate')
PREVE64B = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/rude2-e64b-frozen-candidate')
PREVB982 = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/detail-b982-frozen-candidate')
PREV5DCE = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/startkit-5dce-frozen-candidate')
PREV300B = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/sdmap-300b-frozen-candidate')
PREV5002 = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/sdopt-5002-frozen-candidate')
PREV7ADF = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/hebody-7adf-frozen-candidate')
PREV5D37 = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/sdrace-5d37-frozen-candidate')
PREVF59E = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/animfix-f59e-frozen-candidate')
PREVF72D = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/spellvis-f72d-frozen-candidate')
PREVE961 = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/spellport-e961-frozen-candidate')
PREVC2BF = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/gomodels-c2bf-frozen-candidate')
PREV2AD1 = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/actionbar-2ad1-frozen-candidate')
PREV8AB7 = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/version-8ab7-frozen-candidate')
PREV2076 = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/models8-2076-frozen-candidate')
PREV265F = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/prune-265f-frozen-candidate')
PREV56EC = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/whisper-56ec-frozen-candidate')
PREV3510 = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/version-3510-frozen-candidate')
PREVB95E = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/shipne-b95e-frozen-candidate')
PREVF521 = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/taxiroutes-f521-frozen-candidate')
PREV5647 = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/drakeswap-5647-frozen-candidate')
PREV4983 = Path('/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/mailrealm-4983-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 = 'c043c255b4ef6165237e3af79a08463c'
BUILD = '50ca70b51ce2d72c4bfa9f3e487a9aa4'
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,PREV294C,PREVEDAD,PREVD157,PREV2213,PREV77DD,PREVBCCB,PREVA2F8,PREV6784,PREV5492,PREVE64B,PREVB982,PREV5DCE,PREV300B,PREV5002,PREV7ADF,PREV5D37,PREVF59E,PREVF72D,PREVE961,PREVC2BF,PREV2AD1,PREV8AB7,PREV2076,PREV265F,PREV56EC,PREV3510,PREVB95E,PREVF521,PREV5647,PREV4983,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)
from casc_compact import read_indexes
self.local_rows={}
for _,_,lay in read_indexes(CLIENT,api).values():
for r in lay['rows']:self.local_rows.setdefault(r[:9],r)
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')
lr=self.local_rows.get(key[:9])
if lr:
pos=int.from_bytes(lr[9:14],'big');path=CLIENT/f'data.{pos>>30:03d}';off=pos%2**30;sp=int.from_bytes(lr[14:18],'little')
with path.open('rb') as f:
f.seek(off);block=f.read(sp)
frame=block if block[:4]==b'BLTE' else block[30:]
try:
if len(frame)==size and casc.blte_encoding_key(frame)==key:
body=casc.decode_blte(frame,encoding_key=key.hex(),content_key=ck,max_decoded=536870912)
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=sp)
except ValueError:pass
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)