Files

30 lines
1.8 KiB
Python

import sys,struct,collections,json,random
sys.path.insert(0,'/mnt/Games/@project/wt-master-merge/ops')
sys.path.insert(0,'/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/content/prune-56ec-20261125')
import m2_format_compare as fc, frozen_store as fs
def s16(v):return v-65536 if v>32767 else v
st=fs.Store();root=st.root;cell={}
for g in st.layout['groups']:
if not g['locale']&2 or g.get('flags1'):continue
f=0
for i,(d,) in enumerate(struct.iter_unpack('<I',memoryview(root)[g['ids_offset']:g['ckeys_offset']])):
f+=d;cell.setdefault(f,root[g['ckeys_offset']+16*i:g['ckeys_offset']+16*i+16].hex());f+=1
lf={}
for l in open('/mnt/Games/@project/listfiles/community-listfile.csv',errors='replace'):
i,_,p=l.rstrip('\n').partition(';');lf[p.lower()]=int(i)
ms=[p for p in lf if p.startswith(('item/objectcomponents/weapon/','item/objectcomponents/shield/')) and p.endswith('.m2') and lf[p] in cell and lf.get(p[:-3]+'00.skin') in cell]
C=collections.Counter();ex={}
for p in ms:
try:
m=st.read(cell[lf[p]])[2];sk=st.read(cell[lf[p[:-3]+'00.skin']])[2]
t=fc.model(m);ts=fc.skin(t,sk);b=t['body']
mc,mo=struct.unpack_from('<II',b,112);mats=list(struct.iter_unpack('<HH',b[mo:mo+4*mc]))
cn,co=struct.unpack_from('<II',b,136);coord=[s16(x[0]) for x in struct.iter_unpack('<H',b[co:co+2*cn])]
flags=struct.unpack_from('<I',b,16)[0]
except Exception as e: C[('ERR',str(e)[:40])]+=1;continue
for r in ts['summary']['batch_rows']:
n=r[8];bl=tuple(mats[r[6]+k][1] if r[6]+k<len(mats) else None for k in range(n));cv=tuple(coord[r[10]+k] if r[10]+k<len(coord) else None for k in range(n))
k=(n,bl,cv,hex(r[2]),'combos' if flags&8 else '')
C[k]+=1;ex.setdefault(k,p)
for k,v in C.most_common(60):print(v,k,ex.get(k,''))