mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[SabreTools, Flags, DatFile, README] Add update description
This commit is contained in:
@@ -1786,9 +1786,6 @@ namespace SabreTools.Library.DatFiles
|
|||||||
|
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
|
|
||||||
// For comparison's sake, we want to use CRC as the base ordering
|
|
||||||
BucketBy(SortedBy.CRC, DedupeType.Full);
|
|
||||||
|
|
||||||
// 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)
|
||||||
{
|
{
|
||||||
@@ -1798,7 +1795,12 @@ namespace SabreTools.Library.DatFiles
|
|||||||
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);
|
||||||
|
|
||||||
|
// If we are matching based on hashes of any sort
|
||||||
|
if ((replaceMode & ReplaceMode.Names) != 0
|
||||||
|
|| (replaceMode & ReplaceMode.Hashes) != 0)
|
||||||
|
{
|
||||||
// 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
|
||||||
|
BucketBy(SortedBy.CRC, DedupeType.Full);
|
||||||
intDat.BucketBy(SortedBy.CRC, DedupeType.None);
|
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
|
||||||
@@ -1896,6 +1898,37 @@ namespace SabreTools.Library.DatFiles
|
|||||||
intDat.Remove(key);
|
intDat.Remove(key);
|
||||||
intDat.AddRange(key, newDatItems);
|
intDat.AddRange(key, newDatItems);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we are matching based on names of any sort
|
||||||
|
if ((replaceMode & ReplaceMode.Descriptions) != 0)
|
||||||
|
{
|
||||||
|
// For comparison's sake, we want to use Machine Name as the base ordering
|
||||||
|
BucketBy(SortedBy.Game, DedupeType.Full);
|
||||||
|
intDat.BucketBy(SortedBy.Game, DedupeType.None);
|
||||||
|
|
||||||
|
// Then we do a namewise comparison against the base DAT
|
||||||
|
List<string> keys = intDat.Keys;
|
||||||
|
Parallel.ForEach(keys, Globals.ParallelOptions, key =>
|
||||||
|
{
|
||||||
|
List<DatItem> datItems = intDat[key];
|
||||||
|
List<DatItem> newDatItems = new List<DatItem>();
|
||||||
|
foreach (DatItem datItem in datItems)
|
||||||
|
{
|
||||||
|
DatItem newDatItem = (DatItem)datItem.Clone();
|
||||||
|
if (Contains(key) && this[key].Count() > 0)
|
||||||
|
{
|
||||||
|
newDatItem.MachineDescription = this[key][0].MachineDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
newDatItems.Add(newDatItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now add the new list to the key
|
||||||
|
intDat.Remove(key);
|
||||||
|
intDat.AddRange(key, newDatItems);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Determine the output path for the DAT
|
// Determine the output path for the DAT
|
||||||
string interOutDir = Utilities.GetOutputPath(outDir, path, inplace);
|
string interOutDir = Utilities.GetOutputPath(outDir, path, inplace);
|
||||||
|
|||||||
@@ -251,6 +251,7 @@ namespace SabreTools.Library.Data
|
|||||||
None = 0x0,
|
None = 0x0,
|
||||||
Names = 0x1,
|
Names = 0x1,
|
||||||
Hashes = Names << 1,
|
Hashes = Names << 1,
|
||||||
|
Descriptions = Hashes << 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1156,8 +1156,12 @@ Options:
|
|||||||
Add a DAT or folder of DATs to the base set to be used in
|
Add a DAT or folder of DATs to the base set to be used in
|
||||||
item name replacement
|
item name replacement
|
||||||
|
|
||||||
-un, --update-names Update names from base DATs
|
-un, --update-names Update item names from base DATs
|
||||||
This flag enables updating of names from base DATs.
|
This flag enables updating of item names from base DATs.
|
||||||
|
|
||||||
|
-udd, --update-desc Update machine descriptions from base DATs
|
||||||
|
This flag enables updating of machine descriptions from base
|
||||||
|
DATs
|
||||||
|
|
||||||
-uh, --update-hashes Update hashes from base DATs
|
-uh, --update-hashes Update hashes from base DATs
|
||||||
This flag enables updating of hashes from base DATs.
|
This flag enables updating of hashes from base DATs.
|
||||||
|
|||||||
@@ -1272,7 +1272,12 @@ namespace SabreTools
|
|||||||
null));
|
null));
|
||||||
update["base-replace"].AddFeature("update-names", new Feature(
|
update["base-replace"].AddFeature("update-names", new Feature(
|
||||||
new List<string>() { "-un", "--update-names" },
|
new List<string>() { "-un", "--update-names" },
|
||||||
"Update names from base DATs",
|
"Update item names from base DATs",
|
||||||
|
FeatureType.Flag,
|
||||||
|
null));
|
||||||
|
update["base-replace"].AddFeature("update-desc", new Feature(
|
||||||
|
new List<string>() { "-udd", "--update-desc" },
|
||||||
|
"Update machine descriptions from base DATs",
|
||||||
FeatureType.Flag,
|
FeatureType.Flag,
|
||||||
null));
|
null));
|
||||||
update["base-replace"].AddFeature("update-hashes", new Feature(
|
update["base-replace"].AddFeature("update-hashes", new Feature(
|
||||||
|
|||||||
@@ -488,6 +488,9 @@ namespace SabreTools
|
|||||||
case "update-dat":
|
case "update-dat":
|
||||||
updateDat = true;
|
updateDat = true;
|
||||||
break;
|
break;
|
||||||
|
case "update-desc":
|
||||||
|
replaceMode |= ReplaceMode.Descriptions;
|
||||||
|
break;
|
||||||
case "update-hashes":
|
case "update-hashes":
|
||||||
replaceMode |= ReplaceMode.Hashes;
|
replaceMode |= ReplaceMode.Hashes;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user