mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[SabreTools, DatFiles/] Fix merging, fix replacement
This commit is contained in:
@@ -33,6 +33,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
this._datHeader = datFile._datHeader;
|
this._datHeader = datFile._datHeader;
|
||||||
this._items = datFile._items;
|
this._items = datFile._items;
|
||||||
this._sortedBy = datFile._sortedBy;
|
this._sortedBy = datFile._sortedBy;
|
||||||
|
this._mergedBy = datFile._mergedBy;
|
||||||
this._datStats = datFile._datStats;
|
this._datStats = datFile._datStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
this._datHeader = datFile._datHeader;
|
this._datHeader = datFile._datHeader;
|
||||||
this._items = datFile._items;
|
this._items = datFile._items;
|
||||||
this._sortedBy = datFile._sortedBy;
|
this._sortedBy = datFile._sortedBy;
|
||||||
|
this._mergedBy = datFile._mergedBy;
|
||||||
this._datStats = datFile._datStats;
|
this._datStats = datFile._datStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
// DatItems dictionary
|
// DatItems dictionary
|
||||||
internal SortedDictionary<string, List<DatItem>> _items = new SortedDictionary<string, List<DatItem>>();
|
internal SortedDictionary<string, List<DatItem>> _items = new SortedDictionary<string, List<DatItem>>();
|
||||||
internal SortedBy _sortedBy;
|
internal SortedBy _sortedBy;
|
||||||
|
internal DedupeType _mergedBy;
|
||||||
|
|
||||||
// Internal statistical data
|
// Internal statistical data
|
||||||
internal DatStats _datStats = new DatStats();
|
internal DatStats _datStats = new DatStats();
|
||||||
@@ -1395,7 +1396,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
// If the sorted type isn't the same, we want to sort the dictionary accordingly
|
// If the sorted type isn't the same, we want to sort the dictionary accordingly
|
||||||
if (_sortedBy != bucketBy)
|
if (_sortedBy != bucketBy)
|
||||||
{
|
{
|
||||||
Globals.Logger.User("Organizing roms by {0}" + (deduperoms != DedupeType.None ? " and merging" : ""), bucketBy);
|
Globals.Logger.User("Organizing roms by {0}", bucketBy);
|
||||||
|
|
||||||
// Set the sorted type
|
// Set the sorted type
|
||||||
_sortedBy = bucketBy;
|
_sortedBy = bucketBy;
|
||||||
@@ -1426,7 +1427,14 @@ namespace SabreTools.Library.DatFiles
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now go through and sort all of the individual lists
|
// If the merge type isn't the same, we want to merge the dictionary accordingly
|
||||||
|
if (_mergedBy != deduperoms)
|
||||||
|
{
|
||||||
|
Globals.Logger.User("Deduping roms by {0}", deduperoms);
|
||||||
|
|
||||||
|
// Set the sorted type
|
||||||
|
_mergedBy = deduperoms;
|
||||||
|
|
||||||
List<string> keys = Keys;
|
List<string> keys = Keys;
|
||||||
Parallel.ForEach(keys, Globals.ParallelOptions, key =>
|
Parallel.ForEach(keys, Globals.ParallelOptions, key =>
|
||||||
{
|
{
|
||||||
@@ -1447,6 +1455,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
AddRange(key, sortedlist);
|
AddRange(key, sortedlist);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the dictionary key that should be used for a given item and sorting type
|
/// Get the dictionary key that should be used for a given item and sorting type
|
||||||
@@ -1607,13 +1616,11 @@ namespace SabreTools.Library.DatFiles
|
|||||||
baseFileNames.Reverse();
|
baseFileNames.Reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate the combined data and get the headers
|
|
||||||
List<DatFile> datHeaders = PopulateUserData(inputFileNames, inplace, clean,
|
|
||||||
remUnicode, descAsName, outDir, filter, splitType);
|
|
||||||
|
|
||||||
// If we're in merging mode
|
// If we're in merging mode
|
||||||
if ((updateMode & UpdateMode.Merge) != 0)
|
if ((updateMode & UpdateMode.Merge) != 0)
|
||||||
{
|
{
|
||||||
|
// Populate the combined data and get the headers
|
||||||
|
List<DatFile> datHeaders = PopulateUserData(inputFileNames, inplace, clean, remUnicode, descAsName, outDir, filter, splitType);
|
||||||
MergeNoDiff(outDir, inputFileNames, datHeaders);
|
MergeNoDiff(outDir, inputFileNames, datHeaders);
|
||||||
}
|
}
|
||||||
// If we have one of the standard diffing modes
|
// If we have one of the standard diffing modes
|
||||||
@@ -1627,6 +1634,8 @@ namespace SabreTools.Library.DatFiles
|
|||||||
else if ((updateMode & UpdateMode.DiffCascade) != 0
|
else if ((updateMode & UpdateMode.DiffCascade) != 0
|
||||||
|| (updateMode & UpdateMode.DiffReverseCascade) != 0)
|
|| (updateMode & UpdateMode.DiffReverseCascade) != 0)
|
||||||
{
|
{
|
||||||
|
// Populate the combined data and get the headers
|
||||||
|
List<DatFile> datHeaders = PopulateUserData(inputFileNames, inplace, clean, remUnicode, descAsName, outDir, filter, splitType);
|
||||||
DiffCascade(outDir, inplace, inputFileNames, datHeaders, skip);
|
DiffCascade(outDir, inplace, inputFileNames, datHeaders, skip);
|
||||||
}
|
}
|
||||||
// If we have diff against mode
|
// If we have diff against mode
|
||||||
@@ -1750,14 +1759,14 @@ namespace SabreTools.Library.DatFiles
|
|||||||
// Now we want to try to replace each item in each input DAT from the base
|
// Now we want to try to replace each item in each input DAT from the base
|
||||||
foreach (string path in inputFileNames)
|
foreach (string path in inputFileNames)
|
||||||
{
|
{
|
||||||
Globals.Logger.User("Replacing items in '{0}'' from the base DAT", path.Split('¬')[0]);
|
Globals.Logger.User("Replacing items in '{0}' from the base DAT", path.Split('¬')[0]);
|
||||||
|
|
||||||
// First we parse in the DAT internally
|
// First we parse in the DAT internally
|
||||||
DatFile intDat = new DatFile();
|
DatFile intDat = new DatFile();
|
||||||
intDat.Parse(path, 1, 1, keep: true, clean: clean, remUnicode: remUnicode, descAsName: descAsName);
|
intDat.Parse(path, 1, 1, keep: true, clean: clean, remUnicode: remUnicode, descAsName: descAsName);
|
||||||
|
|
||||||
// For comparison's sake, we want to use CRC as the base ordering
|
// For comparison's sake, we want to use CRC as the base ordering
|
||||||
intDat.BucketBy(SortedBy.CRC, DedupeType.Full);
|
intDat.BucketBy(SortedBy.CRC, DedupeType.None);
|
||||||
|
|
||||||
// Then we do a hashwise comparison against the base DAT
|
// Then we do a hashwise comparison against the base DAT
|
||||||
List<string> keys = intDat.Keys;
|
List<string> keys = intDat.Keys;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
this._datHeader = datFile._datHeader;
|
this._datHeader = datFile._datHeader;
|
||||||
this._items = datFile._items;
|
this._items = datFile._items;
|
||||||
this._sortedBy = datFile._sortedBy;
|
this._sortedBy = datFile._sortedBy;
|
||||||
|
this._mergedBy = datFile._mergedBy;
|
||||||
this._datStats = datFile._datStats;
|
this._datStats = datFile._datStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
this._datHeader = datFile._datHeader;
|
this._datHeader = datFile._datHeader;
|
||||||
this._items = datFile._items;
|
this._items = datFile._items;
|
||||||
this._sortedBy = datFile._sortedBy;
|
this._sortedBy = datFile._sortedBy;
|
||||||
|
this._mergedBy = datFile._mergedBy;
|
||||||
this._datStats = datFile._datStats;
|
this._datStats = datFile._datStats;
|
||||||
_hash = hash;
|
_hash = hash;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
this._datHeader = datFile._datHeader;
|
this._datHeader = datFile._datHeader;
|
||||||
this._items = datFile._items;
|
this._items = datFile._items;
|
||||||
this._sortedBy = datFile._sortedBy;
|
this._sortedBy = datFile._sortedBy;
|
||||||
|
this._mergedBy = datFile._mergedBy;
|
||||||
this._datStats = datFile._datStats;
|
this._datStats = datFile._datStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
this._datHeader = datFile._datHeader;
|
this._datHeader = datFile._datHeader;
|
||||||
this._items = datFile._items;
|
this._items = datFile._items;
|
||||||
this._sortedBy = datFile._sortedBy;
|
this._sortedBy = datFile._sortedBy;
|
||||||
|
this._mergedBy = datFile._mergedBy;
|
||||||
this._datStats = datFile._datStats;
|
this._datStats = datFile._datStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
this._datHeader = datFile._datHeader;
|
this._datHeader = datFile._datHeader;
|
||||||
this._items = datFile._items;
|
this._items = datFile._items;
|
||||||
this._sortedBy = datFile._sortedBy;
|
this._sortedBy = datFile._sortedBy;
|
||||||
|
this._mergedBy = datFile._mergedBy;
|
||||||
this._datStats = datFile._datStats;
|
this._datStats = datFile._datStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
this._datHeader = datFile._datHeader;
|
this._datHeader = datFile._datHeader;
|
||||||
this._items = datFile._items;
|
this._items = datFile._items;
|
||||||
this._sortedBy = datFile._sortedBy;
|
this._sortedBy = datFile._sortedBy;
|
||||||
|
this._mergedBy = datFile._mergedBy;
|
||||||
this._datStats = datFile._datStats;
|
this._datStats = datFile._datStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
this._datHeader = datFile._datHeader;
|
this._datHeader = datFile._datHeader;
|
||||||
this._items = datFile._items;
|
this._items = datFile._items;
|
||||||
this._sortedBy = datFile._sortedBy;
|
this._sortedBy = datFile._sortedBy;
|
||||||
|
this._mergedBy = datFile._mergedBy;
|
||||||
this._datStats = datFile._datStats;
|
this._datStats = datFile._datStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
this._datHeader = datFile._datHeader;
|
this._datHeader = datFile._datHeader;
|
||||||
this._items = datFile._items;
|
this._items = datFile._items;
|
||||||
this._sortedBy = datFile._sortedBy;
|
this._sortedBy = datFile._sortedBy;
|
||||||
|
this._mergedBy = datFile._mergedBy;
|
||||||
this._datStats = datFile._datStats;
|
this._datStats = datFile._datStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
this._datHeader = datFile._datHeader;
|
this._datHeader = datFile._datHeader;
|
||||||
this._items = datFile._items;
|
this._items = datFile._items;
|
||||||
this._sortedBy = datFile._sortedBy;
|
this._sortedBy = datFile._sortedBy;
|
||||||
|
this._mergedBy = datFile._mergedBy;
|
||||||
this._datStats = datFile._datStats;
|
this._datStats = datFile._datStats;
|
||||||
_delim = delim;
|
_delim = delim;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ namespace SabreTools.Library.DatFiles
|
|||||||
this._datHeader = datFile._datHeader;
|
this._datHeader = datFile._datHeader;
|
||||||
this._items = datFile._items;
|
this._items = datFile._items;
|
||||||
this._sortedBy = datFile._sortedBy;
|
this._sortedBy = datFile._sortedBy;
|
||||||
|
this._mergedBy = datFile._mergedBy;
|
||||||
this._datStats = datFile._datStats;
|
this._datStats = datFile._datStats;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -579,7 +579,11 @@ namespace SabreTools
|
|||||||
filter.MD5s.AddRange((List<string>)feat.Value.GetValue());
|
filter.MD5s.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "mt":
|
case "mt":
|
||||||
Globals.MaxThreads = (int)feat.Value.GetValue() == Int32.MinValue ? (int)feat.Value.GetValue() : Globals.MaxThreads;
|
int val = (int)feat.Value.GetValue();
|
||||||
|
if (val != Int32.MinValue)
|
||||||
|
{
|
||||||
|
Globals.MaxThreads = val;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "name":
|
case "name":
|
||||||
datHeader.Name = (string)feat.Value.GetValue();
|
datHeader.Name = (string)feat.Value.GetValue();
|
||||||
|
|||||||
Reference in New Issue
Block a user