1"""Check the parallel SOUNDS IDs/path initializer and DOR's two voice assets."""
2from pathlib import Path
3import re
4
5root = Path(__file__).resolve().parents[1]
6source = (root / "Sound.h").read_text(encoding="utf-8-sig")
7
8source = re.sub(r"/\*.*?\*/|//[^\n]*", "", source, flags=re.S)
9ids = re.search(r"enum SOUNDS[^\{]*\{(.*?)\};", source, re.S).group(1)
10indices = {}
11cursor = -1
12for item in ids.split(","):
13 item = item.strip()
14 if not item:
15 continue
16 parts = item.split("=", 1)
17 name = parts[0].strip()
18 if len(parts) == 1:
19 cursor += 1
20 else:
21 expr = parts[1].strip()
22 if re.fullmatch(r"-?\d+", expr):
24 else:
25 match = re.fullmatch(r"(\w+)\s*\+\s*(\d+)", expr)
26 assert match, expr
27 cursor = indices[match[1]] +
int(match[2])
28 indices[name] = cursor
29paths = re.search(r"sound_path\s*=\s*\{(.*?)\};", source, re.S).group(1)
30values = re.findall(r'"(?:\\.|[^"\\])*"', paths)
31assert indices["SOUND_ENUMERATION"] == len(values), (indices["SOUND_ENUMERATION"], len(values))
32
33
34config_slots = [slot for name, slot in indices.items() if name.startswith("SOUND_CONFIG")]
35assert config_slots == list(range(min(config_slots), max(config_slots) + 1))
36assert all(indices["SOUND_AURALUNITTESTA"] <= slot <= indices["SOUND_AURALUNITOKAY"]
37 and values[slot] == '""' for slot in config_slots)
38assert indices["SOUND_CONFIGLANDINGGEAR"] in config_slots
39assert values[indices["SOUND_THUNDER_NEAR"]] == r'"Sounds\\Weather\\near1.wav"'
40assert (root / "Sounds/VMU/config-landing-gear.mp3").stat().st_size > 1000
41assert (root / "Sounds/VMU/E-10/config-landing-gear.wav").read_bytes()[:4] == b"RIFF"
42assert not (root / "Sounds/VMU/config-landing-gear.wav").exists(), "Erin belongs in E-10"
43print(f"PASS: {len(values)} sound slots match the enum (including reserved slots); Catherine/Erin assets present")
SCRIPT_CONTROL SCRIPT_STATE const void int