Skip to content

Commit

Permalink
Fix pokewalker pid check for female-only
Browse files Browse the repository at this point in the history
pidGender check failed as 0xFE (female only) returned male if pid ended
in 0xFE or 0xFF
jump out early if the pkm is fixed gender rather than genderless only

https://projectpokemon.org/home/forums/topic/48956-pokewalker-happiny-pid-mismatch/
Thanks Taargüs Taargüs!
  • Loading branch information
kwsch committed Jan 2, 2019
1 parent 2b5272a commit 552e7a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions PKHeX.Core/Legality/RNG/PIDGenerator.cs
Expand Up @@ -230,18 +230,18 @@ public static uint GetPokeWalkerPID(int TID, int SID, uint nature, int gender, i
// Ensure nature is set to required nature without affecting shininess
pid += nature - (pid % 25);

if (gr >= 0xFE || gr == 0) // non-dual gender
return pid;

// Ensure Gender is set to required gender without affecting other properties
// If Gender is modified, modify the ability if appropriate
int currentGender = gender;
if (currentGender == 2)
return pid;

// either m/f
var pidGender = (pid & 0xFF) < gr ? 1 : 0;
if (currentGender == pidGender)
if (gender == pidGender)
return pid;

if (currentGender == 0) // Male
if (gender == 0) // Male
{
pid += (uint)((((gr - (pid & 0xFF)) / 25) + 1) * 25);
if ((nature & 1) != (pid & 1))
Expand Down
Binary file not shown.

0 comments on commit 552e7a1

Please sign in to comment.