mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add source-dependent machines to diffing for IDDB
This commit is contained in:
@@ -617,7 +617,7 @@ namespace SabreTools.DatTools
|
|||||||
/// <param name="inputs">List of inputs to write out from</param>
|
/// <param name="inputs">List of inputs to write out from</param>
|
||||||
public static DatFile DiffDuplicatesDB(DatFile datFile, List<ParentablePath> inputs)
|
public static DatFile DiffDuplicatesDB(DatFile datFile, List<ParentablePath> inputs)
|
||||||
{
|
{
|
||||||
InternalStopwatch watch = new("Initializing duplicate DAT");
|
var watch = new InternalStopwatch("Initializing duplicate DAT");
|
||||||
|
|
||||||
// Fill in any information not in the base DAT
|
// Fill in any information not in the base DAT
|
||||||
if (string.IsNullOrEmpty(datFile.Header.GetStringFieldValue(DatHeader.FileNameKey)))
|
if (string.IsNullOrEmpty(datFile.Header.GetStringFieldValue(DatHeader.FileNameKey)))
|
||||||
@@ -662,12 +662,7 @@ namespace SabreTools.DatTools
|
|||||||
// Loop through and add all machines
|
// Loop through and add all machines
|
||||||
foreach (var machine in machines)
|
foreach (var machine in machines)
|
||||||
{
|
{
|
||||||
// TODO: Figure out how we can reintroduce the source to this name
|
long newMachineIndex = dupeData.ItemsDB.AddMachine(machine.Value);
|
||||||
var machineValue = machine.Value;
|
|
||||||
//machineValue.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, machineValue.GetStringFieldValue(Models.Metadata.Machine.NameKey) + $" ({Path.GetFileNameWithoutExtension(inputs[newrom.GetFieldValue<Source?>(DatItem.SourceKey)!.Index].CurrentPath)})");
|
|
||||||
machineValue.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, machineValue.GetStringFieldValue(Models.Metadata.Machine.NameKey));
|
|
||||||
|
|
||||||
long newMachineIndex = dupeData.ItemsDB.AddMachine(machineValue);
|
|
||||||
machineRemapping[machine.Key] = newMachineIndex;
|
machineRemapping[machine.Key] = newMachineIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,21 +679,41 @@ namespace SabreTools.DatTools
|
|||||||
long machineIndex = itemMachineMappings[item.Key];
|
long machineIndex = itemMachineMappings[item.Key];
|
||||||
long sourceIndex = itemSourceMappings[item.Key];
|
long sourceIndex = itemSourceMappings[item.Key];
|
||||||
|
|
||||||
|
// If the current item isn't an external duplicate
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
if ((item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey) & DupeType.External) != 0)
|
if ((item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey) & DupeType.External) == 0)
|
||||||
#else
|
#else
|
||||||
if (item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey).HasFlag(DupeType.External))
|
if (!item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey).HasFlag(DupeType.External))
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
if (item.Value.Clone() is not DatItem newrom)
|
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
return;
|
return;
|
||||||
#else
|
#else
|
||||||
continue;
|
continue;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dupeData.ItemsDB.AddItem(newrom, machineRemapping[machineIndex], sourceRemapping[sourceIndex], statsOnly: false);
|
// Get the current source and machine
|
||||||
|
var currentSource = sources[sourceIndex];
|
||||||
|
string? currentMachineName = machines[machineIndex].GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||||
|
var currentMachine = datFile.ItemsDB.GetMachine(currentMachineName);
|
||||||
|
if (currentMachine.Item2 == null)
|
||||||
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
|
return;
|
||||||
|
#else
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Get the source-specific machine
|
||||||
|
string? renamedMachineName = $"{currentMachineName} ({Path.GetFileNameWithoutExtension(inputs[currentSource!.Index].CurrentPath)})";
|
||||||
|
var renamedMachine = datFile.ItemsDB.GetMachine(renamedMachineName);
|
||||||
|
if (renamedMachine.Item2 == null)
|
||||||
|
{
|
||||||
|
var newMachine = currentMachine.Item2.Clone() as Machine;
|
||||||
|
newMachine!.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, renamedMachineName);
|
||||||
|
long newMachineIndex = dupeData.ItemsDB.AddMachine(newMachine!);
|
||||||
|
renamedMachine = (newMachineIndex, newMachine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dupeData.ItemsDB.AddItem(item.Value, renamedMachine.Item1, sourceRemapping[sourceIndex], statsOnly: false);
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
});
|
});
|
||||||
#else
|
#else
|
||||||
@@ -1035,7 +1050,7 @@ namespace SabreTools.DatTools
|
|||||||
/// <param name="inputs">List of inputs to write out from</param>
|
/// <param name="inputs">List of inputs to write out from</param>
|
||||||
public static DatFile DiffNoDuplicatesDB(DatFile datFile, List<ParentablePath> inputs)
|
public static DatFile DiffNoDuplicatesDB(DatFile datFile, List<ParentablePath> inputs)
|
||||||
{
|
{
|
||||||
InternalStopwatch watch = new("Initializing no duplicate DAT");
|
var watch = new InternalStopwatch("Initializing no duplicate DAT");
|
||||||
|
|
||||||
// Fill in any information not in the base DAT
|
// Fill in any information not in the base DAT
|
||||||
if (string.IsNullOrEmpty(datFile.Header.GetStringFieldValue(DatHeader.FileNameKey)))
|
if (string.IsNullOrEmpty(datFile.Header.GetStringFieldValue(DatHeader.FileNameKey)))
|
||||||
@@ -1080,12 +1095,7 @@ namespace SabreTools.DatTools
|
|||||||
// Loop through and add all machines
|
// Loop through and add all machines
|
||||||
foreach (var machine in machines)
|
foreach (var machine in machines)
|
||||||
{
|
{
|
||||||
// TODO: Figure out how we can reintroduce the source to this name
|
long newMachineIndex = outerDiffData.ItemsDB.AddMachine(machine.Value);
|
||||||
var machineValue = machine.Value;
|
|
||||||
//machineValue.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, machineValue.GetStringFieldValue(Models.Metadata.Machine.NameKey) + $" ({Path.GetFileNameWithoutExtension(inputs[newrom.GetFieldValue<Source?>(DatItem.SourceKey)!.Index].CurrentPath)})");
|
|
||||||
machineValue.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, machineValue.GetStringFieldValue(Models.Metadata.Machine.NameKey));
|
|
||||||
|
|
||||||
long newMachineIndex = outerDiffData.ItemsDB.AddMachine(machineValue);
|
|
||||||
machineRemapping[machine.Key] = newMachineIndex;
|
machineRemapping[machine.Key] = newMachineIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1102,21 +1112,41 @@ namespace SabreTools.DatTools
|
|||||||
long machineIndex = itemMachineMappings[item.Key];
|
long machineIndex = itemMachineMappings[item.Key];
|
||||||
long sourceIndex = itemSourceMappings[item.Key];
|
long sourceIndex = itemSourceMappings[item.Key];
|
||||||
|
|
||||||
|
// If the current item isn't a duplicate
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
if ((item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey) & DupeType.Internal) != 0 || item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey) == 0x00)
|
if ((item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey) & DupeType.Internal) == 0 && item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey) != 0x00)
|
||||||
#else
|
#else
|
||||||
if (item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey).HasFlag(DupeType.Internal) || item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey) == 0x00)
|
if (!item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey).HasFlag(DupeType.Internal) && item.Value.GetFieldValue<DupeType>(DatItem.DupeTypeKey) != 0x00)
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
if (item.Value.Clone() is not DatItem newrom || sourceIndex == -1)
|
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
return;
|
return;
|
||||||
#else
|
#else
|
||||||
continue;
|
continue;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
outerDiffData.ItemsDB.AddItem(newrom, machineRemapping[machineIndex], sourceRemapping[sourceIndex], statsOnly: false);
|
// Get the current source and machine
|
||||||
|
var currentSource = sources[sourceIndex];
|
||||||
|
string? currentMachineName = machines[machineIndex].GetStringFieldValue(Models.Metadata.Machine.NameKey);
|
||||||
|
var currentMachine = datFile.ItemsDB.GetMachine(currentMachineName);
|
||||||
|
if (currentMachine.Item2 == null)
|
||||||
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
|
return;
|
||||||
|
#else
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Get the source-specific machine
|
||||||
|
string? renamedMachineName = $"{currentMachineName} ({Path.GetFileNameWithoutExtension(inputs[currentSource!.Index].CurrentPath)})";
|
||||||
|
var renamedMachine = datFile.ItemsDB.GetMachine(renamedMachineName);
|
||||||
|
if (renamedMachine.Item2 == null)
|
||||||
|
{
|
||||||
|
var newMachine = currentMachine.Item2.Clone() as Machine;
|
||||||
|
newMachine!.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, renamedMachineName);
|
||||||
|
long newMachineIndex = outerDiffData.ItemsDB.AddMachine(newMachine);
|
||||||
|
renamedMachine = (newMachineIndex, newMachine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
outerDiffData.ItemsDB.AddItem(item.Value, renamedMachine.Item1, sourceRemapping[sourceIndex], statsOnly: false);
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
});
|
});
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user