Fix pt/hgss egg location handling 4->5

Closes #1766
pt/hgss egg location data is lost on transfer, retaining faraway place
only.
2c8e2176e9 fix was incorrect
This commit is contained in:
Kurt 2018-01-21 11:57:34 -08:00
parent e616b56bfa
commit b229a947f2
3 changed files with 29 additions and 10 deletions

View file

@ -475,17 +475,34 @@ namespace PKHeX.Core
if (pkm.Egg_Location != 0)
return false;
}
else
switch (pkm.GenNumber)
else if (pkm.Gen4)
{
case 4:
if (pkm.Egg_Location != 2002) // Link Trade
if (pkm.Egg_Location != 2002) // Link Trade
{
// check Pt/HGSS data
if (pkm.Format <= 4)
return false; // must match
if (e.EggLocation >= 3000 || e.EggLocation <= 2010) // non-Pt/HGSS egg gift
return false;
break;
default:
if (pkm.Egg_Location != 30002) // Link Trade
// transferring 4->5 clears pt/hgss location value and keeps Faraway Place
if (pkm.Egg_Location != 3002) // Faraway Place
return false;
break;
}
}
else
{
if (pkm.Egg_Location != 30002) // Link Trade
return false;
}
}
else if (e.EggLocation != 0 && pkm.Gen4)
{
// Check the inverse scenario for 4->5 eggs
if (e.EggLocation < 3000 && e.EggLocation > 2010) // Pt/HGSS egg gift
{
if (pkm.Format > 4)
return false; // locations match when it shouldn't
}
}

View file

@ -438,7 +438,9 @@ namespace PKHeX.Core
pk5.Met_Location = pk5.Gen4 && pk5.FatefulEncounter && Legal.CrownBeasts.Contains(pk5.Species)
? (pk5.Species == 251 ? Legal.Transfer4_CelebiUnused : Legal.Transfer4_CrownUnused) // Celebi : Beast
: Legal.Transfer4; // Pokétransfer (not Crown)
pk5.Egg_Location = Egg_Location;
// Egg Location is not modified; when clearing Pt/HGSS egg data, the location will revert to Faraway Place
// pk5.Egg_Location = Egg_Location;
// Delete HGSS Data
BitConverter.GetBytes((ushort)0).CopyTo(pk5.Data, 0x86);

View file

@ -8,7 +8,7 @@ namespace PKHeX.Core
{
public static readonly byte[] ExtraBytes =
{
0x42, 0x43, 0x5E, 0x63, 0x64, 0x65, 0x66, 0x67, 0x87
0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x5E, 0x63, 0x64, 0x65, 0x66, 0x67, 0x87
};
public override int SIZE_PARTY => PKX.SIZE_5PARTY;
public override int SIZE_STORED => PKX.SIZE_5STORED;