PKHeX/PKHeX.Core/Legality/BulkAnalysis.cs

379 lines
13 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using PKHeX.Core.Searching;
using static PKHeX.Core.CheckIdentifier;
namespace PKHeX.Core
{
2021-02-19 18:52:26 +00:00
/// <summary>
/// Analyzes content within a <see cref="SaveFile"/> for overall <see cref="PKM"/> legality analysis.
/// </summary>
public sealed class BulkAnalysis
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
public readonly IReadOnlyList<SlotCache> AllData;
public readonly IReadOnlyList<LegalityAnalysis> AllAnalysis;
public readonly ITrainerInfo Trainer;
2020-12-22 01:17:56 +00:00
public readonly List<CheckResult> Parse = new();
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
public readonly Dictionary<ulong, SlotCache> Trackers = new();
public readonly bool Valid;
private readonly bool[] CloneFlags;
public BulkAnalysis(SaveFile sav)
{
Trainer = sav;
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var list = new List<SlotCache>(sav.BoxSlotCount + (sav.HasParty ? 6 : 0) + 5);
SlotInfoLoader.AddFromSaveFile(sav, list);
AllData = list;
AllAnalysis = GetIndividualAnalysis(AllData);
CloneFlags = new bool[AllData.Count];
Valid = ScanAll();
}
private bool ScanAll()
{
CheckClones();
if (Trainer.Generation <= 2)
return Parse.All(z => z.Valid);
CheckIDReuse();
CheckPIDReuse();
if (Trainer.Generation >= 6)
CheckECReuse();
if (Trainer.Generation >= 8)
CheckHOMETrackerReuse();
CheckDuplicateOwnedGifts();
return Parse.All(z => z.Valid);
}
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
private static string GetSummary(SlotCache entry) => $"[{entry.Identify()}] {entry.Entity.FileName}";
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
private void AddLine(SlotCache first, SlotCache second, string msg, CheckIdentifier i, Severity s = Severity.Invalid)
{
var c = $"{msg}{Environment.NewLine}{GetSummary(first)}{Environment.NewLine}{GetSummary(second)}";
var chk = new CheckResult(s, c, i);
Parse.Add(chk);
}
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
private void AddLine(SlotCache first, string msg, CheckIdentifier i, Severity s = Severity.Invalid)
{
var c = $"{msg}{Environment.NewLine}{GetSummary(first)}";
var chk = new CheckResult(s, c, i);
Parse.Add(chk);
}
private void CheckClones()
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var dict = new Dictionary<string, SlotCache>();
for (int i = 0; i < AllData.Count; i++)
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var cs = AllData[i];
var ca = AllAnalysis[i];
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
Debug.Assert(cs.Entity.Format == Trainer.Generation);
2020-02-13 00:37:59 +00:00
// Check the upload tracker to see if there's any duplication.
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
if (cs.Entity is IHomeTrack home)
2020-02-13 00:37:59 +00:00
{
2020-02-13 02:52:48 +00:00
if (home.Tracker != 0)
{
2020-02-13 02:52:48 +00:00
var tracker = home.Tracker;
if (Trackers.TryGetValue(tracker, out var clone))
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
AddLine(cs, clone!, "Clone detected (Duplicate Tracker).", Encounter);
else
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
Trackers.Add(tracker, cs);
}
2020-05-31 19:12:48 +00:00
else if (ca.Info.Generation < 8)
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
AddLine(cs, "Missing tracker.", Encounter);
}
2020-02-13 00:37:59 +00:00
}
// Hash Details like EC/IV to see if there's any duplication.
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var identity = SearchUtil.HashByDetails(cs.Entity);
if (!dict.TryGetValue(identity, out var ps))
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
dict.Add(identity, cs);
continue;
}
CloneFlags[i] = true;
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
AddLine(ps!, cs, "Clone detected (Details).", Encounter);
}
}
private void CheckDuplicateOwnedGifts()
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var combined = new CombinedReference[AllData.Count];
for (int i = 0; i < combined.Length; i++)
combined[i] = new CombinedReference(AllData[i], AllAnalysis[i]);
var dupes = combined.Where(z =>
z.Analysis.Info.Generation >= 3
&& z.Analysis.EncounterMatch is MysteryGift {EggEncounter: true} && !z.Slot.Entity.WasTradedEgg)
.GroupBy(z => ((MysteryGift)z.Analysis.EncounterMatch).CardTitle);
foreach (var dupe in dupes)
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var tidGroup = dupe.GroupBy(z => z.Slot.Entity.TID | (z.Slot.Entity.SID << 16))
.Select(z => z.ToList())
.Where(z => z.Count >= 2).ToList();
if (tidGroup.Count == 0)
continue;
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var first = tidGroup[0][0].Slot;
var second = tidGroup[0][1].Slot;
AddLine(first, second, $"Receipt of the same egg mystery gifts detected: {dupe.Key}", Encounter);
}
}
private void CheckECReuse()
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var dict = new Dictionary<uint, CombinedReference>();
for (int i = 0; i < AllData.Count; i++)
{
if (CloneFlags[i])
continue; // already flagged
var cp = AllData[i];
var ca = AllAnalysis[i];
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
Debug.Assert(cp.Entity.Format >= 6);
var id = cp.Entity.EncryptionConstant;
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var cr = new CombinedReference(cp, ca);
if (!dict.TryGetValue(id, out var pa) || pa is null)
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
dict.Add(id, cr);
continue;
}
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
VerifyECShare(pa, cr);
}
}
private void CheckHOMETrackerReuse()
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var dict = new Dictionary<ulong, SlotCache>();
for (int i = 0; i < AllData.Count; i++)
{
if (CloneFlags[i])
continue; // already flagged
var cp = AllData[i];
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
Debug.Assert(cp.Entity.Format >= 8);
Debug.Assert(cp.Entity is IHomeTrack);
var id = ((IHomeTrack)cp.Entity).Tracker;
if (id == 0)
continue;
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
if (!dict.TryGetValue(id, out var ps) || ps is null)
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
dict.Add(id, cp);
continue;
}
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
AddLine(ps, cp, "HOME Tracker sharing detected.", Misc);
}
}
private void CheckPIDReuse()
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var dict = new Dictionary<uint, CombinedReference>();
for (int i = 0; i < AllData.Count; i++)
{
if (CloneFlags[i])
continue; // already flagged
var cp = AllData[i];
var ca = AllAnalysis[i];
bool g345 = ca.Info.Generation is 3 or 4 or 5;
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var id = g345 ? cp.Entity.EncryptionConstant : cp.Entity.PID;
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var cr = new CombinedReference(cp, ca);
if (!dict.TryGetValue(id, out var pr) || pr is null)
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
dict.Add(id, cr);
continue;
}
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
VerifyPIDShare(pr, cr);
}
}
private class CombinedReference
{
public readonly SlotCache Slot;
public readonly LegalityAnalysis Analysis;
public CombinedReference(SlotCache slot, LegalityAnalysis analysis)
{
Slot = slot;
Analysis = analysis;
}
}
private void CheckIDReuse()
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var dict = new Dictionary<int, CombinedReference>();
for (int i = 0; i < AllData.Count; i++)
{
if (CloneFlags[i])
continue; // already flagged
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var cs = AllData[i];
var ca = AllAnalysis[i];
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var id = cs.Entity.TID + (cs.Entity.SID << 16);
Debug.Assert(cs.Entity.TID <= ushort.MaxValue);
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
if (!dict.TryGetValue(id, out var pr) || pr is null)
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var r = new CombinedReference(cs, ca);
dict.Add(id, r);
continue;
}
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var pa = pr.Analysis;
// ignore GB era collisions
// a 16bit TID can reasonably occur for multiple trainers, and versions
if (ca.Info.Generation <= 2 && pa.Info.Generation <= 2)
continue;
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var ps = pr.Slot;
if (VerifyIDReuse(ps, pa, cs, ca))
continue;
// egg encounters can be traded before hatching
// store the current loop pkm if it's a better reference
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
if (ps.Entity.WasTradedEgg && !cs.Entity.WasTradedEgg)
dict[id] = new CombinedReference(cs, ca);
}
}
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
private void VerifyECShare(CombinedReference pr, CombinedReference cr)
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var ps = pr.Slot;
var pa = pr.Analysis;
var cs = cr.Slot;
var ca = cr.Analysis;
const CheckIdentifier ident = PID;
int gen = pa.Info.Generation;
bool gbaNDS = gen is 3 or 4 or 5;
if (!gbaNDS)
{
if (ca.Info.Generation != gen)
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
AddLine(ps, cs, "EC sharing across generations detected.", ident);
return;
}
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
AddLine(ps, cs, "EC sharing for 3DS-onward origin detected.", ident);
return;
}
// eggs/mystery gifts shouldn't share with wild encounters
var cenc = ca.Info.EncounterMatch;
2020-12-25 20:30:26 +00:00
bool eggMysteryCurrent = cenc is EncounterEgg or MysteryGift;
var penc = pa.Info.EncounterMatch;
2020-12-25 20:30:26 +00:00
bool eggMysteryPrevious = penc is EncounterEgg or MysteryGift;
if (eggMysteryCurrent != eggMysteryPrevious)
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
AddLine(ps, cs, "EC sharing across RNG encounters detected.", ident);
}
}
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
private void VerifyPIDShare(CombinedReference pr, CombinedReference cr)
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var ps = pr.Slot;
var pa = pr.Analysis;
var cs = cr.Slot;
var ca = cr.Analysis;
const CheckIdentifier ident = PID;
int gen = pa.Info.Generation;
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
if (ca.Info.Generation != gen)
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
AddLine(ps, cs, "PID sharing across generations detected.", ident);
return;
}
bool gbaNDS = gen is 3 or 4 or 5;
if (!gbaNDS)
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
AddLine(ps, cs, "PID sharing for 3DS-onward origin detected.", ident);
return;
}
// eggs/mystery gifts shouldn't share with wild encounters
var cenc = ca.Info.EncounterMatch;
2020-12-25 20:30:26 +00:00
bool eggMysteryCurrent = cenc is EncounterEgg or MysteryGift;
var penc = pa.Info.EncounterMatch;
2020-12-25 20:30:26 +00:00
bool eggMysteryPrevious = penc is EncounterEgg or MysteryGift;
if (eggMysteryCurrent != eggMysteryPrevious)
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
AddLine(ps, cs, "PID sharing across RNG encounters detected.", ident);
}
}
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
private bool VerifyIDReuse(SlotCache ps, LegalityAnalysis pa, SlotCache cs, LegalityAnalysis ca)
{
if (pa.EncounterMatch is MysteryGift {EggEncounter: false})
return false;
if (ca.EncounterMatch is MysteryGift {EggEncounter: false})
return false;
const CheckIdentifier ident = CheckIdentifier.Trainer;
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
var pp = ps.Entity;
var cp = cs.Entity;
// 32bit ID-SID should only occur for one generation
// Trainer-ID-SID should only occur for one version
if (IsSharedVersion(pp, pa, cp, ca))
{
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
AddLine(ps, cs, "TID sharing across versions detected.", ident);
return true;
}
// ID-SID should only occur for one Trainer name
if (pp.OT_Name != cp.OT_Name)
{
var severity = ca.Info.Generation == 4 ? Severity.Fishy : Severity.Invalid;
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
AddLine(ps, cs, "TID sharing across different trainer names detected.", ident, severity);
}
return false;
}
private static bool IsSharedVersion(PKM pp, LegalityAnalysis pa, PKM cp, LegalityAnalysis ca)
{
if (pp.Version == cp.Version)
return false;
// Traded eggs retain the original version ID, only on the same generation
if (pa.Info.Generation != ca.Info.Generation)
return false;
if (pa.EncounterMatch.EggEncounter && pp.WasTradedEgg)
return false; // version doesn't update on trade
if (ca.EncounterMatch.EggEncounter && cp.WasTradedEgg)
return false; // version doesn't update on trade
return true;
}
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
private static IReadOnlyList<LegalityAnalysis> GetIndividualAnalysis(IReadOnlyList<SlotCache> pkms)
{
var results = new LegalityAnalysis[pkms.Count];
for (int i = 0; i < pkms.Count; i++)
Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately (#3222) * Track a PKM's Box,Slot,StorageFlags,Identifier metadata separately Don't store within the object, track the slot origin data separately. Batch editing now pre-filters if using Box/Slot/Identifier logic; split up mods/filters as they're starting to get pretty hefty. - Requesting a Box Data report now shows all slots in the save file (party, misc) - Can now exclude backup saves from database search via toggle (separate from settings preventing load entirely) - Replace some linq usages with direct code * Remove WasLink virtual in PKM Inline any logic, since we now have encounter objects to indicate matching, rather than the proto-legality logic checking properties of a PKM. * Use Fateful to directly check gen5 mysterygift origins No other encounter types in gen5 apply Fateful * Simplify double ball comparison Used to be separate for deferral cases, now no longer needed to be separate. * Grab move/relearn reference and update locally Fix relearn move identifier * Inline defog HM transfer preference check HasMove is faster than getting moves & checking contains. Skips allocation by setting values directly. * Extract more met location metadata checks: WasBredEgg * Replace Console.Write* with Debug.Write* There's no console output UI, so don't include them in release builds. * Inline WasGiftEgg, WasEvent, and WasEventEgg logic Adios legality tags that aren't entirely correct for the specific format. Just put the computations in EncounterFinder.
2021-06-23 03:23:48 +00:00
{
var entry = pkms[i];
var pk = entry.Entity;
results[i] = new LegalityAnalysis(pk);
}
return results;
}
}
}