mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +00:00
improve pcd<->pgt matching
Hotfix wasn't appropriate: check bytes 0 & 1 in addition to 3+, add bounds checking
This commit is contained in:
parent
f0a570d132
commit
2ab175db6e
1 changed files with 13 additions and 2 deletions
|
@ -69,8 +69,19 @@ namespace PKHeX.Core
|
|||
|
||||
public bool GiftEquals(PGT pgt)
|
||||
{
|
||||
// Skip over the PGT's "Corresponding PCD Slot"
|
||||
return Gift.Data.Skip(3).SequenceEqual(pgt.Data.Skip(3));
|
||||
// Skip over the PGT's "Corresponding PCD Slot" @ 0x02
|
||||
byte[] g = pgt.Data;
|
||||
byte[] c = Gift.Data;
|
||||
if (g.Length != c.Length || g.Length < 3)
|
||||
return false;
|
||||
for (int i = 0; i < 2; i++)
|
||||
if (g[i] != c[i])
|
||||
return false;
|
||||
for (int i = 3; i < g.Length; i++)
|
||||
if (g[i] != c[i])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override PKM convertToPKM(SaveFile SAV)
|
||||
|
|
Loading…
Add table
Reference in a new issue