mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-01 02:06:46 -05:00
Replace party/boxdata get with more performant use
Read directly from the save file. Batch Editor no longer updates dex, HT details, or updates acquired counts when placing back in the SAV.
This commit is contained in:
@@ -41,16 +41,15 @@ public static void AddFromLocalFile(string file, ConcurrentBag<SlotCache> db, IT
|
||||
|
||||
private static void AddBoxData(SaveFile sav, ConcurrentBag<SlotCache> 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<SlotCache> db)
|
||||
|
||||
private static void AddPartyData(SaveFile sav, ConcurrentBag<SlotCache> 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<SlotCache> db, ITra
|
||||
|
||||
public static void AddBoxData(SaveFile sav, ICollection<SlotCache> 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<SlotCache> db)
|
||||
|
||||
public static void AddPartyData(SaveFile sav, ICollection<SlotCache> 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;
|
||||
|
||||
|
||||
@@ -174,18 +174,21 @@ private void RunBatchEditFolder(IReadOnlyCollection<StringInstructionSet> sets,
|
||||
|
||||
private void RunBatchEditSaveFile(IReadOnlyCollection<StringInstructionSet> sets, bool boxes = false, bool party = false)
|
||||
{
|
||||
var data = new List<SlotCache>();
|
||||
if (party)
|
||||
{
|
||||
var data = new List<SlotCache>(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<SlotCache>(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<SlotCache> d)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user