From 806225a5d4b4f5f587a82fb6abdecdcf62899ea1 Mon Sep 17 00:00:00 2001 From: Stanislas Daniel Claude Dolcini Date: Tue, 31 Mar 2026 00:03:27 +0100 Subject: [PATCH] Track default music tracks from music.js and cheats checkrefs.py only traced music files referenced in civ JSON Music[] arrays. Two additional sources were missed: - gui/common/music.js DEFAULT_*_TRACKS prototype arrays define fallback playlists used when a civ has no music entries. All .ogg filenames found in that file are now added as deps of the music.js root. - simulation/data/cheats/*.json files can reference audio files via Data.DefaultParameter (e.g. retroMe.json -> 0_8Bit_Bonus_Track.ogg). These are now tracked as deps of each cheat root. Fixes 10 false-positive unused-file warnings. --- source/tools/entity/checkrefs.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/source/tools/entity/checkrefs.py b/source/tools/entity/checkrefs.py index 19beb1daa6..e65adec885 100755 --- a/source/tools/entity/checkrefs.py +++ b/source/tools/entity/checkrefs.py @@ -829,6 +829,32 @@ class CheckRefs: civ = load(f) for music in civ.get("Music", []): self.deps.append((fp, Path(f"audio/music/{music['File']}"))) + self._add_default_music_tracks() + + def _add_default_music_tracks(self): + """Add music tracks that are hardcoded as fallback defaults in gui/common/music.js + and audio files referenced in cheat definitions.""" + music_js_fp = Path("gui/common/music.js") + music_js_ffp = None + for mod in self.mods: + candidate = self.vfs_root / mod / music_js_fp + if candidate.exists(): + music_js_ffp = candidate + if music_js_ffp is not None: + self.files.append(music_js_fp) + self.roots.append(music_js_fp) + content = music_js_ffp.read_text(encoding="utf-8") + for track in re.findall(r'"([^"]+\.ogg)"', content): + self.deps.append((music_js_fp, Path(f"audio/music/{track}"))) + + for fp, ffp in self.find_files("simulation/data/cheats", "json"): + self.files.append(fp) + self.roots.append(fp) + with open(ffp, encoding="utf-8") as f: + cheat = load(f) + default_param = cheat.get("Data", {}).get("DefaultParameter", "") + if default_param.endswith(".ogg"): + self.deps.append((fp, Path(f"audio/music/{default_param}"))) def add_tips(self): self.logger.info("Loading tips...")