From cf23bb9c2dd4bb3e5702416362dce7a6c37842f1 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 13 Mar 2024 11:11:59 -0400 Subject: [PATCH] Add clear marked items method to IDDB --- SabreTools.DatFiles/ItemDictionaryDB.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/SabreTools.DatFiles/ItemDictionaryDB.cs b/SabreTools.DatFiles/ItemDictionaryDB.cs index 3e20eb46..5ea8a075 100644 --- a/SabreTools.DatFiles/ItemDictionaryDB.cs +++ b/SabreTools.DatFiles/ItemDictionaryDB.cs @@ -116,6 +116,22 @@ namespace SabreTools.DatFiles return _machineIndex - 1; } + /// + /// Remove all items marked for removal + /// + public void ClearMarked() + { + var itemIndices = _items.Keys; + foreach (long itemIndex in itemIndices) + { + var datItem = _items[itemIndex]; + if (datItem == null || datItem.GetBoolFieldValue(DatItem.RemoveKey) != true) + continue; + + RemoveItem(itemIndex); + } + } + /// /// Get an item based on the index ///