mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Extra merge tag code
This commit is contained in:
@@ -1574,7 +1574,7 @@ namespace SabreTools.Library.DatFiles
|
||||
continue;
|
||||
|
||||
// If the game (is/is not) a bios, we want to continue
|
||||
if (dev ^ (datFile[game][0].MachineType.HasFlag(Data.MachineType.Device)))
|
||||
if (dev ^ (datFile[game][0].MachineType.HasFlag(MachineType.Device)))
|
||||
continue;
|
||||
|
||||
// If the game has no devices, we continue
|
||||
@@ -1736,14 +1736,33 @@ namespace SabreTools.Library.DatFiles
|
||||
foreach (DatItem item in items)
|
||||
{
|
||||
// If the disk doesn't have a valid merge tag OR the merged file doesn't exist in the parent, then add it
|
||||
if (item.ItemType == Data.ItemType.Disk && (((Disk)item).MergeTag == null || !datFile[parent].Select(i => i.Name).Contains(((Disk)item).MergeTag)))
|
||||
if (item.ItemType == ItemType.Disk && (((Disk)item).MergeTag == null || !datFile[parent].Select(i => i.Name).Contains(((Disk)item).MergeTag)))
|
||||
{
|
||||
// Rename the child so it's in a subfolder
|
||||
item.Name = $"{item.MachineName}\\{item.Name}";
|
||||
|
||||
// Update the machine to be the new parent
|
||||
item.CopyMachineInformation(copyFrom);
|
||||
|
||||
// Add the rom to the parent set
|
||||
datFile.Add(parent, item);
|
||||
}
|
||||
|
||||
// If the rom doesn't have a valid merge tag OR the merged file doesn't exist in the parent, then add it
|
||||
else if (item.ItemType == ItemType.Rom && (((Rom)item).MergeTag == null || !datFile[parent].Select(i => i.Name).Contains(((Rom)item).MergeTag)))
|
||||
{
|
||||
// Rename the child so it's in a subfolder
|
||||
item.Name = $"{item.MachineName}\\{item.Name}";
|
||||
|
||||
// Update the machine to be the new parent
|
||||
item.CopyMachineInformation(copyFrom);
|
||||
|
||||
// Add the rom to the parent set
|
||||
datFile.Add(parent, item);
|
||||
}
|
||||
|
||||
// Otherwise, if the parent doesn't already contain the non-disk (or a merge-equivalent), add it
|
||||
else if (item.ItemType != Data.ItemType.Disk && !datFile[parent].Contains(item))
|
||||
else if (item.ItemType != ItemType.Disk && !datFile[parent].Contains(item))
|
||||
{
|
||||
// Rename the child so it's in a subfolder
|
||||
item.Name = $"{item.MachineName}\\{item.Name}";
|
||||
@@ -1771,8 +1790,8 @@ namespace SabreTools.Library.DatFiles
|
||||
foreach (string game in games)
|
||||
{
|
||||
if (datFile[game].Count > 0
|
||||
&& (datFile[game][0].MachineType.HasFlag(Data.MachineType.Bios)
|
||||
|| datFile[game][0].MachineType.HasFlag(Data.MachineType.Device)))
|
||||
&& (datFile[game][0].MachineType.HasFlag(MachineType.Bios)
|
||||
|| datFile[game][0].MachineType.HasFlag(MachineType.Device)))
|
||||
{
|
||||
datFile.Remove(game);
|
||||
}
|
||||
@@ -1795,7 +1814,7 @@ namespace SabreTools.Library.DatFiles
|
||||
continue;
|
||||
|
||||
// If the game (is/is not) a bios, we want to continue
|
||||
if (bios ^ datFile[game][0].MachineType.HasFlag(Data.MachineType.Bios))
|
||||
if (bios ^ datFile[game][0].MachineType.HasFlag(MachineType.Bios))
|
||||
continue;
|
||||
|
||||
// Determine if the game has a parent or not
|
||||
|
||||
@@ -15,7 +15,9 @@ namespace SabreTools.Library.DatItems
|
||||
#region Private instance variables
|
||||
|
||||
private byte[] _md5; // 16 bytes
|
||||
#if NET_FRAMEWORK
|
||||
private byte[] _ripemd160; // 20 bytes
|
||||
#endif
|
||||
private byte[] _sha1; // 20 bytes
|
||||
private byte[] _sha256; // 32 bytes
|
||||
private byte[] _sha384; // 48 bytes
|
||||
@@ -200,7 +202,9 @@ namespace SabreTools.Library.DatItems
|
||||
IndexSource = this.IndexSource,
|
||||
|
||||
_md5 = this._md5,
|
||||
#if NET_FRAMEWORK
|
||||
_ripemd160 = this._ripemd160,
|
||||
#endif
|
||||
_sha1 = this._sha1,
|
||||
_sha256 = this._sha256,
|
||||
_sha384 = this._sha384,
|
||||
@@ -289,7 +293,9 @@ namespace SabreTools.Library.DatItems
|
||||
if ((this.ItemStatus == ItemStatus.Nodump && newOther.ItemStatus == ItemStatus.Nodump)
|
||||
&& (this.Name == newOther.Name)
|
||||
&& (this._md5.IsNullOrEmpty() && newOther._md5.IsNullOrEmpty())
|
||||
#if NET_FRAMEWORK
|
||||
&& (this._ripemd160.IsNullOrEmpty() && newOther._ripemd160.IsNullOrEmpty())
|
||||
#endif
|
||||
&& (this._sha1.IsNullOrEmpty() && newOther._sha1.IsNullOrEmpty())
|
||||
&& (this._sha256.IsNullOrEmpty() && newOther._sha256.IsNullOrEmpty())
|
||||
&& (this._sha384.IsNullOrEmpty() && newOther._sha384.IsNullOrEmpty())
|
||||
@@ -300,7 +306,9 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
// If we can determine that the disks have no non-empty hashes in common, we return false
|
||||
else if ((this._md5.IsNullOrEmpty() || newOther._md5.IsNullOrEmpty())
|
||||
#if NET_FRAMEWORK
|
||||
&& (this._ripemd160.IsNullOrEmpty() || newOther._ripemd160.IsNullOrEmpty())
|
||||
#endif
|
||||
&& (this._sha1.IsNullOrEmpty() || newOther._sha1.IsNullOrEmpty())
|
||||
&& (this._sha256.IsNullOrEmpty() || newOther._sha256.IsNullOrEmpty())
|
||||
&& (this._sha384.IsNullOrEmpty() || newOther._sha384.IsNullOrEmpty())
|
||||
@@ -311,7 +319,9 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
// Otherwise if we get a partial match
|
||||
else if (((this._md5.IsNullOrEmpty() || newOther._md5.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._md5, newOther._md5))
|
||||
#if NET_FRAMEWORK
|
||||
&& ((this._ripemd160.IsNullOrEmpty() || newOther._ripemd160.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._ripemd160, newOther._ripemd160))
|
||||
#endif
|
||||
&& ((this._sha1.IsNullOrEmpty() || newOther._sha1.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha1, newOther._sha1))
|
||||
&& ((this._sha256.IsNullOrEmpty() || newOther._sha256.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha256, newOther._sha256))
|
||||
&& ((this._sha384.IsNullOrEmpty() || newOther._sha384.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha384, newOther._sha384))
|
||||
|
||||
@@ -16,7 +16,9 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
private byte[] _crc; // 8 bytes
|
||||
private byte[] _md5; // 16 bytes
|
||||
#if NET_FRAMEWORK
|
||||
private byte[] _ripemd160; // 20 bytes
|
||||
#endif
|
||||
private byte[] _sha1; // 20 bytes
|
||||
private byte[] _sha256; // 32 bytes
|
||||
private byte[] _sha384; // 48 bytes
|
||||
@@ -249,7 +251,9 @@ namespace SabreTools.Library.DatItems
|
||||
Size = this.Size,
|
||||
_crc = this._crc,
|
||||
_md5 = this._md5,
|
||||
#if NET_FRAMEWORK
|
||||
_ripemd160 = this._ripemd160,
|
||||
#endif
|
||||
_sha1 = this._sha1,
|
||||
_sha256 = this._sha256,
|
||||
_sha384 = this._sha384,
|
||||
@@ -279,7 +283,9 @@ namespace SabreTools.Library.DatItems
|
||||
&& (this.Name == newOther.Name)
|
||||
&& (this._crc.IsNullOrEmpty() && newOther._crc.IsNullOrEmpty())
|
||||
&& (this._md5.IsNullOrEmpty() && newOther._md5.IsNullOrEmpty())
|
||||
#if NET_FRAMEWORK
|
||||
&& (this._ripemd160.IsNullOrEmpty() && newOther._ripemd160.IsNullOrEmpty())
|
||||
#endif
|
||||
&& (this._sha1.IsNullOrEmpty() && newOther._sha1.IsNullOrEmpty())
|
||||
&& (this._sha256.IsNullOrEmpty() && newOther._sha256.IsNullOrEmpty())
|
||||
&& (this._sha384.IsNullOrEmpty() && newOther._sha384.IsNullOrEmpty())
|
||||
@@ -291,7 +297,9 @@ namespace SabreTools.Library.DatItems
|
||||
// If we can determine that the roms have no non-empty hashes in common, we return false
|
||||
else if ((this._crc.IsNullOrEmpty() || newOther._crc.IsNullOrEmpty())
|
||||
&& (this._md5.IsNullOrEmpty() || newOther._md5.IsNullOrEmpty())
|
||||
#if NET_FRAMEWORK
|
||||
&& (this._ripemd160.IsNullOrEmpty() || newOther._ripemd160.IsNullOrEmpty())
|
||||
#endif
|
||||
&& (this._sha1.IsNullOrEmpty() || newOther._sha1.IsNullOrEmpty())
|
||||
&& (this._sha256.IsNullOrEmpty() || newOther._sha256.IsNullOrEmpty())
|
||||
&& (this._sha384.IsNullOrEmpty() || newOther._sha384.IsNullOrEmpty())
|
||||
@@ -304,7 +312,9 @@ namespace SabreTools.Library.DatItems
|
||||
else if ((this.Size == -1)
|
||||
&& ((this._crc.IsNullOrEmpty() || newOther._crc.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._crc, newOther._crc))
|
||||
&& ((this._md5.IsNullOrEmpty() || newOther._md5.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._md5, newOther._md5))
|
||||
#if NET_FRAMEWORK
|
||||
&& ((this._ripemd160.IsNullOrEmpty() || newOther._ripemd160.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._ripemd160, newOther._ripemd160))
|
||||
#endif
|
||||
&& ((this._sha1.IsNullOrEmpty() || newOther._sha1.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha1, newOther._sha1))
|
||||
&& ((this._sha256.IsNullOrEmpty() || newOther._sha256.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha256, newOther._sha256))
|
||||
&& ((this._sha384.IsNullOrEmpty() || newOther._sha384.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha384, newOther._sha384))
|
||||
@@ -317,7 +327,9 @@ namespace SabreTools.Library.DatItems
|
||||
else if ((this.Size == newOther.Size)
|
||||
&& ((this._crc.IsNullOrEmpty() || newOther._crc.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._crc, newOther._crc))
|
||||
&& ((this._md5.IsNullOrEmpty() || newOther._md5.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._md5, newOther._md5))
|
||||
#if NET_FRAMEWORK
|
||||
&& ((this._ripemd160.IsNullOrEmpty() || newOther._ripemd160.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._ripemd160, newOther._ripemd160))
|
||||
#endif
|
||||
&& ((this._sha1.IsNullOrEmpty() || newOther._sha1.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha1, newOther._sha1))
|
||||
&& ((this._sha256.IsNullOrEmpty() || newOther._sha256.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha256, newOther._sha256))
|
||||
&& ((this._sha384.IsNullOrEmpty() || newOther._sha384.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha384, newOther._sha384))
|
||||
|
||||
Reference in New Issue
Block a user