Version 3.2.1: whole bank copies of voice lines, unique names, docs figures checked by tools/check_docs.py
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""Catalog: classification rules, naming, character labels, search; the shipped CSVs."""
|
||||
import collections
|
||||
import csv
|
||||
import os
|
||||
|
||||
@@ -104,6 +105,57 @@ def test_shipped_csvs_are_consistent():
|
||||
assert all(l.sound for ls in locs.values() for l in ls if l.kind == "p")
|
||||
|
||||
|
||||
def test_shipped_catalog_cross_references():
|
||||
"""Every reference between the shipped files points to something that exists, and every line has one
|
||||
recording and one name per language (copies aside)."""
|
||||
from ackit import subtitles
|
||||
voices = ["INT", "FRA", "ITA", "DEU", "ESN"]
|
||||
rows = {a: read_csv(os.path.join(catalog_dir(), a + ".csv")) for a in voices + ["SFX", "BANK"]}
|
||||
keys = {s.key: s for r in rows.values() for s in r}
|
||||
bank = rows["BANK"]
|
||||
# subtitles -> a voice recording of that language (INT voices for the others)
|
||||
for f in os.listdir(catalog_dir()):
|
||||
if f.startswith("SUB_") and f.endswith(".csv"):
|
||||
lang = f[4:7]
|
||||
voice = lang if lang in voices else "INT"
|
||||
for s in subtitles.read_texts(os.path.join(catalog_dir(), f), lang):
|
||||
for k in filter(None, s.sound.split(";")):
|
||||
assert k in keys, (f, s.speech, k)
|
||||
snd = keys[k]
|
||||
assert snd.archive == voice or (snd.archive == "BANK" and snd.in_language(voice)), (f, k)
|
||||
# heads of WAD recordings -> a WAD recording, never larger than it; no BANK sound is also a head
|
||||
locs = banks.read_locations(os.path.join(catalog_dir(), banks.LOCATIONS))
|
||||
for m, ls in locs.items():
|
||||
for l in ls:
|
||||
if l.kind == "p":
|
||||
assert l.sound in keys and keys[l.sound].archive in voices and l.size <= keys[l.sound].size, l
|
||||
assert "BANK:%08X" % m not in keys
|
||||
# speaker labels -> line names that exist in every voice language
|
||||
names = {L: {s.name for s in rows[L]} for L in voices}
|
||||
with open(os.path.join(catalog_dir(), "characters.csv"), encoding="utf-8") as f:
|
||||
for r in csv.DictReader(f):
|
||||
assert all(r["name"] in names[L] for L in ([r["language"]] if r["language"] else voices)), r
|
||||
# one recording per language per line (copies: a second place of the same recording, same line)
|
||||
for L in voices:
|
||||
per = collections.defaultdict(list)
|
||||
for s in rows[L] + [b for b in bank if b.line and b.in_language(L)]:
|
||||
if s.line:
|
||||
per[s.line].append(s)
|
||||
for lid, ss in per.items():
|
||||
assert len({s.sha1 for s in ss}) == 1, (L, lid, [s.key for s in ss]) # copies are identical
|
||||
assert len([s for s in ss if s.archive == "BANK"]) <= 1, (L, lid)
|
||||
# the same line has the same name in every language (the second place of a copy keeps its position name)
|
||||
common = {}
|
||||
for L in voices:
|
||||
per = collections.defaultdict(set)
|
||||
for s in rows[L]:
|
||||
if s.line:
|
||||
per[s.line].add(s.name)
|
||||
for lid, ns in per.items():
|
||||
common[lid] = common[lid] & ns if lid in common else ns
|
||||
assert all(common.values()), [k for k, v in common.items() if not v][:5]
|
||||
|
||||
|
||||
@pytest.mark.game
|
||||
def test_real_game_uses_shipped_catalog(real_game_dir):
|
||||
g = Game(real_game_dir)
|
||||
@@ -114,6 +166,17 @@ def test_real_game_uses_shipped_catalog(real_game_dir):
|
||||
assert all(s.line for s in cat.sounds if s.archive == "ITA" and s.group == "Speech") # every voice line
|
||||
s = cat.resolve("Speech_TAPE_JOKER_1#4") # position 4 in the ITA entry (the user's list name)
|
||||
assert s.category == "Interview tapes" and s.size == 44985 and s.name.startswith("Speech_TAPE_JOKER_1_")
|
||||
assert len(cat.heads) == 396 and sum(len(v) for v in cat.heads.values()) == 2101
|
||||
# bank copies of WAD recordings: 396 prefetch heads + 49 recordings also stored whole in banks
|
||||
assert len(cat.heads) == 445 and sum(len(v) for v in cat.heads.values()) == 2185
|
||||
b = cat.resolve("Play_BatmanDeviceImpact_Wood_1")
|
||||
assert b.archive == "BANK" and b.group == "SFX"
|
||||
|
||||
|
||||
@pytest.mark.game
|
||||
def test_every_name_resolves_to_its_sound(real_game_dir):
|
||||
"""A line named after its INT position (CHR_RadioScanner#1) can equal another recording's position alias
|
||||
in another language: the name wins, in every language."""
|
||||
g = Game(real_game_dir)
|
||||
for lang in g.languages:
|
||||
cat = Catalog(g, [lang, "SFX", "BANK"])
|
||||
assert all(cat.resolve(s.name) is s for s in cat.sounds), lang
|
||||
|
||||
Reference in New Issue
Block a user