diff --git a/PKHeX.Core/Editing/Saves/Slots/Info/SlotInfoLoader.cs b/PKHeX.Core/Editing/Saves/Slots/Info/SlotInfoLoader.cs index a40374e60..0dad51832 100644 --- a/PKHeX.Core/Editing/Saves/Slots/Info/SlotInfoLoader.cs +++ b/PKHeX.Core/Editing/Saves/Slots/Info/SlotInfoLoader.cs @@ -41,16 +41,15 @@ public static void AddFromLocalFile(string file, ConcurrentBag db, IT private static void AddBoxData(SaveFile sav, ConcurrentBag db) { - var bd = sav.BoxData; var bc = sav.BoxCount; var sc = sav.BoxSlotCount; - int ctr = 0; for (int box = 0; box < bc; box++) { - for (int slot = 0; slot < sc; slot++, ctr++) + for (int slot = 0; slot < sc; slot++) { var ident = new SlotInfoBox(box, slot); - var result = new SlotCache(ident, bd[ctr], sav); + var pk = sav.GetBoxSlotAtIndex(box, slot); + var result = new SlotCache(ident, pk, sav); db.Add(result); } } @@ -58,10 +57,10 @@ private static void AddBoxData(SaveFile sav, ConcurrentBag db) private static void AddPartyData(SaveFile sav, ConcurrentBag db) { - var pd = sav.PartyData; - for (var index = 0; index < pd.Count; index++) + var count = sav.PartyCount; + for (var index = 0; index < count; index++) { - var pk = pd[index]; + var pk = sav.GetPartySlotAtIndex(index); if (pk.Species == 0) continue; @@ -116,16 +115,15 @@ public static void AddFromLocalFile(string file, ICollection db, ITra public static void AddBoxData(SaveFile sav, ICollection db) { - var bd = sav.BoxData; var bc = sav.BoxCount; var sc = sav.BoxSlotCount; - int ctr = 0; for (int box = 0; box < bc; box++) { - for (int slot = 0; slot < sc; slot++, ctr++) + for (int slot = 0; slot < sc; slot++) { var ident = new SlotInfoBox(box, slot); - var result = new SlotCache(ident, bd[ctr], sav); + var pk = sav.GetBoxSlotAtIndex(box, slot); + var result = new SlotCache(ident, pk, sav); db.Add(result); } } @@ -133,10 +131,10 @@ public static void AddBoxData(SaveFile sav, ICollection db) public static void AddPartyData(SaveFile sav, ICollection db) { - var pd = sav.PartyData; - for (var index = 0; index < pd.Count; index++) + var count = sav.PartyCount; + for (var index = 0; index < count; index++) { - var pk = pd[index]; + var pk = sav.GetPartySlotAtIndex(index); if (pk.Species == 0) continue; diff --git a/PKHeX.WinForms/Subforms/PKM Editors/BatchEditor.cs b/PKHeX.WinForms/Subforms/PKM Editors/BatchEditor.cs index 0db4d75ab..814db3bd8 100644 --- a/PKHeX.WinForms/Subforms/PKM Editors/BatchEditor.cs +++ b/PKHeX.WinForms/Subforms/PKM Editors/BatchEditor.cs @@ -174,18 +174,21 @@ private void RunBatchEditFolder(IReadOnlyCollection sets, private void RunBatchEditSaveFile(IReadOnlyCollection sets, bool boxes = false, bool party = false) { - var data = new List(); if (party) { + var data = new List(SAV.PartyCount); SlotInfoLoader.AddPartyData(SAV, data); process(data); - SAV.PartyData = data.ConvertAll(z => z.Entity); + foreach (var slot in data) + slot.Source.WriteTo(SAV, slot.Entity, PKMImportSetting.Skip); } if (boxes) { + var data = new List(SAV.SlotCount); SlotInfoLoader.AddBoxData(SAV, data); process(data); - SAV.BoxData = data.ConvertAll(z => z.Entity); + foreach (var slot in data) + slot.Source.WriteTo(SAV, slot.Entity, PKMImportSetting.Skip); } void process(IList d) {