mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Shouldn't have to expicitly define an empty dictionary for parse.
Addendum to this fix is adding a Nodump output for HashSplit
This commit is contained in:
@@ -1342,7 +1342,6 @@ Make a selection:
|
|||||||
DatData datdata = new DatData
|
DatData datdata = new DatData
|
||||||
{
|
{
|
||||||
OutputFormat = outputFormat,
|
OutputFormat = outputFormat,
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
|
||||||
MergeRoms = false,
|
MergeRoms = false,
|
||||||
};
|
};
|
||||||
datdata = RomManipulation.Parse(filename, 0, 0, datdata, logger, true);
|
datdata = RomManipulation.Parse(filename, 0, 0, datdata, logger, true);
|
||||||
@@ -1372,7 +1371,6 @@ Make a selection:
|
|||||||
DatData datdata = new DatData
|
DatData datdata = new DatData
|
||||||
{
|
{
|
||||||
OutputFormat = outputFormat,
|
OutputFormat = outputFormat,
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
|
||||||
MergeRoms = false,
|
MergeRoms = false,
|
||||||
};
|
};
|
||||||
datdata = RomManipulation.Parse(file, 0, 0, datdata, logger, true);
|
datdata = RomManipulation.Parse(file, 0, 0, datdata, logger, true);
|
||||||
@@ -1429,7 +1427,6 @@ Make a selection:
|
|||||||
logger.User("Converting " + input);
|
logger.User("Converting " + input);
|
||||||
DatData datdata = new DatData
|
DatData datdata = new DatData
|
||||||
{
|
{
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
|
||||||
OutputFormat = OutputFormat.MissFile,
|
OutputFormat = OutputFormat.MissFile,
|
||||||
|
|
||||||
UseGame = usegame,
|
UseGame = usegame,
|
||||||
|
|||||||
@@ -56,13 +56,8 @@ namespace SabreTools
|
|||||||
Directory.CreateDirectory(_outdir);
|
Directory.CreateDirectory(_outdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the initial DatData object
|
|
||||||
DatData datdata = new DatData
|
|
||||||
{
|
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Load the current DAT to be processed
|
// Load the current DAT to be processed
|
||||||
|
DatData datdata = new DatData();
|
||||||
datdata = RomManipulation.Parse(_filename, 0, 0, datdata, _logger);
|
datdata = RomManipulation.Parse(_filename, 0, 0, datdata, _logger);
|
||||||
|
|
||||||
// Set all of the appropriate outputs for each of the subsets
|
// Set all of the appropriate outputs for each of the subsets
|
||||||
|
|||||||
@@ -399,10 +399,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get all roms that are found in the DAT to see what needs to be added
|
// Get all roms that are found in the DAT to see what needs to be added
|
||||||
DatData datdata = new DatData
|
DatData datdata = new DatData();
|
||||||
{
|
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
|
||||||
};
|
|
||||||
datdata = RomManipulation.Parse(_filepath, sysid, srcid, datdata, _logger);
|
datdata = RomManipulation.Parse(_filepath, sysid, srcid, datdata, _logger);
|
||||||
|
|
||||||
// Sort inputted roms into games
|
// Sort inputted roms into games
|
||||||
|
|||||||
@@ -117,7 +117,6 @@ namespace SabreTools
|
|||||||
ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None),
|
ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None),
|
||||||
OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
||||||
MergeRoms = _dedup,
|
MergeRoms = _dedup,
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
|
||||||
Type = (_superdat ? "SuperDAT" : ""),
|
Type = (_superdat ? "SuperDAT" : ""),
|
||||||
};
|
};
|
||||||
foreach (string input in _inputs)
|
foreach (string input in _inputs)
|
||||||
@@ -145,7 +144,6 @@ namespace SabreTools
|
|||||||
ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None),
|
ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None),
|
||||||
OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
||||||
MergeRoms = _dedup,
|
MergeRoms = _dedup,
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
|
||||||
};
|
};
|
||||||
foreach (string key in userData.Roms.Keys)
|
foreach (string key in userData.Roms.Keys)
|
||||||
{
|
{
|
||||||
@@ -189,7 +187,6 @@ namespace SabreTools
|
|||||||
ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None),
|
ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None),
|
||||||
OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
||||||
MergeRoms = _dedup,
|
MergeRoms = _dedup,
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (string key in outerDiffData.Roms.Keys)
|
foreach (string key in outerDiffData.Roms.Keys)
|
||||||
@@ -228,7 +225,6 @@ namespace SabreTools
|
|||||||
ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None),
|
ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None),
|
||||||
OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
||||||
MergeRoms = _dedup,
|
MergeRoms = _dedup,
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
|
||||||
};
|
};
|
||||||
foreach (string key in userData.Roms.Keys)
|
foreach (string key in userData.Roms.Keys)
|
||||||
{
|
{
|
||||||
@@ -273,7 +269,6 @@ namespace SabreTools
|
|||||||
ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None),
|
ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None),
|
||||||
OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
||||||
MergeRoms = _dedup,
|
MergeRoms = _dedup,
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
List<string> keys = userData.Roms.Keys.ToList();
|
List<string> keys = userData.Roms.Keys.ToList();
|
||||||
|
|||||||
@@ -85,7 +85,6 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
DatData datdata = new DatData
|
DatData datdata = new DatData
|
||||||
{
|
{
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
|
||||||
ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None),
|
ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None),
|
||||||
OutputFormat = RomManipulation.GetOutputFormat(filename),
|
OutputFormat = RomManipulation.GetOutputFormat(filename),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -156,7 +156,6 @@ namespace SabreTools
|
|||||||
ForcePacking = ForcePacking.None,
|
ForcePacking = ForcePacking.None,
|
||||||
OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml),
|
||||||
MergeRoms = true,
|
MergeRoms = true,
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Now read in all of the files
|
// Now read in all of the files
|
||||||
|
|||||||
@@ -145,12 +145,32 @@ namespace SabreTools
|
|||||||
DatData datdata = new DatData
|
DatData datdata = new DatData
|
||||||
{
|
{
|
||||||
Description = Path.GetFileNameWithoutExtension(filename),
|
Description = Path.GetFileNameWithoutExtension(filename),
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
|
||||||
};
|
};
|
||||||
datdata = RomManipulation.Parse(filename, 0, 0, datdata, _logger, true);
|
datdata = RomManipulation.Parse(filename, 0, 0, datdata, _logger, true);
|
||||||
|
|
||||||
// Create each of the respective output DATs
|
// Create each of the respective output DATs
|
||||||
_logger.User("Creating and populating new 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<string, List<RomData>>(),
|
||||||
|
};
|
||||||
DatData sha1 = new DatData
|
DatData sha1 = new DatData
|
||||||
{
|
{
|
||||||
Name = datdata.Name + " (SHA-1)",
|
Name = datdata.Name + " (SHA-1)",
|
||||||
@@ -195,8 +215,8 @@ namespace SabreTools
|
|||||||
};
|
};
|
||||||
DatData crc = new DatData
|
DatData crc = new DatData
|
||||||
{
|
{
|
||||||
Name = datdata.Name + " (CRC and None)",
|
Name = datdata.Name + " (CRC)",
|
||||||
Description = datdata.Description + " (CRC and None)",
|
Description = datdata.Description + " (CRC)",
|
||||||
Category = datdata.Category,
|
Category = datdata.Category,
|
||||||
Version = datdata.Version,
|
Version = datdata.Version,
|
||||||
Date = datdata.Date,
|
Date = datdata.Date,
|
||||||
@@ -222,8 +242,22 @@ namespace SabreTools
|
|||||||
List<RomData> roms = datdata.Roms[key];
|
List<RomData> roms = datdata.Roms[key];
|
||||||
foreach (RomData rom in roms)
|
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<RomData> temp = new List<RomData>();
|
||||||
|
temp.Add(rom);
|
||||||
|
nodump.Roms.Add(key, temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
// If the file has a SHA-1
|
// 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))
|
if (sha1.Roms.ContainsKey(key))
|
||||||
{
|
{
|
||||||
@@ -281,6 +315,10 @@ namespace SabreTools
|
|||||||
// Now, output all of the files to the output directory
|
// Now, output all of the files to the output directory
|
||||||
_logger.User("DAT information created, outputting new files");
|
_logger.User("DAT information created, outputting new files");
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
if (nodump.Roms.Count > 0)
|
||||||
|
{
|
||||||
|
success &= Output.WriteDatfile(nodump, outdir, _logger);
|
||||||
|
}
|
||||||
if (sha1.Roms.Count > 0)
|
if (sha1.Roms.Count > 0)
|
||||||
{
|
{
|
||||||
success &= Output.WriteDatfile(sha1, outdir, _logger);
|
success &= Output.WriteDatfile(sha1, outdir, _logger);
|
||||||
|
|||||||
@@ -144,10 +144,7 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
// First get the combination Dictionary of currentAllMerged and currentNewMerged
|
// First get the combination Dictionary of currentAllMerged and currentNewMerged
|
||||||
_logger.User("Adding Current and New Merged DATs to the dictionary");
|
_logger.User("Adding Current and New Merged DATs to the dictionary");
|
||||||
DatData completeDats = new DatData
|
DatData completeDats = new DatData();
|
||||||
{
|
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
|
||||||
};
|
|
||||||
completeDats = RomManipulation.Parse(_currentAllMerged, 0, 0, completeDats, _logger);
|
completeDats = RomManipulation.Parse(_currentAllMerged, 0, 0, completeDats, _logger);
|
||||||
completeDats = RomManipulation.Parse(_currentNewMerged, 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))]
|
// Now create the New Missing dictionary [(Net New)+(currentMissingMerged-(Unneeded))]
|
||||||
_logger.User("Creating and populating New Missing dictionary");
|
_logger.User("Creating and populating New Missing dictionary");
|
||||||
DatData midMissing = new DatData
|
DatData midMissing = new DatData();
|
||||||
{
|
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
|
||||||
};
|
|
||||||
midMissing = RomManipulation.Parse(_currentMissingMerged, 0, 0, midMissing, _logger);
|
midMissing = RomManipulation.Parse(_currentMissingMerged, 0, 0, midMissing, _logger);
|
||||||
foreach (string key in unneeded.Keys)
|
foreach (string key in unneeded.Keys)
|
||||||
{
|
{
|
||||||
@@ -454,10 +448,7 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
// Now create the Have dictionary [(currentAllMerged)-(currentMissingMerged)]
|
// Now create the Have dictionary [(currentAllMerged)-(currentMissingMerged)]
|
||||||
_logger.User("Creating and populating Have dictionary");
|
_logger.User("Creating and populating Have dictionary");
|
||||||
DatData midHave = new DatData
|
DatData midHave = new DatData();
|
||||||
{
|
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
|
||||||
};
|
|
||||||
midHave = RomManipulation.Parse(_currentMissingMerged, 0, 0, midHave, _logger);
|
midHave = RomManipulation.Parse(_currentMissingMerged, 0, 0, midHave, _logger);
|
||||||
midHave = RomManipulation.Parse(_currentAllMerged, 0, 0, midHave, _logger);
|
midHave = RomManipulation.Parse(_currentAllMerged, 0, 0, midHave, _logger);
|
||||||
Dictionary<string, List<RomData>> have = new Dictionary<string, List<RomData>>();
|
Dictionary<string, List<RomData>> have = new Dictionary<string, List<RomData>>();
|
||||||
@@ -527,10 +518,7 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
// Now create the Have dictionary [(currentNewMerged)-(currentMissingMerged)]
|
// Now create the Have dictionary [(currentNewMerged)-(currentMissingMerged)]
|
||||||
_logger.User("Creating and populating Have dictionary");
|
_logger.User("Creating and populating Have dictionary");
|
||||||
DatData midHave = new DatData
|
DatData midHave = new DatData();
|
||||||
{
|
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
|
||||||
};
|
|
||||||
midHave = RomManipulation.Parse(_currentMissingMerged, 0, 0, midHave, _logger);
|
midHave = RomManipulation.Parse(_currentMissingMerged, 0, 0, midHave, _logger);
|
||||||
midHave = RomManipulation.Parse(_currentNewMerged, 0, 0, midHave, _logger);
|
midHave = RomManipulation.Parse(_currentNewMerged, 0, 0, midHave, _logger);
|
||||||
Dictionary<string, List<RomData>> have = new Dictionary<string, List<RomData>>();
|
Dictionary<string, List<RomData>> have = new Dictionary<string, List<RomData>>();
|
||||||
|
|||||||
@@ -100,6 +100,12 @@ namespace SabreTools.Helper
|
|||||||
/// <returns>DatData object representing the read-in data</returns>
|
/// <returns>DatData object representing the read-in data</returns>
|
||||||
public static DatData Parse(string filename, int sysid, int srcid, DatData datdata, Logger logger, bool keep = false)
|
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<string, List<RomData>>();
|
||||||
|
}
|
||||||
|
|
||||||
// Prepare all internal variables
|
// Prepare all internal variables
|
||||||
XmlReader subreader, headreader, flagreader;
|
XmlReader subreader, headreader, flagreader;
|
||||||
bool superdat = false, nodump = false, empty = true;
|
bool superdat = false, nodump = false, empty = true;
|
||||||
|
|||||||
@@ -34,10 +34,7 @@ namespace SabreTools
|
|||||||
long size = 0;
|
long size = 0;
|
||||||
foreach (string filename in inputs)
|
foreach (string filename in inputs)
|
||||||
{
|
{
|
||||||
DatData datdata = new DatData
|
DatData datdata = new DatData();
|
||||||
{
|
|
||||||
Roms = new Dictionary<string, List<RomData>>(),
|
|
||||||
};
|
|
||||||
datdata = RomManipulation.Parse(filename, 0, 0, datdata, logger);
|
datdata = RomManipulation.Parse(filename, 0, 0, datdata, logger);
|
||||||
foreach (List<RomData> romlist in datdata.Roms.Values)
|
foreach (List<RomData> romlist in datdata.Roms.Values)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user