Minor clean

This commit is contained in:
Kurt 2021-02-14 10:23:53 -08:00
parent 1af27516e6
commit 884cd70d43
2 changed files with 9 additions and 8 deletions

View file

@ -15,19 +15,22 @@ namespace PKHeX.Core
/// The iterator lazily finds matching encounters, then verifies secondary checks to weed out any nonexact matches.
/// </remarks>
/// <param name="pkm">Source data to find a match for</param>
/// <param name="info">Object to store matched encounter info</param>
/// <returns>
/// Information containing the matched encounter and any parsed checks.
/// If no clean match is found, the last checked match is returned.
/// If no match is found, an invalid encounter object is returned.
/// </returns>
public static LegalInfo FindVerifiedEncounter(PKM pkm)
public static void FindVerifiedEncounter(PKM pkm, LegalInfo info)
{
var info = new LegalInfo(pkm);
var encounters = EncounterGenerator.GetEncounters(pkm, info);
using var encounter = new PeekEnumerator<IEncounterable>(encounters);
if (!encounter.PeekIsNext())
return VerifyWithoutEncounter(pkm, info);
{
VerifyWithoutEncounter(pkm, info);
return;
}
var EncounterValidator = EncounterVerifier.GetEncounterVerifierMethod(pkm);
while (encounter.MoveNext())
@ -63,8 +66,6 @@ namespace PKHeX.Core
info.Parse.Add(new CheckResult(ParseSettings.RNGFrameNotFound, LEncConditionBadRNGFrame, CheckIdentifier.PID)); // todo for further confirmation
if (!info.PIDIVMatches) // if false, all valid PIDIV matches have already been consumed
info.Parse.Add(new CheckResult(Severity.Invalid, LPIDTypeMismatch, CheckIdentifier.PID));
return info;
}
/// <summary>

View file

@ -111,11 +111,12 @@ namespace PKHeX.Core
if (pkm.Format <= 2) // prior to storing GameVersion
pkm.TradebackStatus = GBRestrictions.GetTradebackStatusInitial(pkm);
Info = new LegalInfo(pkm);
#if SUPPRESS
try
#endif
{
Info = EncounterFinder.FindVerifiedEncounter(pkm);
EncounterFinder.FindVerifiedEncounter(pkm, Info);
if (!pkm.IsOriginValid)
AddLine(Severity.Invalid, LEncConditionBadSpecies, CheckIdentifier.GameOrigin);
GetParseMethod()();
@ -141,7 +142,6 @@ namespace PKHeX.Core
#pragma warning restore CA1031 // Do not catch general exception types
{
System.Diagnostics.Debug.WriteLine(e.Message);
Info = new LegalInfo(pkm);
Valid = false;
AddLine(Severity.Invalid, L_AError, CheckIdentifier.Misc);
}
@ -396,7 +396,7 @@ namespace PKHeX.Core
if (rl != lines.Count) // move info added, break for next section
lines.Add(br[1]);
var outputLines = Parse.Where(chk => chk?.Valid == true && chk.Comment != L_AValid).OrderBy(chk => chk.Judgement); // Fishy sorted to top
var outputLines = Parse.Where(chk => chk.Valid && chk.Comment != L_AValid).OrderBy(chk => chk.Judgement); // Fishy sorted to top
lines.AddRange(outputLines.Select(chk => chk.Format(L_F0_1)));
lines.AddRange(br);