Fix wurmple evo gen3/4

yeah it was never the lowest 16 bits as every-internet-source claims.

1D9C9130 silcoon => 3716[8] = cascoon (nope)
#1330 was correct!
This commit is contained in:
Kurt 2017-07-17 15:58:09 -07:00
parent 4207df8d74
commit 2d18440445
4 changed files with 21 additions and 29 deletions

View file

@ -98,7 +98,7 @@ namespace PKHeX.Core
}
private void VerifyECPIDWurmple()
{
uint evoVal = PKX.GetWurmpleEvoVal(pkm.GenNumber, pkm.EncryptionConstant);
uint evoVal = PKX.GetWurmpleEvoVal(pkm.EncryptionConstant);
if (pkm.Species == 265)
AddLine(Severity.Valid, string.Format(V212, evoVal == 0 ? SpeciesStrings[267] : SpeciesStrings[269]), CheckIdentifier.EC);

View file

@ -1328,7 +1328,7 @@ namespace PKHeX.Core
}
private static bool IsWurmpleEvoValid(PKM pkm)
{
uint evoVal = PKX.GetWurmpleEvoVal(pkm.GenNumber, pkm.EncryptionConstant);
uint evoVal = PKX.GetWurmpleEvoVal(pkm.EncryptionConstant);
int wIndex = Array.IndexOf(WurmpleEvolutions, pkm.Species) / 2;
return evoVal == wIndex;
}

View file

@ -458,23 +458,30 @@ namespace PKHeX.Core
}
/// <summary>
/// Gets the Wurmple Evolution Value for a given <see cref="PKM.GenNumber"/> and <see cref="PKM.EncryptionConstant"/>
/// Gets the Wurmple Evolution Value for a given <see cref="PKM.EncryptionConstant"/>
/// </summary>
/// <param name="gen">Origin Generation</param>
/// <param name="EC">Encryption Constant</param>
/// <returns>Wurmple Evolution Value</returns>
public static uint GetWurmpleEvoVal(int gen, uint EC)
public static uint GetWurmpleEvoVal(uint EC)
{
uint evoVal;
switch (gen)
{
case 4:
case 3: evoVal = EC & 0xFFFF; break;
default: evoVal = EC >> 16; break;
}
var evoVal = EC >> 16;
return evoVal % 10 / 5;
}
/// <summary>
/// Gets the Wurmple <see cref="PKM.EncryptionConstant"/> for a given Evolution Value
/// </summary>
/// <param name="evoVal">Wurmple Evolution Value</param>
/// <remarks>0 = Silcoon, 1 = Cascoon</remarks>
/// <returns>Encryption Constan</returns>
public static uint GetWurmpleEC(int evoVal)
{
uint EC;
while (true)
if (evoVal == GetWurmpleEvoVal(EC = Util.Rand32()))
return EC;
}
/// <summary>
/// Gets a random PID according to specifications.
/// </summary>

View file

@ -1055,23 +1055,8 @@ namespace PKHeX.WinForms.Controls
return;
int wIndex = Array.IndexOf(Legal.WurmpleEvolutions, WinFormsUtil.GetIndex(CB_Species));
if (wIndex < 0)
{
TB_EC.Text = Util.Rand32().ToString("X8");
}
else
{
int gen = pkm.GenNumber;
uint EC;
bool valid;
do
{
EC = Util.Rand32();
uint evoVal = PKX.GetWurmpleEvoVal(gen, EC);
valid = evoVal == wIndex / 2;
} while (!valid);
TB_EC.Text = EC.ToString("X8");
}
uint EC = wIndex < 0 ? Util.Rand32() : PKX.GetWurmpleEC(wIndex/2);
TB_EC.Text = EC.ToString("X8");
UpdateLegality();
}
private void UpdateHackedStats(object sender, EventArgs e)