mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-06 13:40:50 -05:00
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:
parent
c1fa7d3916
commit
6bd0e87ea3
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user