diff --git a/CHANGELIST.md b/CHANGELIST.md index 61db3129..03c055a4 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -112,6 +112,7 @@ - Rename main application to MPF.UI - Fix build scripts - Make protection file output required +- Standardize PS1-5 outputs and parsing (Deterous) ### 3.1.9a (2024-05-21) diff --git a/MPF.Core/Utilities/InfoTool.cs b/MPF.Core/Utilities/InfoTool.cs index f592e626..e8fcc3ef 100644 --- a/MPF.Core/Utilities/InfoTool.cs +++ b/MPF.Core/Utilities/InfoTool.cs @@ -571,7 +571,7 @@ namespace MPF.Core.Utilities { using var br = new BinaryReader(File.OpenRead(sfoPath)); br.BaseStream.Seek(-0x18, SeekOrigin.End); - return new string(br.ReadChars(9)).TrimEnd('\0'); ; + return new string(br.ReadChars(9)).TrimEnd('\0').Insert(4, "-"); } catch { @@ -760,7 +760,7 @@ namespace MPF.Core.Utilities { using var br = new BinaryReader(File.OpenRead(paramSfoPath)); br.BaseStream.Seek(-0x14, SeekOrigin.End); - return new string(br.ReadChars(9)); + return new string(br.ReadChars(9)).Insert(4, "-"); } catch { @@ -853,7 +853,7 @@ namespace MPF.Core.Utilities try { - return json["disc"]?[0]?["masterDataId"]?.Value(); + return json["disc"]?[0]?["masterDataId"]?.Value()?.Insert(4, "-"); } catch { diff --git a/MPF.Frontend/SubmissionGenerator.cs b/MPF.Frontend/SubmissionGenerator.cs index 7074a224..34912fb5 100644 --- a/MPF.Frontend/SubmissionGenerator.cs +++ b/MPF.Frontend/SubmissionGenerator.cs @@ -679,20 +679,15 @@ namespace MPF.Frontend break; case RedumpSystem.KonamiPython2: - if (drive?.Name != null - && (!info.CommonDiscInfo!.CommentsSpecialFields!.ContainsKey(SiteCode.InternalSerialName) - || string.IsNullOrEmpty(info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName]))) + if (InfoTool.GetPlayStationExecutableInfo(drive?.Name, out var kp2Serial, out Region? kp2Region, out var kp2Date)) { - if (InfoTool.GetPlayStationExecutableInfo(drive.Name, out var serial, out Region? region, out var date)) - { - info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = serial ?? string.Empty; - info.CommonDiscInfo.Region ??= region; - info.CommonDiscInfo.EXEDateBuildDate ??= date; - } - - info.VersionAndEditions!.Version ??= InfoTool.GetPlayStation2Version(drive?.Name) ?? string.Empty; + if (info.CommonDiscInfo!.CommentsSpecialFields!.TryGetValue(SiteCode.InternalSerialName, out string? value) && string.IsNullOrEmpty(value)) + info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = kp2Serial ?? string.Empty; + info.CommonDiscInfo.Region ??= kp2Region; + info.CommonDiscInfo.EXEDateBuildDate ??= kp2Date; } + info.VersionAndEditions!.Version ??= InfoTool.GetPlayStation2Version(drive?.Name) ?? string.Empty; break; case RedumpSystem.KonamiSystemGV: @@ -788,16 +783,12 @@ namespace MPF.Frontend break; case RedumpSystem.SonyPlayStation: - if (drive?.Name != null - && (!info.CommonDiscInfo!.CommentsSpecialFields!.ContainsKey(SiteCode.InternalSerialName) - || string.IsNullOrEmpty(info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName]))) + if (InfoTool.GetPlayStationExecutableInfo(drive?.Name, out var psxSerial, out Region? psxRegion, out var psxDate)) { - if (InfoTool.GetPlayStationExecutableInfo(drive.Name, out var serial, out Region? region, out var date)) - { - info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = serial ?? string.Empty; - info.CommonDiscInfo.Region ??= region; - info.CommonDiscInfo.EXEDateBuildDate ??= date; - } + if (info.CommonDiscInfo!.CommentsSpecialFields!.TryGetValue(SiteCode.InternalSerialName, out string? value) && string.IsNullOrEmpty(value)) + info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = psxSerial ?? string.Empty; + info.CommonDiscInfo.Region ??= psxRegion; + info.CommonDiscInfo.EXEDateBuildDate ??= psxDate; } break; @@ -805,63 +796,44 @@ namespace MPF.Frontend case RedumpSystem.SonyPlayStation2: info.CommonDiscInfo!.LanguageSelection ??= []; - if (drive?.Name != null - && (!info.CommonDiscInfo!.CommentsSpecialFields!.ContainsKey(SiteCode.InternalSerialName) - || string.IsNullOrEmpty(info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName]))) + if (InfoTool.GetPlayStationExecutableInfo(drive?.Name, out var ps2Serial, out Region? ps2Region, out var ps2Date)) { - if (InfoTool.GetPlayStationExecutableInfo(drive.Name, out var serial, out Region? region, out var date)) - { - info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = serial ?? string.Empty; - info.CommonDiscInfo.Region ??= region; - info.CommonDiscInfo.EXEDateBuildDate ??= date; - } - - info.VersionAndEditions!.Version ??= InfoTool.GetPlayStation2Version(drive?.Name) ?? string.Empty; + if (info.CommonDiscInfo!.CommentsSpecialFields!.TryGetValue(SiteCode.InternalSerialName, out string? value) && string.IsNullOrEmpty(value)) + info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = ps2Serial ?? string.Empty; + info.CommonDiscInfo.Region ??= ps2Region; + info.CommonDiscInfo.EXEDateBuildDate ??= ps2Date; } + info.VersionAndEditions!.Version ??= InfoTool.GetPlayStation2Version(drive?.Name) ?? string.Empty; break; case RedumpSystem.SonyPlayStation3: info.Extras!.DiscKey ??= addPlaceholders ? RequiredValue : string.Empty; info.Extras.DiscID ??= addPlaceholders ? RequiredValue : string.Empty; - if (drive?.Name != null - && (!info.CommonDiscInfo!.CommentsSpecialFields!.ContainsKey(SiteCode.InternalSerialName) - || string.IsNullOrEmpty(info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName]))) - { - info.VersionAndEditions!.Version ??= InfoTool.GetPlayStation3Version(drive.Name) ?? string.Empty; - info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation3Serial(drive.Name) ?? string.Empty; - } + if (info.CommonDiscInfo!.CommentsSpecialFields!.TryGetValue(SiteCode.InternalSerialName, out string? ps3Serial) && string.IsNullOrEmpty(ps3Serial)) + info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation3Serial(drive?.Name) ?? string.Empty; - if (drive?.Name != null) - { - string? firmwareVersion = InfoTool.GetPlayStation3FirmwareVersion(drive.Name); - if (firmwareVersion != null) - info.CommonDiscInfo!.ContentsSpecialFields![SiteCode.Patches] ??= $"PS3 Firmware {firmwareVersion}"; - } + info.VersionAndEditions!.Version ??= InfoTool.GetPlayStation3Version(drive?.Name) ?? string.Empty; + + string? firmwareVersion = InfoTool.GetPlayStation3FirmwareVersion(drive?.Name); + if (firmwareVersion != null) + info.CommonDiscInfo!.ContentsSpecialFields![SiteCode.Patches] ??= $"PS3 Firmware {firmwareVersion}"; break; case RedumpSystem.SonyPlayStation4: - if (drive?.Name != null - && (!info.CommonDiscInfo!.CommentsSpecialFields!.ContainsKey(SiteCode.InternalSerialName) - || string.IsNullOrEmpty(info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName]))) - { - info.VersionAndEditions!.Version ??= InfoTool.GetPlayStation4Version(drive.Name) ?? string.Empty; - info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation4Serial(drive.Name) ?? string.Empty; - } + if (info.CommonDiscInfo!.CommentsSpecialFields!.TryGetValue(SiteCode.InternalSerialName, out string? ps4Serial) && string.IsNullOrEmpty(ps4Serial)) + info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation4Serial(drive?.Name) ?? string.Empty; + info.VersionAndEditions!.Version ??= InfoTool.GetPlayStation4Version(drive?.Name) ?? string.Empty; break; case RedumpSystem.SonyPlayStation5: - if (drive?.Name != null - && (!info.CommonDiscInfo!.CommentsSpecialFields!.ContainsKey(SiteCode.InternalSerialName) - || string.IsNullOrEmpty(info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName]))) - { - info.VersionAndEditions!.Version ??= InfoTool.GetPlayStation5Version(drive.Name) ?? string.Empty; - info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation5Serial(drive.Name) ?? string.Empty; - } + if (info.CommonDiscInfo!.CommentsSpecialFields!.TryGetValue(SiteCode.InternalSerialName, out string? ps5Serial) && string.IsNullOrEmpty(ps5Serial)) + info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation5Serial(drive?.Name) ?? string.Empty; + info.VersionAndEditions!.Version ??= InfoTool.GetPlayStation5Version(drive?.Name) ?? string.Empty; break; case RedumpSystem.TomyKissSite: diff --git a/MPF.Processors/Redumper.cs b/MPF.Processors/Redumper.cs index eae76202..bb5d4b5a 100644 --- a/MPF.Processors/Redumper.cs +++ b/MPF.Processors/Redumper.cs @@ -1168,10 +1168,26 @@ namespace MPF.Processors if (line == null) break; - if (line.StartsWith("EXE date:")) + if (line.StartsWith("anti-modchip:")) + { + // Valid but skip + } + else if (line.StartsWith("EXE:")) + { + // Valid but skip + } + else if (line.StartsWith("EXE date:")) { exeDate = line.Substring("EXE date: ".Length).Trim(); } + else if (line.StartsWith("libcrypt:")) + { + // Valid but skip + } + else if (line.StartsWith("region:")) + { + // Valid but skip + } else if (line.StartsWith("serial:")) { serial = line.Substring("serial: ".Length).Trim();