diff --git a/DATabase/DATabase.cs b/DATabase/DATabase.cs index 04ba1b36..28934c9c 100644 --- a/DATabase/DATabase.cs +++ b/DATabase/DATabase.cs @@ -1342,7 +1342,6 @@ Make a selection: DatData datdata = new DatData { OutputFormat = outputFormat, - Roms = new Dictionary>(), MergeRoms = false, }; datdata = RomManipulation.Parse(filename, 0, 0, datdata, logger, true); @@ -1372,7 +1371,6 @@ Make a selection: DatData datdata = new DatData { OutputFormat = outputFormat, - Roms = new Dictionary>(), MergeRoms = false, }; datdata = RomManipulation.Parse(file, 0, 0, datdata, logger, true); @@ -1429,7 +1427,6 @@ Make a selection: logger.User("Converting " + input); DatData datdata = new DatData { - Roms = new Dictionary>(), OutputFormat = OutputFormat.MissFile, UseGame = usegame, diff --git a/DATabase/ExtSplit.cs b/DATabase/ExtSplit.cs index 9b6fd75b..cc00e6d7 100644 --- a/DATabase/ExtSplit.cs +++ b/DATabase/ExtSplit.cs @@ -56,13 +56,8 @@ namespace SabreTools Directory.CreateDirectory(_outdir); } - // Create the initial DatData object - DatData datdata = new DatData - { - Roms = new Dictionary>(), - }; - // Load the current DAT to be processed + DatData datdata = new DatData(); datdata = RomManipulation.Parse(_filename, 0, 0, datdata, _logger); // Set all of the appropriate outputs for each of the subsets diff --git a/DATabase/Import.cs b/DATabase/Import.cs index ede610bc..c10e22c8 100644 --- a/DATabase/Import.cs +++ b/DATabase/Import.cs @@ -399,10 +399,7 @@ namespace SabreTools } // Get all roms that are found in the DAT to see what needs to be added - DatData datdata = new DatData - { - Roms = new Dictionary>(), - }; + DatData datdata = new DatData(); datdata = RomManipulation.Parse(_filepath, sysid, srcid, datdata, _logger); // Sort inputted roms into games diff --git a/DATabase/MergeDiff.cs b/DATabase/MergeDiff.cs index dab2e2fe..36762ed7 100644 --- a/DATabase/MergeDiff.cs +++ b/DATabase/MergeDiff.cs @@ -117,7 +117,6 @@ namespace SabreTools ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None), OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml), MergeRoms = _dedup, - Roms = new Dictionary>(), Type = (_superdat ? "SuperDAT" : ""), }; foreach (string input in _inputs) @@ -145,7 +144,6 @@ namespace SabreTools ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None), OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml), MergeRoms = _dedup, - Roms = new Dictionary>(), }; foreach (string key in userData.Roms.Keys) { @@ -189,7 +187,6 @@ namespace SabreTools ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None), OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml), MergeRoms = _dedup, - Roms = new Dictionary>(), }; foreach (string key in outerDiffData.Roms.Keys) @@ -228,7 +225,6 @@ namespace SabreTools ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None), OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml), MergeRoms = _dedup, - Roms = new Dictionary>(), }; foreach (string key in userData.Roms.Keys) { @@ -273,7 +269,6 @@ namespace SabreTools ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None), OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml), MergeRoms = _dedup, - Roms = new Dictionary>(), }; List keys = userData.Roms.Keys.ToList(); diff --git a/DATabase/TrimMerge.cs b/DATabase/TrimMerge.cs index bb1d6bf3..fd4d1209 100644 --- a/DATabase/TrimMerge.cs +++ b/DATabase/TrimMerge.cs @@ -85,7 +85,6 @@ namespace SabreTools { DatData datdata = new DatData { - Roms = new Dictionary>(), ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None), OutputFormat = RomManipulation.GetOutputFormat(filename), }; diff --git a/DATabaseTwo/Generate.cs b/DATabaseTwo/Generate.cs index 9b2589fb..a9aacef5 100644 --- a/DATabaseTwo/Generate.cs +++ b/DATabaseTwo/Generate.cs @@ -156,7 +156,6 @@ namespace SabreTools ForcePacking = ForcePacking.None, OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml), MergeRoms = true, - Roms = new Dictionary>(), }; // Now read in all of the files diff --git a/HashSplit/HashSplit.cs b/HashSplit/HashSplit.cs index 0c92532f..64800caf 100644 --- a/HashSplit/HashSplit.cs +++ b/HashSplit/HashSplit.cs @@ -145,12 +145,32 @@ namespace SabreTools DatData datdata = new DatData { Description = Path.GetFileNameWithoutExtension(filename), - Roms = new Dictionary>(), }; datdata = RomManipulation.Parse(filename, 0, 0, datdata, _logger, true); // Create each of the respective output DATs _logger.User("Creating and populating new DATs"); + DatData nodump = new DatData + { + Name = datdata.Name + " (Nodump)", + Description = datdata.Description + " (Nodump)", + Category = datdata.Category, + Version = datdata.Version, + Date = datdata.Date, + Author = datdata.Author, + Email = datdata.Email, + Homepage = datdata.Homepage, + Url = datdata.Url, + Comment = datdata.Comment, + Header = datdata.Header, + Type = datdata.Type, + ForceMerging = datdata.ForceMerging, + ForceNodump = datdata.ForceNodump, + ForcePacking = datdata.ForcePacking, + OutputFormat = outputFormat, + MergeRoms = datdata.MergeRoms, + Roms = new Dictionary>(), + }; DatData sha1 = new DatData { Name = datdata.Name + " (SHA-1)", @@ -195,8 +215,8 @@ namespace SabreTools }; DatData crc = new DatData { - Name = datdata.Name + " (CRC and None)", - Description = datdata.Description + " (CRC and None)", + Name = datdata.Name + " (CRC)", + Description = datdata.Description + " (CRC)", Category = datdata.Category, Version = datdata.Version, Date = datdata.Date, @@ -222,8 +242,22 @@ namespace SabreTools List roms = datdata.Roms[key]; foreach (RomData rom in roms) { + // If the file is a nodump + if (rom.Nodump) + { + if (nodump.Roms.ContainsKey(key)) + { + nodump.Roms[key].Add(rom); + } + else + { + List temp = new List(); + temp.Add(rom); + nodump.Roms.Add(key, temp); + } + } // If the file has a SHA-1 - if (rom.SHA1 != null && rom.SHA1 != "") + else if (rom.SHA1 != null && rom.SHA1 != "") { if (sha1.Roms.ContainsKey(key)) { @@ -281,6 +315,10 @@ namespace SabreTools // Now, output all of the files to the output directory _logger.User("DAT information created, outputting new files"); bool success = true; + if (nodump.Roms.Count > 0) + { + success &= Output.WriteDatfile(nodump, outdir, _logger); + } if (sha1.Roms.Count > 0) { success &= Output.WriteDatfile(sha1, outdir, _logger); diff --git a/OfflineMerge/OfflineMerge.cs b/OfflineMerge/OfflineMerge.cs index 48fed2a0..84a68bab 100644 --- a/OfflineMerge/OfflineMerge.cs +++ b/OfflineMerge/OfflineMerge.cs @@ -144,10 +144,7 @@ namespace SabreTools { // First get the combination Dictionary of currentAllMerged and currentNewMerged _logger.User("Adding Current and New Merged DATs to the dictionary"); - DatData completeDats = new DatData - { - Roms = new Dictionary>(), - }; + DatData completeDats = new DatData(); completeDats = RomManipulation.Parse(_currentAllMerged, 0, 0, completeDats, _logger); completeDats = RomManipulation.Parse(_currentNewMerged, 0, 0, completeDats, _logger); @@ -201,10 +198,7 @@ namespace SabreTools // Now create the New Missing dictionary [(Net New)+(currentMissingMerged-(Unneeded))] _logger.User("Creating and populating New Missing dictionary"); - DatData midMissing = new DatData - { - Roms = new Dictionary>(), - }; + DatData midMissing = new DatData(); midMissing = RomManipulation.Parse(_currentMissingMerged, 0, 0, midMissing, _logger); foreach (string key in unneeded.Keys) { @@ -454,10 +448,7 @@ namespace SabreTools { // Now create the Have dictionary [(currentAllMerged)-(currentMissingMerged)] _logger.User("Creating and populating Have dictionary"); - DatData midHave = new DatData - { - Roms = new Dictionary>(), - }; + DatData midHave = new DatData(); midHave = RomManipulation.Parse(_currentMissingMerged, 0, 0, midHave, _logger); midHave = RomManipulation.Parse(_currentAllMerged, 0, 0, midHave, _logger); Dictionary> have = new Dictionary>(); @@ -527,10 +518,7 @@ namespace SabreTools { // Now create the Have dictionary [(currentNewMerged)-(currentMissingMerged)] _logger.User("Creating and populating Have dictionary"); - DatData midHave = new DatData - { - Roms = new Dictionary>(), - }; + DatData midHave = new DatData(); midHave = RomManipulation.Parse(_currentMissingMerged, 0, 0, midHave, _logger); midHave = RomManipulation.Parse(_currentNewMerged, 0, 0, midHave, _logger); Dictionary> have = new Dictionary>(); diff --git a/SabreHelper/RomManipulation.cs b/SabreHelper/RomManipulation.cs index 1e2eb78b..17d0a7bf 100644 --- a/SabreHelper/RomManipulation.cs +++ b/SabreHelper/RomManipulation.cs @@ -100,6 +100,12 @@ namespace SabreTools.Helper /// DatData object representing the read-in data public static DatData Parse(string filename, int sysid, int srcid, DatData datdata, Logger logger, bool keep = false) { + // Make sure there's a dictionary to read to + if (datdata.Roms == null) + { + datdata.Roms = new Dictionary>(); + } + // Prepare all internal variables XmlReader subreader, headreader, flagreader; bool superdat = false, nodump = false, empty = true; diff --git a/UncompressedSize/UncompressedSize.cs b/UncompressedSize/UncompressedSize.cs index 48df0160..a7c35beb 100644 --- a/UncompressedSize/UncompressedSize.cs +++ b/UncompressedSize/UncompressedSize.cs @@ -34,10 +34,7 @@ namespace SabreTools long size = 0; foreach (string filename in inputs) { - DatData datdata = new DatData - { - Roms = new Dictionary>(), - }; + DatData datdata = new DatData(); datdata = RomManipulation.Parse(filename, 0, 0, datdata, logger); foreach (List romlist in datdata.Roms.Values) {