diff --git a/SabreTools.RedumpLib.Test/SubmissionInfoTests.cs b/SabreTools.RedumpLib.Test/SubmissionInfoTests.cs index c61a66e..952069a 100644 --- a/SabreTools.RedumpLib.Test/SubmissionInfoTests.cs +++ b/SabreTools.RedumpLib.Test/SubmissionInfoTests.cs @@ -153,10 +153,6 @@ namespace SabreTools.RedumpLib.Test Layerbreak = 0, Layerbreak2 = 1, Layerbreak3 = 2, - Size = 12345, - CRC32 = "CRC32", - MD5 = "MD5", - SHA1 = "SHA1", }, DumpingInfo = new DumpingInfoSection() diff --git a/SabreTools.RedumpLib.Test/ValidatorTests.cs b/SabreTools.RedumpLib.Test/ValidatorTests.cs index c49217b..287454a 100644 --- a/SabreTools.RedumpLib.Test/ValidatorTests.cs +++ b/SabreTools.RedumpLib.Test/ValidatorTests.cs @@ -166,10 +166,13 @@ namespace SabreTools.RedumpLib.Test var si = new SubmissionInfo { CommonDiscInfo = new CommonDiscInfoSection { Media = type }, + TracksAndWriteOffsets = new TracksAndWriteOffsetsSection + { + ClrMameProData = "", + }, SizeAndChecksums = new SizeAndChecksumsSection { Layerbreak = 12345, - Size = 50_050_629_633, }, }; @@ -236,9 +239,9 @@ namespace SabreTools.RedumpLib.Test var si = new SubmissionInfo { CommonDiscInfo = new CommonDiscInfoSection { Media = type }, - SizeAndChecksums = new SizeAndChecksumsSection + TracksAndWriteOffsets = new TracksAndWriteOffsetsSection { - Size = 25_025_314_817, + ClrMameProData = "", }, }; diff --git a/SabreTools.RedumpLib/Data/Extensions.cs b/SabreTools.RedumpLib/Data/Extensions.cs index cab53bf..4ce85d1 100644 --- a/SabreTools.RedumpLib/Data/Extensions.cs +++ b/SabreTools.RedumpLib/Data/Extensions.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Text.RegularExpressions; using SabreTools.RedumpLib.Attributes; namespace SabreTools.RedumpLib.Data @@ -11,6 +12,32 @@ namespace SabreTools.RedumpLib.Data #pragma warning disable IDE0072 public static class Extensions { + #region Non-Enumerable + + /// + /// Extract the size from XML hash data + /// + /// String representing the combined hash data + /// Extracted size on success, -1 on error + public static long ExtractSizeFromHashData(string? hashData) + { + if (string.IsNullOrEmpty(hashData)) + return -1; + + var hashreg = new Regex(@" diff --git a/SabreTools.RedumpLib/Data/Sections/SizeAndChecksumsSection.cs b/SabreTools.RedumpLib/Data/Sections/SizeAndChecksumsSection.cs index 32b6dc6..69f91ee 100644 --- a/SabreTools.RedumpLib/Data/Sections/SizeAndChecksumsSection.cs +++ b/SabreTools.RedumpLib/Data/Sections/SizeAndChecksumsSection.cs @@ -20,18 +20,6 @@ namespace SabreTools.RedumpLib.Data.Sections [JsonProperty(PropertyName = "d_pic_identifier", NullValueHandling = NullValueHandling.Ignore)] public string? PICIdentifier { get; set; } - [JsonProperty(PropertyName = "d_size", NullValueHandling = NullValueHandling.Ignore)] - public long Size { get; set; } - - [JsonProperty(PropertyName = "d_crc32", NullValueHandling = NullValueHandling.Ignore)] - public string? CRC32 { get; set; } - - [JsonProperty(PropertyName = "d_md5", NullValueHandling = NullValueHandling.Ignore)] - public string? MD5 { get; set; } - - [JsonProperty(PropertyName = "d_sha1", NullValueHandling = NullValueHandling.Ignore)] - public string? SHA1 { get; set; } - public object Clone() { return new SizeAndChecksumsSection @@ -40,10 +28,6 @@ namespace SabreTools.RedumpLib.Data.Sections Layerbreak2 = this.Layerbreak2, Layerbreak3 = this.Layerbreak3, PICIdentifier = this.PICIdentifier, - Size = this.Size, - CRC32 = this.CRC32, - MD5 = this.MD5, - SHA1 = this.SHA1, }; } } diff --git a/SabreTools.RedumpLib/Formatter.cs b/SabreTools.RedumpLib/Formatter.cs index 84ccc22..c35ec9e 100644 --- a/SabreTools.RedumpLib/Formatter.cs +++ b/SabreTools.RedumpLib/Formatter.cs @@ -276,6 +276,9 @@ namespace SabreTools.RedumpLib var system = section?.System; bool reverseOrder = system.HasReversedRingcodes(); + // Extract the size from the hashes + long size = Extensions.ExtractSizeFromHashData(tawo?.ClrMameProData); + output.AppendLine("Common Disc Info:"); AddIfExists(output, Template.TitleField, section?.Title, 1); @@ -286,7 +289,7 @@ namespace SabreTools.RedumpLib AddIfExists(output, Template.MediaTypeField, GetFixedMediaType( section?.Media.ToMediaType(), sac?.PICIdentifier, - sac?.Size, + size, sac?.Layerbreak, sac?.Layerbreak2, sac?.Layerbreak3), @@ -515,11 +518,6 @@ namespace SabreTools.RedumpLib { AddIfExists(output, Template.LayerbreakField, section?.Layerbreak, 1); } - - AddIfExists(output, Template.SizeField, section?.Size.ToString(), 1); - AddIfExists(output, Template.CRC32Field, section?.CRC32, 1); - AddIfExists(output, Template.MD5Field, section?.MD5, 1); - AddIfExists(output, Template.SHA1Field, section?.SHA1, 1); } /// diff --git a/SabreTools.RedumpLib/Validator.cs b/SabreTools.RedumpLib/Validator.cs index d6012a3..bbf21e7 100644 --- a/SabreTools.RedumpLib/Validator.cs +++ b/SabreTools.RedumpLib/Validator.cs @@ -35,19 +35,22 @@ namespace SabreTools.RedumpLib case DiscType.BD66: case DiscType.BD100: case DiscType.BD128: + // Extract the size from the hashes + long size = Extensions.ExtractSizeFromHashData(info.TracksAndWriteOffsets.ClrMameProData); + if (info.SizeAndChecksums.Layerbreak3 != default) info.CommonDiscInfo.Media = DiscType.BD128; else if (info.SizeAndChecksums.Layerbreak2 != default) info.CommonDiscInfo.Media = DiscType.BD100; else if (info.SizeAndChecksums.Layerbreak != default && info.SizeAndChecksums.PICIdentifier == "BDU") info.CommonDiscInfo.Media = DiscType.BD66; - else if (info.SizeAndChecksums.Layerbreak != default && info.SizeAndChecksums.Size > 50_050_629_632) + else if (info.SizeAndChecksums.Layerbreak != default && size > 50_050_629_632) info.CommonDiscInfo.Media = DiscType.BD66; else if (info.SizeAndChecksums.Layerbreak != default) info.CommonDiscInfo.Media = DiscType.BD50; else if (info.SizeAndChecksums.PICIdentifier == "BDU") info.CommonDiscInfo.Media = DiscType.BD33; - else if (info.SizeAndChecksums.Size > 25_025_314_816) + else if (size > 25_025_314_816) info.CommonDiscInfo.Media = DiscType.BD33; else info.CommonDiscInfo.Media = DiscType.BD25;