Fix copyto discarding elements

don't continue; instead seek forward
#2235 part 1, need surgery for part 2 (starter/locked prevents writing
data to the slot, but the slot can still be swapped)
This commit is contained in:
Kurt 2019-01-08 16:45:16 -08:00
parent c1fa7d3916
commit 6bd0e87ea3

View File

@ -837,16 +837,26 @@ public static string GetLocationString(this PKM pk, bool eggmet)
public static int CopyTo(this IEnumerable<PKM> list, IList<PKM> dest, Func<int, int, bool> skip, int start = 0)
{
int ctr = start;
if (ctr >= dest.Count)
return 0;
int skipped = 0;
foreach (var z in list)
{
// seek forward to next open slot
while (true)
{
var exist = dest[ctr];
if (exist == null || !skip(exist.Box, exist.Slot))
break;
skipped++;
ctr++;
}
if (dest.Count <= ctr)
break;
var exist = dest[ctr];
if (exist != null && skip(exist.Box, exist.Slot))
continue;
dest[ctr++] = z;
}
return ctr - start;
return ctr - start - skipped;
}
/// <summary>