Files
2026-11-23 03:28:32 +02:00

54 lines
2.8 KiB
Python

"""Effective client table = native DB2 rows overridden by installed hotfix rows (empty payload = delete)."""
import re,struct,sys,json,functools
sys.path.insert(0,'/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/parity/recipes-20261122')
import dbd
HDR='/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-linux-build-20261121/merge-v1/src-catalogue-5d4af6b3/include/gateway/item_sparse_compat.hpp'
def _cstr(lit):
out=bytearray();i=0
while i<len(lit):
c=lit[i]
if c=='\\':
n=lit[i+1]
if n in '01234567':
j=i+1;k=j
while k<len(lit) and k<j+3 and lit[k] in '01234567':k+=1
out.append(int(lit[j:k],8));i=k;continue
out.append({'n':10,'t':9,'r':13,'\\':92,'"':34,"'":39,'0':0}.get(n,ord(n)));i+=2;continue
out.append(ord(c));i+=1
return bytes(out)
@functools.lru_cache(None)
def hotfixes():
s=open(HDR,encoding='latin1').read()
a=s.index('PayloadBlob[]=');b=s.index(';',a)
blob=_cstr(''.join(re.findall(r'"((?:[^"\\]|\\.)*)"',s[a:b])))
i=s.index('Records[]=');recs={}
for m in re.finditer(r'\{0x([0-9a-f]{8}),(\d+),\{PayloadBlob\+(\d+),(\d+)\}',s[i:]):
recs.setdefault(int(m.group(1),16),{})[int(m.group(2))]=blob[int(m.group(3)):int(m.group(3))+int(m.group(4))]
return recs
def decode(layout,payload):
d={};p=0
for f in layout:
if 'noninline' in f['ann']:continue
vals=[]
for _ in range(f['arr']):
if f['size'] is None and f['name'].endswith(('_lang',)) or f['name'] in('NeutralDisplayName',) and f['size'] is None:
z=payload.index(b'\0',p);vals.append(payload[p:z].decode('utf8','replace'));p=z+1
elif f['size'] is None:
vals.append(struct.unpack_from('<f',payload,p)[0]);p+=4
else:
n=int(f['size'].strip('<>u'));signed=not f['size'].startswith('<u')
vals.append(int.from_bytes(payload[p:p+n//8],'little',signed=signed));p+=n//8
d[f['name']]=vals[0] if f['arr']==1 else vals
return d,len(payload)-p
def table(name):
t=dbd.table(name,f'/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/parity/recipes-20261122/native/{name}.db2')
rows={k:dict(v,_src='native') for k,v in t['rows'].items()}
hf=hotfixes().get(t['header']['table_hash'],{}); extra=set()
for rid,pl in hf.items():
if not pl: rows.pop(rid,None); continue
d,rest=decode(t['layout'],pl); extra.add(rest)
rel=[f['name'] for f in t['layout'] if 'relation' in f['ann'] and 'noninline' in f['ann']]
if rel and rest>=4: d[rel[0]]=int.from_bytes(pl[-4:],'little')
d['ID']=rid; d['_src']='hotfix'; rows[rid]=d
return dict(rows=rows,hotfix_count=len(hf),trailing=sorted(extra),table=t)