mirror of
https://github.com/SabreTools/SabreTools.RedumpLib.git
synced 2026-09-22 23:14:52 +00:00
Remove redundant properties
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -166,10 +166,13 @@ namespace SabreTools.RedumpLib.Test
|
||||
var si = new SubmissionInfo
|
||||
{
|
||||
CommonDiscInfo = new CommonDiscInfoSection { Media = type },
|
||||
TracksAndWriteOffsets = new TracksAndWriteOffsetsSection
|
||||
{
|
||||
ClrMameProData = "<rom name=\"X\" size=\"50050629633\" crc=\"X\" md5=\"X\" sha1=\"X\" />",
|
||||
},
|
||||
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 = "<rom name=\"X\" size=\"25025314817\" crc=\"X\" md5=\"X\" sha1=\"X\" />",
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
/// <summary>
|
||||
/// Extract the size from XML hash data
|
||||
/// </summary>
|
||||
/// <param name="hashData">String representing the combined hash data</param>
|
||||
/// <returns>Extracted size on success, -1 on error</returns>
|
||||
public static long ExtractSizeFromHashData(string? hashData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(hashData))
|
||||
return -1;
|
||||
|
||||
var hashreg = new Regex(@"<rom name="".*?"" size=""(.*?)"" crc=""(.*?)"" md5=""(.*?)"" sha1=""(.*?)""", RegexOptions.Compiled);
|
||||
Match m = hashreg.Match(hashData);
|
||||
if (m.Success)
|
||||
{
|
||||
if (long.TryParse(m.Groups[1].Value, out long size))
|
||||
return size;
|
||||
}
|
||||
|
||||
// Everything else is a failure case
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cross-Enumeration
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user