Files
WoW-Hybrid-gateway/ops/aura_subset_admission.py

92 lines
5.0 KiB
Python

#!/usr/bin/env python3
"""Admit held auras whose native definition only ADDS aura effects.
The 2026-11-11 catalogue (aura_definition_profile.py generate-catalogue) holds a
source aura when its native aura-installing effect indices differ from the
source ones. Modern data often appends effects to a classic spell (Shadowform
15473: source 0,1,2 = auras 36/79/87; native 0..4 = 36/79/87/72/108). Those
auras were never sent, so neither buff nor state kit showed.
Admission here: server spell_template and Octo Spell.dbc agree on the source
aura indices, every source index exists natively with the SAME aura type, and
the mask = the source indices only (extra native effects stay inactive).
Native = the installed client's baked SpellEffect / SpellXSpellVisual DB2s.
Baseline rows always win; this only adds spell IDs.
2026-11-26 (#109, Find Trees 52917 never on the buff bar): the 11-11 catalogue also held 2981 auras with "no native
definition", from before the Octo spells were ported into the client DB2s (#12). Those are now read from the same baked
DB2s with the same rule; for them the native aura indices may also equal the source indices.
usage: aura_subset_admission.py <catalogue.json> <Spell.dbc> <baked-db2-dir> <report.json>
"""
import json
import sys
from collections import Counter
from pathlib import Path
HERE = Path(__file__).resolve().parent
sys.path.insert(0, str(HERE))
sys.path.insert(0, str(HERE / 'claude_recipe_parity'))
import aura_definition_profile as adp
import aura_visual_profile
import dbd
ROOT = HERE.parent
def main(catalogue, dbc, baked, report):
HELD = ('native aura effect indices differ', 'no native definition (local DB2 or package)')
held = sorted(r['spell'] for r in json.loads(Path(catalogue).read_text())['held'] if r['reason'] in HELD)
cols = ['entry', 'name'] + ['effect%d' % i for i in (1, 2, 3)] + ['effectApplyAuraName%d' % i for i in (1, 2, 3)]
raw = adp.db('SELECT HEX(JSON_OBJECT(' + ','.join("'%s',`%s`" % (c, c) for c in cols) +
')) FROM tw_world.spell_template WHERE entry IN (' + ','.join(map(str, held)) + ') ORDER BY entry;')
server = [json.loads(bytes.fromhex(v)) for v in raw.splitlines()]
sources = adp.load_catalogue_inputs(server, dbc)
effects = {}
for r in dbd.table('SpellEffect', str(Path(baked) / 'SpellEffect.db2'))['rows'].values():
if r.get('DifficultyID', 0) == 0:
effects.setdefault(r['SpellID'], {}).setdefault(r['EffectIndex'], []).append(r)
visuals = {}
for r in dbd.table('SpellXSpellVisual', str(Path(baked) / 'SpellXSpellVisual.db2'))['rows'].values():
if r.get('DifficultyID') == 0 and not any(r.get(k) for k in adp.VISUAL_CONDITIONS):
visuals.setdefault(r['SpellID'], []).append(r)
added, links, skipped = [], [], []
for ident in held:
views = [v for v in (sources['server'].get(ident), sources['dbc'].get(ident)) if v]
sets = {tuple(i for i in range(3) if v[1][i] in adp.SOURCE_AURA_EFFECTS) for v in views}
native = effects.get(ident)
reason = None
if len(sets) != 1:
reason = 'server/dbc indices differ'
elif not native or any(len(v) != 1 for v in native.values()):
reason = 'no or ambiguous native effects'
else:
indices = next(iter(sets))
kinds = [views[0][2][i] for i in indices]
nidx = {i for i, v in native.items() if v[0]['Effect'] in adp.NATIVE_AURA_EFFECTS}
if not indices or not set(indices) <= nidx:
reason = 'source indices not a subset of native'
elif [native[i][0].get('EffectAura') for i in indices] != kinds:
reason = 'aura type differs at a source index'
if reason:
skipped.append(dict(spell=ident, reason=reason))
continue
added.append(dict(spell=ident, active_flags=sum(1 << i for i in indices)))
v = visuals.get(ident, [])
if len(v) == 1:
links.append(dict(spell=ident, spell_x_spell_visual=v[0]['ID'], visual=v[0]['SpellVisualID']))
dpath = ROOT / 'include/gateway/aura_definition_profile.hpp'
vpath = ROOT / 'include/gateway/aura_visual_profile.hpp'
definitions = adp.merge_catalogue(adp.parse_header_rows(dpath.read_text(), 'active_flags'), added, 'active_flags')
vis = adp.merge_catalogue(adp.parse_header_rows(vpath.read_text(), 'spell_x_spell_visual'), links, 'spell_x_spell_visual')
dpath.write_text(adp.header(definitions))
vpath.write_text(aura_visual_profile.header(vis))
Path(report).write_text(json.dumps(dict(policy='source-subset-of-native-aura-indices-v2', held_input=len(held),
admitted=added, visual_links=links, skipped=skipped,
skipped_by_reason=dict(Counter(r['reason'] for r in skipped))), indent=1) + '\n')
print('held', len(held), 'admitted', len(added), 'visual links', len(links), dict(Counter(r['reason'] for r in skipped)))
if __name__ == '__main__':
main(*sys.argv[1:5])