diff --git a/PKHeX.Core/Legality/Encounters/Generator/Search/EncounterEnumerator3.cs b/PKHeX.Core/Legality/Encounters/Generator/Search/EncounterEnumerator3.cs index 6e375f042..e8e4e2adb 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/Search/EncounterEnumerator3.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/Search/EncounterEnumerator3.cs @@ -49,8 +49,8 @@ private enum YieldState : byte StartCaptures, SlotStart, - SlotR, SlotS, + SlotR, SlotE, SwarmRSE, SlotFR, @@ -74,6 +74,7 @@ private enum YieldState : byte public bool MoveNext() { + top: switch (State) { case YieldState.Start: @@ -145,33 +146,32 @@ public bool MoveNext() case YieldState.SlotStart: if (!EncounterStateUtil.CanBeWildEncounter(Entity)) goto case YieldState.SlotEnd; - if (Version == GameVersion.R) - { State = YieldState.SlotR; goto case YieldState.SlotR; } - if (Version == GameVersion.S) - { State = YieldState.SlotS; goto case YieldState.SlotS; } - if (Version == GameVersion.E) - { State = YieldState.SlotE; goto case YieldState.SlotE; } if (Version == GameVersion.FR) { State = YieldState.SlotFR; goto case YieldState.SlotFR; } if (Version == GameVersion.LG) { State = YieldState.SlotLG; goto case YieldState.SlotLG; } - throw new ArgumentOutOfRangeException(nameof(Version)); + if (Version is not (GameVersion.R or GameVersion.S or GameVersion.E)) + throw new ArgumentOutOfRangeException(nameof(Version)); + State = YieldState.SwarmRSE; goto case YieldState.SwarmRSE; + + case YieldState.SwarmRSE: + // Aggressively check for Swarm (special move), only one match possible. Next loop will reach regular slots. + // higher priority due to having special move, and poor vblank matching deferral tiebreaks + if (TryGetNext(Encounters3RSE.SlotsSwarmRSE)) + return true; + Index = 0; State = YieldState.SlotS + (byte)((byte)Version - 1); Index = 0; goto top; case YieldState.SlotR: if (TryGetNext(Encounters3RSE.SlotsR)) return true; - Index = 0; State = YieldState.SwarmRSE; goto case YieldState.SwarmRSE; + Index = 0; goto case YieldState.SlotEnd; case YieldState.SlotS: if (TryGetNext(Encounters3RSE.SlotsS)) return true; - Index = 0; State = YieldState.SwarmRSE; goto case YieldState.SwarmRSE; + Index = 0; goto case YieldState.SlotEnd; case YieldState.SlotE: if (TryGetNext(Encounters3RSE.SlotsE)) return true; - Index = 0; State = YieldState.SwarmRSE; goto case YieldState.SwarmRSE; - case YieldState.SwarmRSE: - if (TryGetNext(Encounters3RSE.SlotsSwarmRSE)) - return true; Index = 0; goto case YieldState.SlotEnd; case YieldState.SlotFR: diff --git a/PKHeX.WinForms/Subforms/SaveHandlerTroubleshooter.cs b/PKHeX.WinForms/Subforms/SaveHandlerTroubleshooter.cs index f4f5fbf41..f34c22644 100644 --- a/PKHeX.WinForms/Subforms/SaveHandlerTroubleshooter.cs +++ b/PKHeX.WinForms/Subforms/SaveHandlerTroubleshooter.cs @@ -37,8 +37,7 @@ private void InitializeBindings() var handlers = SaveUtil.Handlers.ToList(); handlers.Insert(0, new SaveHandlerDefault()); CB_Handler.DataSource = handlers - .Select(z => new HandlerItem(GetHandlerDisplayName(z), z)) - .ToList(); + .ConvertAll(z => new HandlerItem(GetHandlerDisplayName(z), z)); UpdateSubVersionChoices(); } diff --git a/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 3/Misc/0283 ★ - TEST - 5143F610D91A swarm lead matching.pk3 b/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 3/Misc/0283 ★ - TEST - 5143F610D91A swarm lead matching.pk3 new file mode 100644 index 000000000..e0833b05f Binary files /dev/null and b/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 3/Misc/0283 ★ - TEST - 5143F610D91A swarm lead matching.pk3 differ