37 lines
2.3 KiB
Python
37 lines
2.3 KiB
Python
import json, struct, sys, collections, pickle
|
|
sys.path.insert(0, '.')
|
|
import octo_mpq as O
|
|
from recover_bindings import chunks
|
|
MAPS = {26:'PVPZone05',27:'Sunnyglade',451:'development',532:'Karazahn',800:'KarazhanCrypt',801:'Moomoo',802:'Grove',807:'EmeraldSanctum',813:'Winterveil',814:'Karazahn40',815:'Giln',817:'HighElfPVP',821:'netherstormbg'}
|
|
RB = json.load(open('recovered-bindings.json'))
|
|
rm = {p: int(max(c, key=c.get)) for p, c in RB['models'].items()}; rw = {p: int(max(c, key=c.get)) for p, c in RB['wmos'].items()}
|
|
ids = pickle.load(open('/tmp/claude-1000/-home-praxis-Projects/8c775e16-46f6-4cfc-9a63-844a8b79c754/scratchpad/cr/root-ids.pkl', 'rb'))
|
|
LF = {}
|
|
for l in open('/mnt/Games/@project/listfiles/community-listfile.csv', encoding='utf-8', errors='replace'):
|
|
a, _, p = l.rstrip('\n').partition(';')
|
|
if p.endswith(('.m2', '.wmo')): LF.setdefault(p.lower(), int(a))
|
|
def bind(p, rec):
|
|
if p in rec: return rec[p], 'recovered'
|
|
q = p.replace('.mdx', '.m2').replace('.mdl', '.m2')
|
|
if q in rec: return rec[q], 'recovered'
|
|
if q in LF and LF[q] in ids: return LF[q], 'native'
|
|
return None, 'missing'
|
|
inv = {}
|
|
for mid, d in MAPS.items():
|
|
wdt = dict(chunks(O.read(f'World\\Maps\\{d}\\{d}.wdt'))); tiles = [(i % 64, i // 64) for i in range(4096) if struct.unpack_from('<I', wdt['MAIN'], i*8)[0] & 1]
|
|
need = collections.Counter(); miss = {'m2': set(), 'wmo': set()}
|
|
for x, y in tiles:
|
|
raw = O.read(f'World\\Maps\\{d}\\{d}_{x}_{y}.adt')
|
|
if raw is None: continue
|
|
c = collections.defaultdict(bytes)
|
|
for t, b in chunks(raw): c[t] += b
|
|
for kind, blob, rec in (('m2', c['MMDX'], rm), ('wmo', c['MWMO'], rw)):
|
|
for p in {x.decode('latin1').replace('\\', '/').lower() for x in blob.split(b'\0') if x}:
|
|
f, how = bind(p, rec); need[(kind, how)] += 1
|
|
if f is None: miss[kind].add(p)
|
|
inv[mid] = dict(dir=d, counts={f'{k}:{h}': n for (k, h), n in need.items()}, missing={k: sorted(v) for k, v in miss.items()})
|
|
print(mid, d, dict(sorted(inv[mid]['counts'].items())))
|
|
json.dump(inv, open('inventory.json', 'w'), indent=1)
|
|
allm = sorted({p for v in inv.values() for p in v['missing']['m2']}); allw = sorted({p for v in inv.values() for p in v['missing']['wmo']})
|
|
print('missing m2', len(allm), 'missing wmo', len(allw)); print(allw)
|