From 1b57acc6a725db1e0943f237cb90e5fdcf834c71 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 28 Oct 2018 20:28:56 -0700 Subject: [PATCH] Check all locks for legality checking Single->All --- .../Generator/EncounterGenerator.cs | 2 +- PKHeX.Core/Legality/RNG/Locks/LockFinder.cs | 29 +++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs index b36881411..017707849 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs @@ -69,7 +69,7 @@ namespace PKHeX.Core info.PIDIV = seeds ?? info.PIDIV; } else if (ParseSettings.FlagCXDShadowFirstLockMismatch - && z is EncounterStaticShadow s && !LockFinder.IsFirstShadowLockValid(s, info.PIDIV)) + && z is EncounterStaticShadow s && !LockFinder.IsAllShadowLockValid(s, info.PIDIV)) { deferred.Add(s); continue; diff --git a/PKHeX.Core/Legality/RNG/Locks/LockFinder.cs b/PKHeX.Core/Legality/RNG/Locks/LockFinder.cs index aa4028728..f4e2a76bd 100644 --- a/PKHeX.Core/Legality/RNG/Locks/LockFinder.cs +++ b/PKHeX.Core/Legality/RNG/Locks/LockFinder.cs @@ -24,9 +24,9 @@ namespace PKHeX.Core public static bool FindLockSeed(uint originSeed, IEnumerable lockList, bool XD, out uint origin) { var locks = new Stack(lockList); - var pids = new Stack(); + var team = new Stack(); var cache = new FrameCache(RNG.XDRNG.Reverse(originSeed, 2), RNG.XDRNG.Prev); - var result = FindLockSeed(cache, 0, locks, null, pids, XD, out var originFrame); + var result = FindLockSeed(cache, 0, locks, null, team, XD, out var originFrame); origin = cache.GetSeed(originFrame); return result; } @@ -117,6 +117,30 @@ namespace PKHeX.Core return IsFirstShadowLockValid(pv, s.Locks, s.Version == GameVersion.XD); } + public static bool IsAllShadowLockValid(EncounterStaticShadow s, PIDIV pv) + { + return IsAllShadowLockValid(pv, s.Locks, s.Version == GameVersion.XD); + } + + public static bool IsAllShadowLockValid(PIDIV pv, TeamLock[] teams, bool XD) + { + if (teams.Length == 0) + return true; + + foreach (var t in teams) + { + var locks = new Stack(t.Locks); + + var team = new Stack(); + var originSeed = pv.OriginSeed; + var cache = new FrameCache(RNG.XDRNG.Reverse(originSeed, 2), RNG.XDRNG.Prev); + var result = FindLockSeed(cache, 0, locks, null, team, XD, out var _); + if (result) + return true; + } + return false; + } + public static bool IsFirstShadowLockValid(PIDIV pv, TeamLock[] teams, bool XD) { if (teams.Length == 0) @@ -126,6 +150,7 @@ namespace PKHeX.Core { var locks = new Stack(1); locks.Push(t.Locks[t.Locks.Length - 1]); + var team = new Stack(); var originSeed = pv.OriginSeed; var cache = new FrameCache(RNG.XDRNG.Reverse(originSeed, 2), RNG.XDRNG.Prev);