mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Unify ContainsWritable implementations
This commit is contained in:
@@ -244,12 +244,6 @@ namespace SabreTools.DatFiles.Test
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ContainsWritableDB
|
|
||||||
|
|
||||||
// TODO: Write ContainsWritableDB tests
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region ResolveNames
|
#region ResolveNames
|
||||||
|
|
||||||
// TODO: Write ResolveNames tests
|
// TODO: Write ResolveNames tests
|
||||||
|
|||||||
@@ -469,28 +469,6 @@ namespace SabreTools.DatFiles
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get if a machine contains any writable items
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="datItems">DatItems to check</param>
|
|
||||||
/// <returns>True if the machine contains at least one writable item, false otherwise</returns>
|
|
||||||
/// <remarks>Empty machines are kept with this</remarks>
|
|
||||||
protected bool ContainsWritableDB(Dictionary<long, DatItem>? datItems)
|
|
||||||
{
|
|
||||||
// Empty machines are considered writable
|
|
||||||
if (datItems == null || datItems.Count == 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
foreach (var datItem in datItems)
|
|
||||||
{
|
|
||||||
ItemType itemType = datItem.Value.GetStringFieldValue(Models.Metadata.DatItem.TypeKey).AsEnumValue<ItemType>();
|
|
||||||
if (Array.Exists(SupportedTypes, t => t == itemType))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resolve name duplicates in an arbitrary set of DatItems based on the supplied information
|
/// Resolve name duplicates in an arbitrary set of DatItems based on the supplied information
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
{
|
{
|
||||||
// If this machine doesn't contain any writable items, skip
|
// If this machine doesn't contain any writable items, skip
|
||||||
var itemsDict = ItemsDB.GetItemsForBucket(key, filter: true);
|
var itemsDict = ItemsDB.GetItemsForBucket(key, filter: true);
|
||||||
if (itemsDict == null || !ContainsWritableDB(itemsDict))
|
if (itemsDict == null || !ContainsWritable([.. itemsDict.Values]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Resolve the names in the block
|
// Resolve the names in the block
|
||||||
|
|||||||
@@ -479,7 +479,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
{
|
{
|
||||||
// If this machine doesn't contain any writable items, skip
|
// If this machine doesn't contain any writable items, skip
|
||||||
var itemsDict = ItemsDB.GetItemsForBucket(key, filter: true);
|
var itemsDict = ItemsDB.GetItemsForBucket(key, filter: true);
|
||||||
if (itemsDict == null || !ContainsWritableDB(itemsDict))
|
if (itemsDict == null || !ContainsWritable([.. itemsDict.Values]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Resolve the names in the block
|
// Resolve the names in the block
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
{
|
{
|
||||||
// If this machine doesn't contain any writable items, skip
|
// If this machine doesn't contain any writable items, skip
|
||||||
var itemsDict = ItemsDB.GetItemsForBucket(key, filter: true);
|
var itemsDict = ItemsDB.GetItemsForBucket(key, filter: true);
|
||||||
if (itemsDict == null || !ContainsWritableDB(itemsDict))
|
if (itemsDict == null || !ContainsWritable([.. itemsDict.Values]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Resolve the names in the block
|
// Resolve the names in the block
|
||||||
|
|||||||
Reference in New Issue
Block a user