[DatItem] Slightly tweak the duplication logic

This commit is contained in:
Matt Nadareski
2017-02-27 22:03:26 -08:00
parent 11293f8ca5
commit 0f3b70de69

View File

@@ -253,27 +253,57 @@ namespace SabreTools.Helper.Dats
return false; return false;
} }
// How about this: If RomCount + DiskCount = SHA1Count, sort by SHA1 // We want to get the proper key for the DatItem
// then if RomCount + DiskCount == MD5Count, sort by MD5 (or make this default for Disk)
// then if RomCount == CRCCount, sort by CRC (or make this default for Rom)
// We assume that we check by CRC for Rom and MD5 for Disk
string key = ""; string key = "";
// For Roms, we get the CRC // If all items are supposed to have a SHA-1, we sort by that
if (datdata.RomCount + datdata.DiskCount - datdata.NodumpCount == datdata.SHA1Count
&& ((_itemType == ItemType.Rom && !String.IsNullOrEmpty(((Rom)this).SHA1))
|| (_itemType == ItemType.Disk && !String.IsNullOrEmpty(((Disk)this).SHA1))))
{
if (_itemType == ItemType.Rom) if (_itemType == ItemType.Rom)
{ {
key = ((Rom)this).CRC; key = ((Rom)this).SHA1;
datdata.BucketByCRC(false, logger, false); datdata.BucketBySHA1(false, logger, false);
}
else
{
key = ((Disk)this).SHA1;
datdata.BucketBySHA1(false, logger, false);
}
} }
// For Disks, we get the MD5 // If all items are supposed to have an MD5, we sort by that
else if (datdata.RomCount + datdata.DiskCount - datdata.NodumpCount == datdata.MD5Count
&& ((_itemType == ItemType.Rom && !String.IsNullOrEmpty(((Rom)this).MD5))
|| (_itemType == ItemType.Disk && !String.IsNullOrEmpty(((Disk)this).MD5))))
{
if (_itemType == ItemType.Rom)
{
key = ((Rom)this).MD5;
datdata.BucketByMD5(false, logger, false);
}
else
{
key = ((Disk)this).MD5;
datdata.BucketByMD5(false, logger, false);
}
}
// If we've gotten here and we have a Disk, sort by MD5
else if (_itemType == ItemType.Disk) else if (_itemType == ItemType.Disk)
{ {
key = ((Disk)this).MD5; key = ((Disk)this).MD5;
datdata.BucketByMD5(false, logger, false); datdata.BucketByMD5(false, logger, false);
} }
// If we've gotten here and we have a Rom, sort by CRC
if (_itemType == ItemType.Rom)
{
key = ((Rom)this).CRC;
datdata.BucketByCRC(false, logger, false);
}
// Otherwise, we use -1 as the key // Otherwise, we use -1 as the key
else else
{ {
@@ -318,23 +348,57 @@ namespace SabreTools.Helper.Dats
return output; return output;
} }
// We assume that we check by CRC for Rom and MD5 for Disk // We want to get the proper key for the DatItem
string key = ""; string key = "";
// For Roms, we get the CRC // If all items are supposed to have a SHA-1, we sort by that
if (datdata.RomCount + datdata.DiskCount - datdata.NodumpCount == datdata.SHA1Count
&& ((_itemType == ItemType.Rom && !String.IsNullOrEmpty(((Rom)this).SHA1))
|| (_itemType == ItemType.Disk && !String.IsNullOrEmpty(((Disk)this).SHA1))))
{
if (_itemType == ItemType.Rom) if (_itemType == ItemType.Rom)
{ {
key = ((Rom)this).CRC; key = ((Rom)this).SHA1;
datdata.BucketByCRC(false, logger, false); datdata.BucketBySHA1(false, logger, false);
}
else
{
key = ((Disk)this).SHA1;
datdata.BucketBySHA1(false, logger, false);
}
} }
// For Disks, we get the MD5 // If all items are supposed to have an MD5, we sort by that
else if (datdata.RomCount + datdata.DiskCount - datdata.NodumpCount == datdata.MD5Count
&& ((_itemType == ItemType.Rom && !String.IsNullOrEmpty(((Rom)this).MD5))
|| (_itemType == ItemType.Disk && !String.IsNullOrEmpty(((Disk)this).MD5))))
{
if (_itemType == ItemType.Rom)
{
key = ((Rom)this).MD5;
datdata.BucketByMD5(false, logger, false);
}
else
{
key = ((Disk)this).MD5;
datdata.BucketByMD5(false, logger, false);
}
}
// If we've gotten here and we have a Disk, sort by MD5
else if (_itemType == ItemType.Disk) else if (_itemType == ItemType.Disk)
{ {
key = ((Disk)this).MD5; key = ((Disk)this).MD5;
datdata.BucketByMD5(false, logger, false); datdata.BucketByMD5(false, logger, false);
} }
// If we've gotten here and we have a Rom, sort by CRC
if (_itemType == ItemType.Rom)
{
key = ((Rom)this).CRC;
datdata.BucketByCRC(false, logger, false);
}
// Otherwise, we use -1 as the key // Otherwise, we use -1 as the key
else else
{ {