diff --git a/SabreTools.Library/DatFiles/DatFile.cs b/SabreTools.Library/DatFiles/DatFile.cs index 4f87193f..bdee9a56 100644 --- a/SabreTools.Library/DatFiles/DatFile.cs +++ b/SabreTools.Library/DatFiles/DatFile.cs @@ -1590,10 +1590,9 @@ namespace SabreTools.Library.DatFiles /// True to allow SL DATs to have game names used instead of descriptions, false otherwise (default) /// Filter object to be passed to the DatItem level /// Type of the split that should be performed (split, merged, fully merged) - /// True if names should be updated, false otherwise [only for base replacement] - /// True if hashes should be updated, false otherwise [only for base replacement] + /// ReplaceMode representing what should be updated [only for base replacement] public void DetermineUpdateType(List inputPaths, List basePaths, string outDir, UpdateMode updateMode, bool inplace, bool skip, - bool bare, bool clean, bool remUnicode, bool descAsName, Filter filter, SplitType splitType, bool updateNames, bool updateHashes) + bool bare, bool clean, bool remUnicode, bool descAsName, Filter filter, SplitType splitType, ReplaceMode replaceMode) { // Ensure we only have files in the inputs List inputFileNames = Utilities.GetOnlyFilesFromInputs(inputPaths, appendparent: true); @@ -1647,7 +1646,7 @@ namespace SabreTools.Library.DatFiles else if ((updateMode & UpdateMode.BaseReplace) != 0 || (updateMode & UpdateMode.ReverseBaseReplace) != 0) { - BaseReplace(inputFileNames, baseFileNames, outDir, inplace, clean, remUnicode, descAsName, filter, splitType, updateNames, updateHashes); + BaseReplace(inputFileNames, baseFileNames, outDir, inplace, clean, remUnicode, descAsName, filter, splitType, replaceMode); } return; @@ -1729,10 +1728,9 @@ namespace SabreTools.Library.DatFiles /// True if we are supposed to trim names to NTFS length, false otherwise /// True if all games should be replaced by '!', false otherwise /// String representing root directory to compare against for length calculation - /// True if names should be updated, false otherwise - /// True if hashes should be updated, false otherwise + /// ReplaceMode representing what should be updated public void BaseReplace(List inputFileNames, List baseFileNames, string outDir, bool inplace, bool clean, bool remUnicode, - bool descAsName, Filter filter, SplitType splitType, bool updateNames, bool updateHashes) + bool descAsName, Filter filter, SplitType splitType, ReplaceMode replaceMode) { // First we want to parse all of the base DATs into the input InternalStopwatch watch = new InternalStopwatch("Populating base DAT for replacement..."); @@ -1789,13 +1787,13 @@ namespace SabreTools.Library.DatFiles if (dupes.Count > 0) { // If we're updating names, replace using the first found name - if (updateNames) + if ((replaceMode & ReplaceMode.Names) != 0) { newDatItem.Name = dupes[0].Name; } // If we're updating hashes, only replace if the current item doesn't have them - if (updateHashes) + if ((replaceMode & ReplaceMode.Hashes) != 0) { if (newDatItem.Type == ItemType.Rom) { diff --git a/SabreTools/SabreTools.Inits.cs b/SabreTools/SabreTools.Inits.cs index e87dcf25..5549b505 100644 --- a/SabreTools/SabreTools.Inits.cs +++ b/SabreTools/SabreTools.Inits.cs @@ -233,8 +233,7 @@ namespace SabreTools /// True to clean the game names to WoD standard, false otherwise (default) /// True if we should remove non-ASCII characters from output, false otherwise (default) /// True if descriptions should be used as names, false otherwise (default) - /// True if names should be updated, false otherwise [only for base replacement] - /// True if hashes should be updated, false otherwise [only for base replacement] + /// ReplaceMode representing what should be updated [only for base replacement] private static void InitUpdate( List inputPaths, List basePaths, @@ -257,8 +256,7 @@ namespace SabreTools bool clean, bool remUnicode, bool descAsName, - bool updateNames, - bool updateHashes) + ReplaceMode replaceMode) { // Normalize the extensions datHeader.AddExtension = (String.IsNullOrWhiteSpace(datHeader.AddExtension) || datHeader.AddExtension.StartsWith(".") @@ -302,17 +300,17 @@ namespace SabreTools } } - // If neither the names or hashes are set, select names - if (!updateNames && !updateHashes) + // If no replacement mode is set, default to Names + if (replaceMode == ReplaceMode.None) { - updateNames = true; + replaceMode = ReplaceMode.Names; } // Populate the DatData object DatFile userInputDat = new DatFile(datHeader); userInputDat.DetermineUpdateType(inputPaths, basePaths, outDir, updateMode, inplace, skip, bare, clean, - remUnicode, descAsName, filter, splitType, updateNames, updateHashes); + remUnicode, descAsName, filter, splitType, replaceMode); } /// diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs index da09b061..cc42037a 100644 --- a/SabreTools/SabreTools.cs +++ b/SabreTools/SabreTools.cs @@ -93,11 +93,10 @@ namespace SabreTools showNodumpColumn = false, shortname = false, skip = false, - updateDat = false, - updateHashes = false, - updateNames = false; + updateDat = false; Hash omitFromScan = Hash.DeepHashes; // TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually OutputFormat outputFormat = OutputFormat.Folder; + ReplaceMode replaceMode = ReplaceMode.None; SkipFileType skipFileType = SkipFileType.None; SplittingMode splittingMode = SplittingMode.None; SplitType splitType = SplitType.None; @@ -490,10 +489,10 @@ namespace SabreTools updateDat = true; break; case "update-hashes": - updateHashes = true; + replaceMode |= ReplaceMode.Hashes; break; case "update-names": - updateNames = true; + replaceMode |= ReplaceMode.Names; break; case "exclude-of": datHeader.ExcludeOf = true; @@ -728,7 +727,7 @@ namespace SabreTools case "Update": VerifyInputs(inputs, feature); InitUpdate(inputs, basePaths, datHeader, updateMode, inplace, skip, removeDateFromAutomaticName, filter, - splitType, outDir, cleanGameNames, removeUnicode, descAsName, updateNames, updateHashes); + splitType, outDir, cleanGameNames, removeUnicode, descAsName, replaceMode); break; // If we're using the verifier case "Verify":