Files

25 lines
1.5 KiB
Python

exec(open('scan.py').read().split("C=collections.Counter()")[0])
sys.path.insert(0,'/mnt/Games/@project/gateway/ops/maps14-20261122');import octo_mpq
C=collections.Counter();ex={};st2=collections.Counter()
for p in ms:
try: src=octo_mpq.read(p.replace('/','\\'))
except Exception: src=None
if not src or src[:4]!=b'MD20' or struct.unpack_from('<I',src,4)[0]!=256: st2['no src']+=1;continue
try:
s=fc.model(src);ss=fc.skin(s)
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)
except Exception as e: st2['err']+=1;continue
if ss['faces']!=ts['faces']: st2['faces differ']+=1;continue
sb,tb=ss['summary']['batch_rows'],ts['summary']['batch_rows']
if len(sb)!=len(tb) or any(a[3]!=b[3] for a,b in zip(sb,tb)): st2['rows not aligned']+=1;continue
st2['aligned']+=1
mats=list(struct.iter_unpack('<HH',fc._extent(src,struct.unpack_from('<I',src,136)[0],struct.unpack_from('<I',src,132)[0],4,324)))
cn,co=struct.unpack_from('<II',src,156);coord=[s16(x[0]) for x in struct.iter_unpack('<H',src[co:co+2*cn])]
for a,b in zip(sb,tb):
if a[8]<2:continue
bl=tuple(mats[a[6]+k][1] if a[6]+k<len(mats) else None for k in range(a[8]));cv=tuple(coord[a[10]+k] if a[10]+k<len(coord) else None for k in range(a[8]))
k=('src',a[0],a[1],a[2],'ops',a[8],bl,cv,'-> native',b[0],b[1],hex(b[2]),'ops',b[8],'mat same',a[6]==b[6],'coord same',a[10]==b[10])
C[k]+=1;ex.setdefault(k,p)
print(dict(st2))
for k,v in C.most_common(50):print(v,k,ex[k])