58 lines
2.8 KiB
Python
Executable File
58 lines
2.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Catalogue-wide rule (#63, 2026-11-25): one row per (SpellID, DifficultyID) in difficulty-keyed spell DB2 tables.
|
|
|
|
The client asserts 'Duplicate difficulty records detected' (SpellLookupCache.h:176) at login when a spell has two rows
|
|
with the same DifficultyID (High Elf Meditation 46021/52524/52525: hotfix-push rows baked in 3c644128 plus a later
|
|
import's copies). For every group of rows identical except for ID, keep the lowest ID (the original/pushed row, which
|
|
the codec's hotfix push also names) and delete the rest. Groups that differ in content are reported, never touched.
|
|
|
|
usage: dedupe.py <db2-dir> <WoWDBDefs/definitions> <out-dir> (needs Db2Bake with delrows; prints a summary)
|
|
Run after every spell import/bake; 0 deletions = clean.
|
|
"""
|
|
import collections
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
DB2BAKE = '/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/db2-bake-20261122/tool/bin/Release/net10.0/Db2Bake.dll'
|
|
TABLES = ['SpellMisc', 'SpellCooldowns', 'SpellCategories', 'SpellAuraOptions', 'SpellLevels', 'SpellInterrupts',
|
|
'SpellTargetRestrictions', 'SpellClassOptions', 'SpellEquippedItems', 'SpellShapeshift', 'SpellTotems',
|
|
'SpellReagents', 'SpellCastingRequirements', 'SpellXSpellVisual']
|
|
|
|
|
|
def rows(src, defs, t):
|
|
out = subprocess.run(['dotnet', DB2BAKE, 'dump', src, defs, t], capture_output=True, text=True, check=True).stdout
|
|
for line in out.splitlines():
|
|
f = dict(x.split('=', 1) for x in line.split('\t')[1:] if '=' in x)
|
|
yield int(f.pop('ID')), f
|
|
|
|
|
|
def main(src, defs, outdir):
|
|
out = Path(outdir); out.mkdir(parents=True, exist_ok=True); total = 0; conflicts = []
|
|
for t in TABLES:
|
|
if not (Path(src) / f'{t}.db2').exists():
|
|
continue
|
|
groups = collections.defaultdict(list)
|
|
for rid, f in rows(src, defs, t):
|
|
key = (f.get('SpellID'), f.get('DifficultyID', '-'))
|
|
if t == 'SpellXSpellVisual': # several visuals per spell are legal; only exact copies are duplicates
|
|
key = tuple(sorted(f.items()))
|
|
groups[key].append((rid, tuple(sorted(f.items()))))
|
|
drop = []
|
|
for key, g in groups.items():
|
|
if len(g) < 2:
|
|
continue
|
|
if len({c for _, c in g}) == 1:
|
|
drop += sorted(r for r, _ in g)[1:]
|
|
else:
|
|
conflicts.append((t, key[:2], [r for r, _ in g]))
|
|
if drop:
|
|
subprocess.run(['dotnet', DB2BAKE, 'delrows', src, defs, t, ','.join(map(str, drop)), str(out / f'{t}.db2')], check=True)
|
|
print(f'{t}\tremoved {len(drop)}\t{drop[:12]}')
|
|
total += len(drop)
|
|
print('total removed', total, 'conflicts (left alone)', len(conflicts), conflicts[:10])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main(*sys.argv[1:4])
|