diff --git a/SabreTools.DatFiles/DatFile.Splitting.cs b/SabreTools.DatFiles/DatFile.Splitting.cs
index 85a3f5e9..ed183b38 100644
--- a/SabreTools.DatFiles/DatFile.Splitting.cs
+++ b/SabreTools.DatFiles/DatFile.Splitting.cs
@@ -65,10 +65,10 @@ namespace SabreTools.DatFiles
/// Use romof tags to remove bios items from children
///
/// True if only child Bios sets are touched, false for non-bios sets
- public void RemoveBiosItemsFromChild(bool bios)
+ public void RemoveItemsFromRomOfChild(bool bios)
{
- RemoveBiosItemsFromChildImpl(bios);
- RemoveBiosItemsFromChildImplDB(bios);
+ RemoveItemsFromRomOfChildImpl(bios);
+ RemoveItemsFromRomOfChildImplDB(bios);
}
///
@@ -966,108 +966,6 @@ namespace SabreTools.DatFiles
}
}
- ///
- /// Use romof tags to remove bios items from children
- ///
- /// True if only child Bios sets are touched, false for non-bios sets
- ///
- /// Applies to .
- /// Assumes items are bucketed by .
- ///
- private void RemoveBiosItemsFromChildImpl(bool bios)
- {
- // Loop through the romof tags
- List buckets = [.. Items.Keys];
- buckets.Sort();
-
- foreach (string bucket in buckets)
- {
- // If the bucket has no items in it
- var items = GetItemsForBucket(bucket);
- if (items == null || items.Count == 0)
- continue;
-
- // Get the machine
- var machine = items[0].GetFieldValue(DatItem.MachineKey);
- if (machine == null)
- continue;
-
- // If the game (is/is not) a bios, we want to continue
- if (bios ^ (machine.GetBoolFieldValue(Models.Metadata.Machine.IsBiosKey) == true))
- continue;
-
- // Get the bios parent
- string? romOf = machine.GetStringFieldValue(Models.Metadata.Machine.RomOfKey);
- if (string.IsNullOrEmpty(romOf))
- continue;
-
- // If the parent doesn't have any items, we want to continue
- var parentItems = GetItemsForBucket(romOf!);
- if (parentItems == null || parentItems.Count == 0)
- continue;
-
- // If the parent exists and has items, we remove the items that are in the parent from the current game
- foreach (DatItem item in parentItems)
- {
- DatItem datItem = (DatItem)item.Clone();
- while (items.Contains(datItem))
- {
- Items.Remove(bucket, datItem);
- }
- }
- }
- }
-
- ///
- /// Use romof tags to remove bios items from children
- ///
- /// True if only child Bios sets are touched, false for non-bios sets
- ///
- /// Applies to .
- /// Assumes items are bucketed by .
- ///
- private void RemoveBiosItemsFromChildImplDB(bool bios)
- {
- // Loop through the romof tags
- List buckets = [.. ItemsDB.SortedKeys];
- foreach (string bucket in buckets)
- {
- // If the bucket has no items in it
- var items = GetItemsForBucketDB(bucket);
- if (items == null || items.Count == 0)
- continue;
-
- // Get the machine for the item
- var machine = ItemsDB.GetMachineForItem(items.First().Key);
- if (machine.Value == null)
- continue;
-
- // If the game (is/is not) a bios, we want to continue
- if (bios ^ (machine.Value.GetBoolFieldValue(Models.Metadata.Machine.IsBiosKey) == true))
- continue;
-
- // Get the bios parent
- string? romOf = machine.Value.GetStringFieldValue(Models.Metadata.Machine.RomOfKey);
- if (string.IsNullOrEmpty(romOf))
- continue;
-
- // If the parent doesn't have any items, we want to continue
- var parentItems = GetItemsForBucketDB(romOf!);
- if (parentItems == null || parentItems.Count == 0)
- continue;
-
- // If the parent exists and has items, we remove the items that are in the parent from the current game
- foreach (var item in parentItems)
- {
- var matchedItems = items.Where(i => i.Value == item.Value);
- foreach (var match in matchedItems)
- {
- ItemsDB.RemoveItem(match.Key);
- }
- }
- }
- }
-
///
/// Use cloneof tags to remove items from the children
///
@@ -1182,6 +1080,108 @@ namespace SabreTools.DatFiles
}
}
+ ///
+ /// Use romof tags to remove bios items from children
+ ///
+ /// True if only child Bios sets are touched, false for non-bios sets
+ ///
+ /// Applies to .
+ /// Assumes items are bucketed by .
+ ///
+ private void RemoveItemsFromRomOfChildImpl(bool bios)
+ {
+ // Loop through the romof tags
+ List buckets = [.. Items.Keys];
+ buckets.Sort();
+
+ foreach (string bucket in buckets)
+ {
+ // If the bucket has no items in it
+ var items = GetItemsForBucket(bucket);
+ if (items == null || items.Count == 0)
+ continue;
+
+ // Get the machine
+ var machine = items[0].GetFieldValue(DatItem.MachineKey);
+ if (machine == null)
+ continue;
+
+ // If the game (is/is not) a bios, we want to continue
+ if (bios ^ (machine.GetBoolFieldValue(Models.Metadata.Machine.IsBiosKey) == true))
+ continue;
+
+ // Get the bios parent
+ string? romOf = machine.GetStringFieldValue(Models.Metadata.Machine.RomOfKey);
+ if (string.IsNullOrEmpty(romOf))
+ continue;
+
+ // If the parent doesn't have any items, we want to continue
+ var parentItems = GetItemsForBucket(romOf!);
+ if (parentItems == null || parentItems.Count == 0)
+ continue;
+
+ // If the parent exists and has items, we remove the items that are in the parent from the current game
+ foreach (DatItem item in parentItems)
+ {
+ DatItem datItem = (DatItem)item.Clone();
+ while (items.Contains(datItem))
+ {
+ Items.Remove(bucket, datItem);
+ }
+ }
+ }
+ }
+
+ ///
+ /// Use romof tags to remove bios items from children
+ ///
+ /// True if only child Bios sets are touched, false for non-bios sets
+ ///
+ /// Applies to .
+ /// Assumes items are bucketed by .
+ ///
+ private void RemoveItemsFromRomOfChildImplDB(bool bios)
+ {
+ // Loop through the romof tags
+ List buckets = [.. ItemsDB.SortedKeys];
+ foreach (string bucket in buckets)
+ {
+ // If the bucket has no items in it
+ var items = GetItemsForBucketDB(bucket);
+ if (items == null || items.Count == 0)
+ continue;
+
+ // Get the machine for the item
+ var machine = ItemsDB.GetMachineForItem(items.First().Key);
+ if (machine.Value == null)
+ continue;
+
+ // If the game (is/is not) a bios, we want to continue
+ if (bios ^ (machine.Value.GetBoolFieldValue(Models.Metadata.Machine.IsBiosKey) == true))
+ continue;
+
+ // Get the bios parent
+ string? romOf = machine.Value.GetStringFieldValue(Models.Metadata.Machine.RomOfKey);
+ if (string.IsNullOrEmpty(romOf))
+ continue;
+
+ // If the parent doesn't have any items, we want to continue
+ var parentItems = GetItemsForBucketDB(romOf!);
+ if (parentItems == null || parentItems.Count == 0)
+ continue;
+
+ // If the parent exists and has items, we remove the items that are in the parent from the current game
+ foreach (var item in parentItems)
+ {
+ var matchedItems = items.Where(i => i.Value == item.Value);
+ foreach (var match in matchedItems)
+ {
+ ItemsDB.RemoveItem(match.Key);
+ }
+ }
+ }
+ }
+
///
/// Remove all romof and cloneof tags from all machines
///
diff --git a/SabreTools.DatTools/MergeSplit.cs b/SabreTools.DatTools/MergeSplit.cs
index a6b8902a..721cba31 100644
--- a/SabreTools.DatTools/MergeSplit.cs
+++ b/SabreTools.DatTools/MergeSplit.cs
@@ -127,8 +127,8 @@ namespace SabreTools.DatTools
datFile.AddItemsFromChildren(true, false);
// Now that we have looped through the cloneof tags, we loop through the romof tags
- datFile.RemoveBiosItemsFromChild(false);
- datFile.RemoveBiosItemsFromChild(true);
+ datFile.RemoveItemsFromRomOfChild(false);
+ datFile.RemoveItemsFromRomOfChild(true);
// Finally, remove the romof and cloneof tags so it's not picked up by the manager
datFile.RemoveMachineRelationshipTags();
@@ -172,8 +172,8 @@ namespace SabreTools.DatTools
datFile.AddItemsFromChildren(true, true);
// Now that we have looped through the cloneof tags, we loop through the romof tags
- datFile.RemoveBiosItemsFromChild(false);
- datFile.RemoveBiosItemsFromChild(true);
+ datFile.RemoveItemsFromRomOfChild(false);
+ datFile.RemoveItemsFromRomOfChild(true);
// Finally, remove the romof and cloneof tags so it's not picked up by the manager
datFile.RemoveMachineRelationshipTags();
@@ -194,8 +194,8 @@ namespace SabreTools.DatTools
datFile.AddItemsFromParent();
// Now that we have looped through the cloneof tags, we loop through the romof tags
- datFile.RemoveBiosItemsFromChild(false);
- datFile.RemoveBiosItemsFromChild(true);
+ datFile.RemoveItemsFromRomOfChild(false);
+ datFile.RemoveItemsFromRomOfChild(true);
// Finally, remove the romof and cloneof tags so it's not picked up by the manager
datFile.RemoveMachineRelationshipTags();
@@ -216,8 +216,8 @@ namespace SabreTools.DatTools
datFile.RemoveItemsFromCloneOfChild();
// Now that we have looped through the cloneof tags, we loop through the romof tags
- datFile.RemoveBiosItemsFromChild(false);
- datFile.RemoveBiosItemsFromChild(true);
+ datFile.RemoveItemsFromRomOfChild(false);
+ datFile.RemoveItemsFromRomOfChild(true);
// Finally, remove the romof and cloneof tags so it's not picked up by the manager
datFile.RemoveMachineRelationshipTags();