From e255348f527679b991dffbd929f5d71fd70a59ab Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Wed, 21 Oct 2026 10:02:30 +0200 Subject: [PATCH] fix: read mame hiscore.dat where the cores open it mame2000 opens hiscore.dat, history.dat and mameinfo.dat from IMAMEBASEPATH, the content directory (src/libretro/fileio.c:1002-1014, libretro.c:1044-1052). mame2014 and mame2015 open hiscore.dat through emu_file with no search path, the working directory (src/emu/hiscore.c:330-337, fileio.c:141-143). With no load_from the entries claimed system/ and the packs shipped files neither core opens there. ANoteOutsideTheSystemDirCarriesLoadFrom holds libretro notes and load_from together. --- emulators/mame2000.yml | 15 +++++++++------ emulators/mame2014.yml | 1 + emulators/mame2015.yml | 1 + tests/test_audit_regressions.py | 30 ++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/emulators/mame2000.yml b/emulators/mame2000.yml index b840fe1e..a29ae3bc 100644 --- a/emulators/mame2000.yml +++ b/emulators/mame2000.yml @@ -34,15 +34,16 @@ notes: | files: - name: hiscore.dat + load_from: content_dir required: false category: game_data system: arcade sha1: "21ddda0c61bd4f1cc04fb9d09e16d403d620f9e8" md5: "9b262149ec70cbda741a8ba55784f8e1" size: 36182 - source_ref: "src/hiscore.c:18,132-146,252-254, src/cpuintrf.c:664-666" + source_ref: "src/hiscore.c:18,132-146,252-254, src/cpuintrf.c:664-666, src/libretro/fileio.c:1002-1014, src/libretro/libretro.c:1044-1052" note: >- - high score definitions, loaded from ROM directory. metadata/hiscore.dat + high score definitions, opened from IMAMEBASEPATH, the directory of the loaded content. metadata/hiscore.dat of the core repository. is_mem_range reads only "cpu:addr:len:start:end" lines under a "gamename:" header. @@ -55,18 +56,20 @@ files: note: "cheat definitions, loaded from system_dir/mame2000/cheat/" - name: history.dat + load_from: content_dir required: false category: game_data system: arcade - source_ref: "src/datafile.c:52,281,541" - note: "game history database, loaded from ROM directory" + source_ref: "src/datafile.c:52,281,541, src/libretro/fileio.c:1002-1014" + note: "game history database, opened from IMAMEBASEPATH, the directory of the loaded content" - name: mameinfo.dat + load_from: content_dir required: false category: game_data system: arcade - source_ref: "src/datafile.c:53,281,568" - note: "game technical info database, loaded from ROM directory" + source_ref: "src/datafile.c:53,281,568, src/libretro/fileio.c:1002-1014" + note: "game technical info database, opened from IMAMEBASEPATH, the directory of the loaded content" - name: neogeo.zip required: true diff --git a/emulators/mame2014.yml b/emulators/mame2014.yml index 835cee5b..4fd821d0 100644 --- a/emulators/mame2014.yml +++ b/emulators/mame2014.yml @@ -102,6 +102,7 @@ notes: | files: # Data files - name: hiscore.dat + load_from: working_directory required: false category: game_data system: arcade diff --git a/emulators/mame2015.yml b/emulators/mame2015.yml index 816735dc..2c45a9cf 100644 --- a/emulators/mame2015.yml +++ b/emulators/mame2015.yml @@ -91,6 +91,7 @@ notes: | files: # Data files - name: hiscore.dat + load_from: working_directory installed_on: [recalbox] required: false category: game_data diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index 63279a06..4ec515b7 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -5511,6 +5511,36 @@ class AHashScanLabelNamesNoOtherDump(unittest.TestCase): self.assertEqual(sorted(set(clashes)), []) +class ANoteOutsideTheSystemDirCarriesLoadFrom(unittest.TestCase): + """mame2000 opens hiscore.dat, history.dat and mameinfo.dat from the + directory of the loaded content (src/libretro/fileio.c:1002-1014), and + mame2014 and mame2015 open hiscore.dat from the working directory + (src/emu/hiscore.c:330-337). Their notes said so, but no load_from did: + the entries claimed system/hiscore.dat and the RetroArch pack shipped a + file neither core opens there. A libretro entry whose note places the + read outside the system directory declares where.""" + + ELSEWHERE = re.compile( + r"\b(?:opened|read|loaded)\b[^.]*?\bfrom (?:the )?(?:working directory|" + r"ROM directory|content directory|directory of the loaded content)" + r"|IMAMEBASEPATH", + re.IGNORECASE, + ) + + def test_prose_and_load_from_agree(self): + offenders = [] + for path in sorted((ROOT / "emulators").glob("*.yml")): + profile = yaml.safe_load(path.read_text(encoding="utf-8")) or {} + if profile.get("type") != "libretro": + continue + for entry in profile.get("files") or []: + if entry.get("path") or entry.get("load_from") or entry.get("mode") == "standalone": + continue + if self.ELSEWHERE.search(str(entry.get("note") or "")): + offenders.append(f"{path.name}: {entry.get('name')}") + self.assertEqual(offenders, []) + + class ReportsHoldTheDataTrees(unittest.TestCase): """Run on their own, the README, site and slot reports resolved against data/ without the shared hold, so a concurrent refresh could swap a tree