Remove reflection for super training checks

Offset is constant, just interpret the raw data instead of the
properties.
speed++;

Adds check for unused super training flags.
This commit is contained in:
Kurt 2017-04-15 12:22:29 -07:00
parent e8aaf71b4d
commit 5f5167cbf9
5 changed files with 31 additions and 10 deletions

View file

@ -1069,8 +1069,19 @@ namespace PKHeX.Core
}
private void verifyMedalsRegular()
{
var TrainNames = ReflectUtil.getPropertiesStartWithPrefix(pkm.GetType(), "SuperTrain").ToArray();
var TrainCount = TrainNames.Count(MissionName => ReflectUtil.GetValue(pkm, MissionName) as bool? == true);
uint data = BitConverter.ToUInt32(pkm.Data, 0x2C);
if ((data & 3) != 0) // 2 unused flags
AddLine(Severity.Invalid, V98, CheckIdentifier.Training);
int TrainCount = 0;
data >>= 2;
for (int i = 2; i < 32; i++)
{
if ((data & 1) != 0)
TrainCount++;
data >>= 1;
}
if (pkm.IsEgg && TrainCount > 0)
{ AddLine(Severity.Invalid, V89, CheckIdentifier.Training); }
else if (TrainCount > 0 && pkm.GenNumber > 6)
@ -1093,13 +1104,22 @@ namespace PKHeX.Core
}
private void verifyMedalsEvent()
{
var DistNames = ReflectUtil.getPropertiesStartWithPrefix(pkm.GetType(), "DistSuperTrain");
var DistCount = DistNames.Count(MissionName => ReflectUtil.GetValue(pkm, MissionName) as bool? == true);
if (pkm.IsEgg && DistCount > 0)
byte data = pkm.Data[0x3A];
if ((data & 0xC0) != 0) // 2 unused flags highest bits
AddLine(Severity.Invalid, V98, CheckIdentifier.Training);
int TrainCount = 0;
for (int i = 0; i < 6; i++)
{
if ((data & 1) != 0)
TrainCount++;
data >>= 1;
}
if (pkm.IsEgg && TrainCount > 0)
{ AddLine(Severity.Invalid, V89, CheckIdentifier.Training); }
else if (DistCount > 0 && pkm.GenNumber > 6)
else if (TrainCount > 0 && pkm.GenNumber > 6)
{ AddLine(Severity.Invalid, V90, CheckIdentifier.Training); }
else if (DistCount > 0)
else if (TrainCount > 0)
{ AddLine(Severity.Fishy, V94, CheckIdentifier.Training); }
}
#endregion

View file

@ -200,11 +200,11 @@ namespace PKHeX.Core
public static string V92 {get; set;} = "Can't have active Super Training complete flag for origins.";
public static string V93 {get; set;} = "Super Training complete flag mismatch.";
public static string V94 {get; set;} = "Distribution Super Training missions are not released."; // Fishy
public static string V98 {get; set;} = "Unused Super Training Flag is flagged.";
public static string V95 {get; set;} = "Can't receive Ribbon(s) as an egg.";
public static string V96 {get; set;} = "GBA Champion Ribbon";
public static string V97 {get; set;} = "Artist Ribbon";
public static string V98 {get; set;} = "National Ribbon (Purified)";
public static string V99 {get; set;} = "Sinnoh Champion Ribbon";
public static string V100 {get; set;} = "Legend Ribbon";
public static string V104 {get; set;} = "Record Ribbon";

View file

@ -151,6 +151,7 @@ V91 = Can't have active Super Training unlocked flag for origins.
V92 = Can't have active Super Training complete flag for origins.
V93 = Super Training complete flag mismatch.
V94 = Distribution Super Training missions are not released.
V98 = Unused Super Training Flag is flagged.
V95 = Can't receive Ribbon(s) as an egg.
V96 = GBA Champion Ribbon
V97 = Artist Ribbon

View file

@ -151,10 +151,10 @@ V91 = 만난 게임에서 대단한 특훈 잠금 해제 플래그를 켤 수
V92 = 만난 게임에서 대단한 특훈 완료 플래그를 켤 수 없습니다.
V93 = 대단한 특훈 완료 플래그가 일치하지 않습니다.
V94 = 배분한 대단한 특훈 미션이 배포되지 않은 미션입니다.
V98 = Unused Super Training Flag is flagged.
V95 = 알은 리본을 얻을 수 없습니다.
V96 = GBA챔피언리본
V97 = 브로마이드리본
V98 = 내셔널리본 (Purified)
V99 = 신오챔피언리본
V100 = 레전드리본
V104 = 레코드리본

View file

@ -151,10 +151,10 @@ V91 = 当前来源版本不能有超级训练解锁的标记。
V92 = 当前来源版本不能有超级训练完成的标记。
V93 = 超级训练完成标记不匹配。
V94 = 配信超级训练任务未发布。
V98 = Unused Super Training Flag is flagged.
V95 = 蛋不能接受奖章。
V96 = GBA冠军奖章
V97 = 肖像奖章
V98 = 国家奖章 (净化)
V99 = 神奥冠军奖章
V100 = 传说奖章
V104 = 记录奖章