From 34ea56c2a70cb325a9fb07ff43aec7a75b9154cd Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 14 Apr 2019 09:06:43 -0700 Subject: [PATCH] Minor updates Fresh day, fresh tests of the new code :) Fix assert conditions Add extra considerations Detected clones should be skipped for PID/EC/TID checks -- should probably detect this a different way rather than checking a computed string (bool array of flags for the clone check results) --- PKHeX.Core/Legality/BulkAnalysis.cs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/PKHeX.Core/Legality/BulkAnalysis.cs b/PKHeX.Core/Legality/BulkAnalysis.cs index 0516d0822..0725895e4 100644 --- a/PKHeX.Core/Legality/BulkAnalysis.cs +++ b/PKHeX.Core/Legality/BulkAnalysis.cs @@ -107,7 +107,7 @@ private void CheckECReuse() { var cp = AllData[i]; var ca = AllAnalysis[i]; - Debug.Assert(cp.Format < 6); + Debug.Assert(cp.Format >= 6); var id = cp.EncryptionConstant; if (!dict.TryGetValue(id, out var pa)) @@ -146,7 +146,7 @@ private void CheckIDReuse() var cp = AllData[i]; var ca = AllAnalysis[i]; var id = cp.TID + (cp.SID << 16); - Debug.Assert(cp.TID < ushort.MaxValue); + Debug.Assert(cp.TID <= ushort.MaxValue); if (!dict.TryGetValue(id, out var pa)) { @@ -172,6 +172,11 @@ private void CheckIDReuse() private void VerifyECShare(LegalityAnalysis pa, LegalityAnalysis ca) { + var i1 = SearchUtil.HashByDetails(pa.pkm); + var i2 = SearchUtil.HashByDetails(ca.pkm); + if (i1 == i2) // is clone; already caught by another method + return; + const CheckIdentifier ident = PID; int gen = pa.Info.Generation; if (ca.Info.Generation != gen) @@ -202,6 +207,11 @@ private void VerifyECShare(LegalityAnalysis pa, LegalityAnalysis ca) private void VerifyPIDShare(LegalityAnalysis pa, LegalityAnalysis ca) { + var i1 = SearchUtil.HashByDetails(pa.pkm); + var i2 = SearchUtil.HashByDetails(ca.pkm); + if (i1 == i2) // is clone; already caught by another method + return; + const CheckIdentifier ident = PID; int gen = pa.Info.Generation; if (ca.Info.Generation != gen) @@ -232,6 +242,16 @@ private void VerifyPIDShare(LegalityAnalysis pa, LegalityAnalysis ca) private bool VerifyIDReuse(PKM pp, LegalityAnalysis pa, PKM cp, LegalityAnalysis ca) { + var i1 = SearchUtil.HashByDetails(pa.pkm); + var i2 = SearchUtil.HashByDetails(ca.pkm); + if (i1 == i2) // is clone; already caught by another method + return true; + + if (pa.EncounterMatch is MysteryGift g1 && !g1.EggEncounter) + return false; + if (ca.EncounterMatch is MysteryGift g2 && !g2.EggEncounter) + return false; + const CheckIdentifier ident = CheckIdentifier.Trainer; // 32bit ID-SID should only occur for one generation