From 7160d34b07edf83eb1fef83dad908468c38f898c Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 13 Jan 2025 22:32:21 -0500 Subject: [PATCH] Creat new machines for ORPG --- SabreTools.DatFiles/DatFile.Filtering.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/SabreTools.DatFiles/DatFile.Filtering.cs b/SabreTools.DatFiles/DatFile.Filtering.cs index 39af8edc..d3ba71e5 100644 --- a/SabreTools.DatFiles/DatFile.Filtering.cs +++ b/SabreTools.DatFiles/DatFile.Filtering.cs @@ -442,8 +442,11 @@ namespace SabreTools.DatFiles if (machine == null) return; - // TODO: Clone current machine so that all data can be retained - // TODO: Assign cloned machine to the item with the new name + // Clone current machine to avoid conflict + machine = (Machine)machine.Clone(); + + // Reassign the item to the new machine + datItem.SetFieldValue(DatItem.MachineKey, machine); // Remove extensions from Rom items if (datItem is Rom) @@ -500,7 +503,6 @@ namespace SabreTools.DatFiles /// /// DatItem to run logic on /// Applies to - /// TODO: Investigate if this causes cascading issues in updating the machine private void SetOneRomPerGameImplDB(KeyValuePair datItem) { // If the item name is null @@ -513,8 +515,14 @@ namespace SabreTools.DatFiles if (machine.Value == null) return; - // TODO: Clone current machine so that all data can be retained - // TODO: Assign cloned machine to the item with the new name + // Clone current machine to avoid conflict + long newMachineIndex = AddMachineDB((Machine)machine.Value.Clone()); + machine = new KeyValuePair(newMachineIndex, ItemsDB.GetMachine(newMachineIndex)); + if (machine.Value == null) + return; + + // Reassign the item to the new machine + ItemsDB._itemToMachineMapping[machine.Key] = newMachineIndex; // Remove extensions from Rom items if (datItem.Value is Rom)