diff --git a/SabreTools.Library/DatFiles/DatFile.cs b/SabreTools.Library/DatFiles/DatFile.cs index 77d200a0..bcbb3bdb 100644 --- a/SabreTools.Library/DatFiles/DatFile.cs +++ b/SabreTools.Library/DatFiles/DatFile.cs @@ -1468,19 +1468,8 @@ namespace SabreTools.Library.DatFiles // If the key is different, move the item to the new key if (newkey != key) { - // We have to circumvent the proper process here because of issues with nodumps - // TODO: Properly handle nodumps in key-to-key transfers - if (_items.ContainsKey(newkey)) - { - _items[newkey].Add(rom); - } - else - { - _items.Add(newkey, new List() { rom }); - } - - // Now remove the rom from its original location - roms.RemoveAt(i); + Add(newkey, rom); + Remove(key, rom); i--; // This make sure that the pointer stays on the correct since one was removed } } diff --git a/SabreTools.Library/DatItems/Disk.cs b/SabreTools.Library/DatItems/Disk.cs index a0b4cb0f..062809e1 100644 --- a/SabreTools.Library/DatItems/Disk.cs +++ b/SabreTools.Library/DatItems/Disk.cs @@ -138,14 +138,20 @@ namespace SabreTools.Library.DatItems // Otherwise, treat it as a rom Disk newOther = (Disk)other; - // If either is a nodump, it's never a match - if (_itemStatus == ItemStatus.Nodump || newOther.ItemStatus == ItemStatus.Nodump) + // If all hashes are empty but they're both nodump and the names match, then they're dupes + if ((this._itemStatus == ItemStatus.Nodump && newOther._itemStatus == ItemStatus.Nodump) + && (this._name == newOther._name) + && (this._md5.IsNullOrWhiteSpace() && newOther._md5.IsNullOrWhiteSpace()) + && (this._sha1.IsNullOrWhiteSpace() && newOther._sha1.IsNullOrWhiteSpace()) + && (this._sha256.IsNullOrWhiteSpace() && newOther._sha256.IsNullOrWhiteSpace()) + && (this._sha384.IsNullOrWhiteSpace() && newOther._sha384.IsNullOrWhiteSpace()) + && (this._sha512.IsNullOrWhiteSpace() && newOther._sha512.IsNullOrWhiteSpace())) { - return dupefound; + dupefound = true; } // If we can determine that the disks have no non-empty hashes in common, we return false - if ((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace()) + else if ((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace()) && (this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace()) && (this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace()) && (this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace()) @@ -153,6 +159,8 @@ namespace SabreTools.Library.DatItems { dupefound = false; } + + // Otherwise if we get a partial match else if (((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._md5, newOther._md5)) && ((this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha1, newOther._sha1)) && ((this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha256, newOther._sha256)) diff --git a/SabreTools.Library/DatItems/Rom.cs b/SabreTools.Library/DatItems/Rom.cs index b70885d6..51bb5cca 100644 --- a/SabreTools.Library/DatItems/Rom.cs +++ b/SabreTools.Library/DatItems/Rom.cs @@ -205,14 +205,21 @@ namespace SabreTools.Library.DatItems // Otherwise, treat it as a rom Rom newOther = (Rom)other; - // If either is a nodump, it's never a match - if (_itemStatus == ItemStatus.Nodump || newOther.ItemStatus == ItemStatus.Nodump) + // If all hashes are empty but they're both nodump and the names match, then they're dupes + if ((this._itemStatus == ItemStatus.Nodump && newOther._itemStatus == ItemStatus.Nodump) + && (this._name == newOther._name) + && (this._crc.IsNullOrWhiteSpace() && newOther._crc.IsNullOrWhiteSpace()) + && (this._md5.IsNullOrWhiteSpace() && newOther._md5.IsNullOrWhiteSpace()) + && (this._sha1.IsNullOrWhiteSpace() && newOther._sha1.IsNullOrWhiteSpace()) + && (this._sha256.IsNullOrWhiteSpace() && newOther._sha256.IsNullOrWhiteSpace()) + && (this._sha384.IsNullOrWhiteSpace() && newOther._sha384.IsNullOrWhiteSpace()) + && (this._sha512.IsNullOrWhiteSpace() && newOther._sha512.IsNullOrWhiteSpace())) { - return dupefound; + dupefound = true; } // If we can determine that the roms have no non-empty hashes in common, we return false - if ((_crc.IsNullOrWhiteSpace() || newOther._crc.IsNullOrWhiteSpace()) + else if ((this._crc.IsNullOrWhiteSpace() || newOther._crc.IsNullOrWhiteSpace()) && (this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace()) && (this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace()) && (this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace()) @@ -221,6 +228,8 @@ namespace SabreTools.Library.DatItems { dupefound = false; } + + // Otherwise if we get a partial match else if ((this.Size == newOther.Size) && ((this._crc.IsNullOrWhiteSpace() || newOther._crc.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._crc, newOther._crc)) && ((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._md5, newOther._md5))