This repository has been archived on 2026-09-16. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Syplheed-Reborn/tools/re-capture/prt_parts.py
Sylpheed RE agent 94065d40ec re: where .prt screen parts live; the five mission banners are a real exception
Read first, as the rule now requires: ui-prm-primitives.md,
ui-rat-layout.md, ui-screen-runtime.md -- they own the .prt/RATC/T8aD
stack but describe element names inside bundles, not where parts live.

A .prt IS a pak entry, under a LANGUAGE directory.  Of 376 distinct
.prt names referenced on the disc, 241 resolve as archive entries --
220 under eng\ and jpn\, 38 under each of the other four.  prbase.prt
resolves under all six; palogo1.prt under two.

All five pgmsg_*.prt resolve under nothing, across 15 prefixes that
include every language dir, so this is not the missing-prefix mistake
again.

A lead, refuted by its own control: four of the five have a same-stem
_sub.rat sub-bundle inside every per-language 2D pak, and pgmsg_update
has none -- but only 4 of 376 .prt stems have a _sub.rat, and
prbase.prt, which does ship as an entry, has none.  Not the container
convention, not adopted.

An intermediate pass nearly reported 'the five appear only in the
manifest'; that was wrong because the token census was truncated by a
slice and the RATC hits were pgmsg_start_sub.rat, a longer token.

New artefact and regenerator; the other six regenerate byte-identical.
2026-08-27 14:01:24 +00:00

65 lines
2.6 KiB
Python

#!/usr/bin/env python3
"""Where `.prt` screen parts live, and why the five mission banners do not.
Regenerates docs/re/data/prt-parts.txt.
"""
import sys, os, glob, re, collections
HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, HERE)
import unitgroup as U
from unit_substructures import pak_entries
FIVE = ['pgmsg_start.prt', 'pgmsg_end.prt', 'pgmsg_update.prt',
'pgmsg_failed.prt', 'pgmsg_restart.prt']
PRE = ['', 'Stage\\', 'stage\\', 'message\\', 'language\\', '2d\\', 'ui\\', 'prt\\',
'view\\'] + [l + '\\' for l in ('eng', 'jpn', 'fra', 'deu', 'ita', 'esp')]
def main():
H = collections.defaultdict(set)
names = set()
rat = collections.defaultdict(set)
for pk in sorted(glob.glob('/work/sylph_extract/**/*.pak', recursive=True)):
base = os.path.basename(pk)
for h, b in pak_entries(pk):
H[h].add(base)
for m in re.finditer(rb'[A-Za-z0-9_]{3,40}\.prt', b):
names.add(m.group(0).decode())
if b[:4] == b'RATC':
for m in re.finditer(rb'[A-Za-z0-9_]{3,40}_sub\.rat', b):
rat[m.group(0).decode()].add(base)
print("# Where `.prt` screen parts live")
print("# Regenerate: python3 tools/re-capture/prt_parts.py")
print("# See docs/re/structures/mission-script-manifest.md")
byp = collections.Counter()
hit = set()
for n in names:
for p in PRE:
if U.name_hash(p + n) in H:
byp[p] += 1; hit.add(n)
print("\n## `.prt` IS a pak entry name -- under a LANGUAGE directory")
print(" distinct .prt names referenced anywhere : %d" % len(names))
print(" resolving as a pak entry : %d" % len(hit))
for p, c in byp.most_common():
print(" prefix %-8s %3d" % (repr(p), c))
print("\n## the five mission-banner parts")
for n in FIVE + ['prbase.prt', 'palogo1.prt']:
ok = [p or '<bare>' for p in PRE if U.name_hash(p + n) in H]
print(" %-20s resolves under: %s" % (n, ok if ok else 'NOTHING'))
print("\n## `<stem>_sub.rat` sub-bundles inside RATC")
print(" distinct _sub.rat names: %d" % len(rat))
for k in sorted(rat):
print(" %-26s in %d archives %s" % (k, len(rat[k]), sorted(rat[k])[:2]))
stems_prt = {n[:-4] for n in names}
stems_rat = {k[:-8] for k in rat}
print(" CONTROL .prt stems that have a _sub.rat: %d / %d -- so this is NOT the general"
% (len(stems_prt & stems_rat), len(stems_prt)))
print(" container convention; `prbase` has a .prt entry and no _sub.rat.")
if __name__ == "__main__":
main()