diff --git a/DATabase/DATabase.cs b/DATabase/DATabase.cs index 48f7b253..b2099605 100644 --- a/DATabase/DATabase.cs +++ b/DATabase/DATabase.cs @@ -874,7 +874,7 @@ Make a selection: 4) Category" + (cat != "" ? ":\t" + cat : "") + @" 5) Version" + (version != "" ? ":\t" + version : "") + @" 6) Author" + (author != "" ? ":\t" + author : "") + @" - 7) " + (ad ? "Only output normal diff" : "Output all diff variants") + @" + 7) " + (ad ? "Only output normal diff" : "Output all diff variants (2 files only)") + @" 8) " + (dedup ? "Don't dedup files in output" : "Dedup files in output") + @" 9) " + (diff ? "Only merge the input files" : "Diff the input files") + @" 10) " + (bare ? "Don't append the date to the name" : "Append the date to the name") + @" diff --git a/DATabase/MergeDiff.cs b/DATabase/MergeDiff.cs index b0514932..cbc071ec 100644 --- a/DATabase/MergeDiff.cs +++ b/DATabase/MergeDiff.cs @@ -81,29 +81,7 @@ namespace SabreTools return false; } - List A = new List(); - - foreach (string input in _inputs) - { - _logger.Log("Adding DAT: " + input); - List B = RomManipulation.Parse(input, 0, 0, _logger); - if (_diff) - { - A = RomManipulation.Diff(A, B); - } - else - { - A.AddRange(B); - } - } - - // If we want a merged list, send it for merging before outputting - if (_dedup) - { - A = RomManipulation.Merge(A); - } - - // Get the names that will be used + // Get the values that will be used if (_name == "") { _name = (_diff ? "diffdat" : "mergedat") + (_dedup ? "-merged" : ""); @@ -125,6 +103,46 @@ namespace SabreTools _author = "SabreTools"; } + List A = new List(); + + foreach (string input in _inputs) + { + _logger.Log("Adding DAT: " + input); + List B = RomManipulation.Parse(input, 0, 0, _logger); + if (_diff) + { + A = RomManipulation.Diff(A, B); + } + else + { + A.AddRange(B); + } + } + + // If we're in Alldiff mode, we can only use the first 2 inputs + if (_ad) + { + List AB1 = RomManipulation.Parse(_inputs[0], 0, 0, _logger); + List AB2 = RomManipulation.Parse(_inputs[1], 0, 0, _logger); + + List OnlyA = RomManipulation.DiffOnlyInA(AB1, AB2); + List OnlyB = RomManipulation.DiffOnlyInA(AB2, AB1); + List BothAB = RomManipulation.DiffInAB(AB1, AB2); + + string input0 = Path.GetFileNameWithoutExtension(_inputs[0]); + string input1 = Path.GetFileNameWithoutExtension(_inputs[1]); + + Output.WriteToDat(_name + "-" + input0 + "-only", _desc + "-" + input0 + "-only", _version, _date, _cat, _author, _forceunpack, _old, "", OnlyA, _logger); + Output.WriteToDat(_name + "-" + input1 + "-only", _desc + "-" + input1 + "-only", _version, _date, _cat, _author, _forceunpack, _old, "", OnlyB, _logger); + Output.WriteToDat(_name + "-inboth", _desc + "-inboth", _version, _date, _cat, _author, _forceunpack, _old, "", BothAB, _logger); + } + + // If we want a merged list, send it for merging before outputting + if (_dedup) + { + A = RomManipulation.Merge(A); + } + // Now write the file out Output.WriteToDat(_name, _desc, _version, _date, _cat, _author, _forceunpack, _old, "", A, _logger); diff --git a/SabreHelper/Build.cs b/SabreHelper/Build.cs index 8378cfdd..5d0ec908 100644 --- a/SabreHelper/Build.cs +++ b/SabreHelper/Build.cs @@ -118,7 +118,7 @@ Options: -lso, --list-sources List all sources (id <= name) -lsy, --list-systems List all systems (id <= name) -m, --merge Merge two or more DATs - -ad, --all-diff Enable output of all diff variants + -ad, --all-diff Enable output of all diff variants (2 DATs only) -di, --diff Switch to diffdat mode -dd, --dedup Enable deduping in the created DAT -b, --bare Don't include date in file name