Files
Sylpheed/tools/re-capture/effect_homes.py
Sylpheed RE agent 122a05735d re: _e/_f on an effect name is the binding unit's FACTION (94 of 94)
Chasing the 17 unlocated eff_l### turned up their shape first: they come in
_e/_f PAIRS - eff_l101_e + eff_l101_f, and the same for l102, l104, l105, l106,
l201, plus _e-only l010/l011/l107/l108 and _f-only l002.

Partitioning every eff_<letter><digits>_<e|f> binding by the ID letter of the
OWNING unit (one GP_MAIN_GAME_* pak = one user):

                effect _e   effect _f
  UN_e###           33          0
  UN_f###            0         61

94 of 94 agree and both off-diagonal cells are empty. The control reads the
factions straight off the IDs: UN_e### -> ADAN (42 objects), UN_f### -> TCAF
(26), UN_n### -> TTRL (2, tutorial, binding neither). So an effect ending _e
belongs to an ADAN ship and one ending _f to a TCAF ship - the same visual is
authored twice, once per faction, which is exactly why eff_l### arrives in pairs.

What the 34 unlocated ARE is now also clear, even though where they live is not.
They are one job, not a scatter: Generic binds 32 of the 34, Explosion 19,
Shell 9, Level_0 and Weapon 2 each. The binder fields rank LowerHPFxModel 252,
HitFxModel 144, then JetFxModel_00N and AfterBurnerFxModel_00N. They sit in the
six GP_MAIN_GAME_* paks at 130 bindings each plus 32 in DefTables.pak. Since
LowerHPFxModel is the damaged-ship effect, the residual is largely the
per-faction battle-damage and hit visuals. None of the 34 is a record name and
only one is a field name, so they are asset references.

Stated plainly: they remain unlocated AS ASSETS. Knowing the family and its
naming law does not say where the geometry lives - the .xpr route is exhausted
for them and the parsed pak payloads hold references, not meshes.

Also fixes a defect in the artefact shipped last commit. effect-homes.txt came
back with two equal-count lines swapped: Counter.most_common() breaks ties by
insertion order, so the package listing was not deterministic. Now sorted by
(-count, name) and verified to regenerate byte-identical twice running. This is
the corpus's own rule - any map built by iterating a set or Counter needs
sorted() - and the new tool had violated it.

The other sixteen artefacts are byte-identical; effect-homes.txt changes only in
the tie-break ordering of the five 1-count rows, with every line pairing.
2026-08-28 09:28:39 +00:00

73 lines
2.6 KiB
Python

#!/usr/bin/env python3
"""Which .xpr package holds each effect the datasheets bind.
Effect names are matched EXACTLY, not as substrings: Base.xpr contains
eff_f0002_barnhaze, so a substring test for "eff_f0002" reports a false hit for
a resource that is not there. Names are pulled as maximal [A-Za-z0-9_] runs
containing "eff_", which yields bare resource names.
Regenerates docs/re/data/effect-homes.txt.
"""
import glob, os, re, subprocess, sys, collections
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from unit_substructures import pak_entries
import unitgroup as U
XPR = '/work/sylph_extract/hidden/resource3d'
FX = re.compile(r'(FxModel|EffectName|Effect_|ShellModel|CoverModel)')
def width(n):
m = re.match(r'eff_[a-z](\d+)', n)
return len(m.group(1)) if m else 0
def main():
if not os.path.isdir(XPR):
print('disc not mounted; nothing to do'); return
home = collections.defaultdict(set)
for path in sorted(glob.glob(os.path.join(XPR, '*.xpr'))):
out = subprocess.run(['grep', '-o', '-a', '[A-Za-z0-9_]*eff_[A-Za-z0-9_]*', path],
capture_output=True, text=True, errors='replace').stdout
for name in set(out.split()):
home[name].add(os.path.basename(path))
bound = set()
for pk in sorted(glob.glob('/work/sylph_extract/**/*.pak', recursive=True)):
for _h, b in pak_entries(pk):
if b[:4] != b'IDXD':
continue
try:
recs = U.parse(b)
except Exception:
continue
for r in recs:
for _t, f, v in r['fields']:
if f and FX.search(f) and isinstance(v, str) and v.startswith('eff_'):
bound.add(v)
res = sorted(n for n in bound if n in home)
un = sorted(n for n in bound if n not in home)
print('effect names bound by a datasheet field : %d' % len(bound))
print('resolved to an .xpr package (exact name): %d' % len(res))
print('unlocated : %d' % len(un))
print()
per = collections.Counter()
for n in res:
for f in home[n]:
per[f] += 1
print('resolved, by package:')
for f, k in sorted(per.items(), key=lambda kv: (-kv[1], kv[0])):
print(' %-26s %d' % (f, k))
print()
print('by digit-width:')
for k in (3, 4, 0):
s = [n for n in bound if width(n) == k]
if s:
print(' %d-digit: %d resolved of %d' % (k, len([n for n in s if n in home]), len(s)))
print()
print('the %d unlocated, in full:' % len(un))
for n in un:
print(' %s' % n)
if __name__ == '__main__':
main()