diff --git a/scripts/region.py b/scripts/region.py index 399a750d..99f79ba0 100644 --- a/scripts/region.py +++ b/scripts/region.py @@ -184,8 +184,12 @@ def build_region_index(profiles: dict) -> dict[str, dict]: # sees the union and is never dropped on ambiguity. The standalone # layout is a path of its own: GC/EUR/IPL.bin fell through to the # bare name and its five-region union, and was never reduced. + # An alias is another name the core reads for the same file: + # scph5552.bin, the name beetle_psx also opens for its European + # BIOS, stayed in a --region jp pack once scph5502.bin went. + aliases = {str(a) for a in f.get("aliases") or []} priority = f.get("priority") - for key in {path, f.get("standalone_path") or "", name} - {""}: + for key in {path, f.get("standalone_path") or "", name, *aliases} - {""}: entry = index.setdefault( key, {"regions": set(), "has_untagged": False, "emulators": [], diff --git a/tests/test_region.py b/tests/test_region.py index 2fe0d063..e2e03d29 100644 --- a/tests/test_region.py +++ b/tests/test_region.py @@ -264,6 +264,18 @@ class TestStandaloneLayoutIsIndexed(unittest.TestCase): self.assertEqual(region.lookup_regions(index, "GC/EUR/IPL.bin", "IPL.bin"), {"europe"}) self.assertIn("GC/EUR/IPL.bin", slot.build_slot_index(profiles)) + def test_an_alias_carries_the_region_of_its_file(self): + """scph5552.bin, the name beetle_psx also opens for its European + BIOS, stayed in a --region jp pack once scph5502.bin went.""" + index = region.build_region_index({"beetle_psx": {"files": [ + {"name": "scph5502.bin", "aliases": ["scph5552.bin"], + "region": ["europe", "oceania"]}, + ]}}) + self.assertEqual( + region.lookup_regions(index, "scph5552.bin", "scph5552.bin"), + {"europe", "oceania"}, + ) + class TestResolveRegionDrops(unittest.TestCase): def setUp(self):