Check all locks for legality checking

Single->All
This commit is contained in:
Kurt 2018-10-28 20:28:56 -07:00
parent b5f128f2c4
commit 1b57acc6a7
2 changed files with 28 additions and 3 deletions

View file

@ -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;

View file

@ -24,9 +24,9 @@ namespace PKHeX.Core
public static bool FindLockSeed(uint originSeed, IEnumerable<NPCLock> lockList, bool XD, out uint origin)
{
var locks = new Stack<NPCLock>(lockList);
var pids = new Stack<SeedFrame>();
var team = new Stack<SeedFrame>();
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<NPCLock>(t.Locks);
var team = new Stack<SeedFrame>();
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<NPCLock>(1);
locks.Push(t.Locks[t.Locks.Length - 1]);
var team = new Stack<SeedFrame>();
var originSeed = pv.OriginSeed;
var cache = new FrameCache(RNG.XDRNG.Reverse(originSeed, 2), RNG.XDRNG.Prev);