mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Move GetDuplicateStatus implementations
This commit is contained in:
@@ -234,105 +234,6 @@ namespace SabreTools.DatItems
|
||||
return _internal.EqualTo(other._internal);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the duplicate status of two items
|
||||
/// </summary>
|
||||
/// <param name="lastItem">DatItem to check against</param>
|
||||
/// <returns>The DupeType corresponding to the relationship between the two</returns>
|
||||
public DupeType GetDuplicateStatus(DatItem? lastItem)
|
||||
{
|
||||
DupeType output = 0x00;
|
||||
|
||||
// If we don't have a duplicate at all, return none
|
||||
if (!Equals(lastItem))
|
||||
return output;
|
||||
|
||||
// Get the sources for comparison
|
||||
var selfSource = GetFieldValue<Source?>(SourceKey);
|
||||
var lastSource = lastItem.GetFieldValue<Source?>(SourceKey);
|
||||
|
||||
// Get the machines for comparison
|
||||
var selfMachine = GetMachine();
|
||||
string? selfMachineName = selfMachine?.GetName();
|
||||
var lastMachine = lastItem.GetMachine();
|
||||
string? lastMachineName = lastMachine?.GetName();
|
||||
|
||||
// If the duplicate is external already
|
||||
#if NET20 || NET35
|
||||
if ((lastItem.GetFieldValue<DupeType>(DupeTypeKey) & DupeType.External) != 0)
|
||||
#else
|
||||
if (lastItem.GetFieldValue<DupeType>(DupeTypeKey).HasFlag(DupeType.External))
|
||||
#endif
|
||||
output |= DupeType.External;
|
||||
|
||||
// If the duplicate should be external
|
||||
else if (lastSource?.Index != selfSource?.Index)
|
||||
output |= DupeType.External;
|
||||
|
||||
// Otherwise, it's considered an internal dupe
|
||||
else
|
||||
output |= DupeType.Internal;
|
||||
|
||||
// If the item and machine names match
|
||||
if (lastMachineName == selfMachineName && lastItem.GetName() == GetName())
|
||||
output |= DupeType.All;
|
||||
|
||||
// Otherwise, hash match is assumed
|
||||
else
|
||||
output |= DupeType.Hash;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the duplicate status of two items
|
||||
/// </summary>
|
||||
/// <param name="selfSource">Source associated with this item</param>
|
||||
/// <param name="lastItem">DatItem to check against</param>
|
||||
/// <param name="lastSource">Source associated with the last item</param>
|
||||
/// <returns>The DupeType corresponding to the relationship between the two</returns>
|
||||
public DupeType GetDuplicateStatusDB(Source? selfSource, DatItem? lastItem, Source? lastSource)
|
||||
{
|
||||
DupeType output = 0x00;
|
||||
|
||||
// If we don't have a duplicate at all, return none
|
||||
if (!Equals(lastItem))
|
||||
return output;
|
||||
|
||||
// TODO: Fix this since machines are determined in a different way
|
||||
// Get the machines for comparison
|
||||
var selfMachine = GetMachine();
|
||||
string? selfMachineName = selfMachine?.GetName();
|
||||
var lastMachine = lastItem.GetMachine();
|
||||
string? lastMachineName = lastMachine?.GetName();
|
||||
|
||||
// If the duplicate is external already
|
||||
#if NET20 || NET35
|
||||
if ((lastItem.GetFieldValue<DupeType>(DupeTypeKey) & DupeType.External) != 0)
|
||||
#else
|
||||
if (lastItem.GetFieldValue<DupeType>(DupeTypeKey).HasFlag(DupeType.External))
|
||||
#endif
|
||||
output |= DupeType.External;
|
||||
|
||||
// If the duplicate should be external
|
||||
else if (lastSource?.Index != selfSource?.Index)
|
||||
output |= DupeType.External;
|
||||
|
||||
// Otherwise, it's considered an internal dupe
|
||||
else
|
||||
output |= DupeType.Internal;
|
||||
|
||||
// If the item and machine names match
|
||||
if (lastMachineName == selfMachineName && lastItem.GetName() == GetName())
|
||||
output |= DupeType.All;
|
||||
|
||||
// Otherwise, hash match is assumed
|
||||
else
|
||||
output |= DupeType.Hash;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation
|
||||
|
||||
Reference in New Issue
Block a user