diff --git a/SabreTools.DatFiles/Enums.cs b/SabreTools.DatFiles/Enums.cs index aabd3f4c..66a937c1 100644 --- a/SabreTools.DatFiles/Enums.cs +++ b/SabreTools.DatFiles/Enums.cs @@ -174,19 +174,22 @@ namespace SabreTools.DatFiles /// public enum DedupeType { + /// + /// No deduplication + /// None = 0, + + /// + /// Deduplicate across all available fields + /// + /// Requires sorting by any hash Full, - // Force only deduping with certain types + /// + /// Deduplicate on a per-machine basis + /// + /// Requires sorting by machine Game, - CRC, - MD2, - MD4, - MD5, - SHA1, - SHA256, - SHA384, - SHA512, } /// diff --git a/SabreTools.DatFiles/ItemDictionary.cs b/SabreTools.DatFiles/ItemDictionary.cs index 711ce6fd..25589935 100644 --- a/SabreTools.DatFiles/ItemDictionary.cs +++ b/SabreTools.DatFiles/ItemDictionary.cs @@ -393,6 +393,10 @@ namespace SabreTools.DatFiles if (dedupeType == DedupeType.None) return; + // Ensure Game deduplication is valid + if (dedupeType == DedupeType.Game && _bucketedBy != ItemKey.Machine) + return; + #if NET452_OR_GREATER || NETCOREAPP Parallel.ForEach(SortedKeys, Core.Globals.ParallelOptions, key => #elif NET40_OR_GREATER @@ -407,9 +411,8 @@ namespace SabreTools.DatFiles // Sort the list of items to be consistent Sort(ref sortedList, false); - // If we're merging the roms, do so - if (dedupeType == DedupeType.Full || (dedupeType == DedupeType.Game && _bucketedBy == ItemKey.Machine)) - sortedList = DatFileTool.Merge(sortedList); + // Merge the items + sortedList = DatFileTool.Merge(sortedList); // Add the list back to the dictionary RemoveBucket(key); diff --git a/SabreTools.DatFiles/ItemDictionaryDB.cs b/SabreTools.DatFiles/ItemDictionaryDB.cs index 92cb96e7..605baa42 100644 --- a/SabreTools.DatFiles/ItemDictionaryDB.cs +++ b/SabreTools.DatFiles/ItemDictionaryDB.cs @@ -688,6 +688,10 @@ namespace SabreTools.DatFiles if (dedupeType == DedupeType.None) return; + // Ensure Game deduplication is valid + if (dedupeType == DedupeType.Game && _bucketedBy != ItemKey.Machine) + return; + #if NET452_OR_GREATER || NETCOREAPP Parallel.ForEach(SortedKeys, Core.Globals.ParallelOptions, key => #elif NET40_OR_GREATER @@ -702,9 +706,8 @@ namespace SabreTools.DatFiles // Sort the list of items to be consistent Sort(ref sortedList, false); - // If we're merging the roms, do so - if (dedupeType == DedupeType.Full || (dedupeType == DedupeType.Game && _bucketedBy == ItemKey.Machine)) - sortedList = Merge(sortedList); + // Merge the items + sortedList = Merge(sortedList); // Get all existing mappings List currentMappings = sortedList.ConvertAll(item =>