Simplify conditional source update

This commit is contained in:
Matt Nadareski
2025-01-06 15:56:48 -05:00
parent 8d845df8b9
commit 02cdfb53ae

View File

@@ -170,7 +170,6 @@ namespace SabreTools.DatItems
/// <param name="item">Existing item to copy information from</param>
/// <remarks>
/// The cases when Source data is updated:
/// - Current source data is missing and the other item has a source
/// - Current source data has an index higher than the other item
/// </remarks>
public void ConditionalUpdateSource(DatItem item)
@@ -179,19 +178,6 @@ namespace SabreTools.DatItems
Source? selfSource = GetFieldValue<Source?>(DatItem.SourceKey);
Source? itemSource = item.GetFieldValue<Source?>(DatItem.SourceKey);
// If both sources are missing, do nothing
if (selfSource == null && itemSource == null)
return;
// Use the new source if missing
if (selfSource == null && itemSource != null)
{
SetFieldValue<Source?>(DatItem.SourceKey, itemSource.Clone() as Source);
CopyMachineInformation(item);
SetName(item.GetName());
return;
}
// If either source is missing
if (selfSource == null || itemSource == null)
return;