Fix gen1/2 gender detect

gender: take top 4 bits of gr:
31 = 0x1F = 1
63 = 0x3F = 3
127 = 0x7F = 7
191 = 0xBF = 11

See the pattern? If we change the compares from >= to >, we -1. All
numbers match except for the 25/75 ratio pkm... which unveils the
problem.

Simplify the calc for these using the logic above, which fixes the error
and makes the code easier to read!

Thanks SystemError for assisting :)
This commit is contained in:
Kurt
2018-06-27 18:31:24 -07:00
parent ed099916b5
commit dc3cdd4491
2 changed files with 2 additions and 28 deletions

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace PKHeX.Core
@@ -298,19 +297,7 @@ public override int Gender
return 1;
if (gv == 0)
return 0;
switch (gv)
{
case 31:
return IV_ATK >= 2 ? 0 : 1;
case 63:
return IV_ATK >= 5 ? 0 : 1;
case 127:
return IV_ATK >= 8 ? 0 : 1;
case 191:
return IV_ATK >= 12 ? 0 : 1;
}
Debug.WriteLine($"Unknown Gender value: {gv}");
return 0;
return IV_ATK > gv >> 4 ? 0 : 1;
}
set { }
}

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace PKHeX.Core
@@ -285,19 +284,7 @@ public override int Gender
return 1;
if (gv == 0)
return 0;
switch (gv)
{
case 31:
return IV_ATK >= 2 ? 0 : 1;
case 63:
return IV_ATK >= 5 ? 0 : 1;
case 127:
return IV_ATK >= 8 ? 0 : 1;
case 191:
return IV_ATK >= 12 ? 0 : 1;
}
Debug.WriteLine($"Unknown Gender value: {gv}");
return 0;
return IV_ATK > gv >> 4 ? 0 : 1;
}
set { }
}