26 lines
1.6 KiB
Python
26 lines
1.6 KiB
Python
import json, struct, sys, collections
|
|
sys.path.insert(0, '.'); sys.path.insert(0, '/mnt/Games/@project/gateway/ops')
|
|
import client_read as R, octo_mpq as O, map_asset_preflight as terrain, source_map_wdt as smw
|
|
from recover_bindings import chunks, maid
|
|
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()}
|
|
CM = json.load(open('client-maps.json')); mid = sys.argv[1]; d = CM[mid]['dir']
|
|
w = R.read_fdid(CM[mid]['wdt']); tiles = maid(w)
|
|
print('installed WDT chunks', [(t, len(b)) for t, b in chunks(w)])
|
|
same = diff = 0
|
|
for (x, y), f in sorted(tiles.items()):
|
|
print((x, y), f)
|
|
src = O.read(f'World\\Maps\\{d}\\{d}_{x}_{y}.adt'); c = collections.defaultdict(bytes)
|
|
for t, b in chunks(src): c[t] += b
|
|
ids = {}
|
|
for p in {q.decode('latin1').replace('\\', '/').lower() for q in c['MMDX'].split(b'\0') if q}: ids[p] = rm.get(p, 0)
|
|
for p in {q.decode('latin1').replace('\\', '/').lower() for q in c['MWMO'].split(b'\0') if q}: ids[p] = rw.get(p, 0)
|
|
try: out, rec = terrain.adt_split_candidate(src, (x, y), file_data_ids=ids, roles=('obj0',))
|
|
except Exception as e: print(' convert error', e); continue
|
|
inst = R.read_fdid(f[1]); mine = smw.native_modf_scale(out['obj0'])[0]
|
|
if mine == inst: same += 1
|
|
else:
|
|
diff += 1; a = dict((t, b) for t, b in chunks(mine)); b = dict((t, b) for t, b in chunks(inst))
|
|
print(' DIFF', [(t, len(a.get(t, b'')), len(b.get(t, b''))) for t in sorted(set(a) | set(b)) if a.get(t) != b.get(t)])
|
|
print('obj0 same', same, 'diff', diff)
|