From e77a036e0e24efdac9c15e8d4d32524ef4d20e7c Mon Sep 17 00:00:00 2001 From: prenoeg Date: Mon, 14 Oct 2024 19:53:29 -0700 Subject: [PATCH] Fixes for PlayStation RetroAchievements hashing (#4085) * Fixed RA hash for PlayStation games when BOOT line contains tabs where spaces are expected. * Fixed RA hash and prevented infinite loop when PlayStation executable is in subdirectory. --- .../RetroAchievements.GameVerification.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/BizHawk.Client.EmuHawk/RetroAchievements/RetroAchievements.GameVerification.cs b/src/BizHawk.Client.EmuHawk/RetroAchievements/RetroAchievements.GameVerification.cs index 3e22633583..fe28fb9da9 100644 --- a/src/BizHawk.Client.EmuHawk/RetroAchievements/RetroAchievements.GameVerification.cs +++ b/src/BizHawk.Client.EmuHawk/RetroAchievements/RetroAchievements.GameVerification.cs @@ -97,6 +97,15 @@ namespace BizHawk.Client.EmuHawk return (buf2048[index + 4] << 16) | (buf2048[index + 3] << 8) | buf2048[index + 2]; } } + + // move on to next sector if filename not found in current sector due to subdirectory + if (buf2048[index] == 0) + { + dsr.ReadLBA_2048(++sector, buf2048, 0); + index = 0; + continue; + } + index += buf2048[index]; } @@ -114,6 +123,9 @@ namespace BizHawk.Client.EmuHawk dsr.ReadLBA_2048(sector, buf2048, 0); exePath = Encoding.ASCII.GetString(buf2048); + // replace any tab characters with space characters to normalize exePath + exePath = exePath.Replace('\t', ' '); + // "BOOT = cdrom:" precedes the path var index = exePath.IndexOf("BOOT = cdrom:", StringComparison.Ordinal); if (index < -1) break;