Fix Import Count on Load Boxes (#2308)

Calculation was wrong if non-overwrite is selected. Also fixed OCD-triggering extra space in output message.
This commit is contained in:
ReignOfComputer 2019-05-16 00:11:48 +08:00 committed by Kurt
parent 7421b137eb
commit 7625ab66b4
7 changed files with 13 additions and 9 deletions

View file

@ -121,6 +121,7 @@ namespace PKHeX.Core
int startCount = boxStart * SAV.BoxSlotCount;
int maxCount = SAV.SlotCount;
int index = startCount;
int nonOverwriteImport = 0;
foreach (var pk in compat)
{
@ -128,20 +129,23 @@ namespace PKHeX.Core
{
while (SAV.IsSlotOverwriteProtected(index))
++index;
SAV.SetBoxSlotAtIndex(pk, index, noSetb);
}
else
{
index = SAV.NextOpenBoxSlot(index-1);
if (index < 0) // Boxes full!
break;
}
SAV.SetBoxSlotAtIndex(pk, index, noSetb);
nonOverwriteImport++;
}
if (++index == maxCount) // Boxes full!
break;
}
return index - startCount; // actual imported count
return (overwrite) ? index - startCount : nonOverwriteImport; // actual imported count
}
public static IEnumerable<PKM> GetCompatible(this SaveFile SAV, IEnumerable<PKM> pks)