diff --git a/PKHeX.Core/Editing/Database/TrainerDatabase.cs b/PKHeX.Core/Editing/Database/TrainerDatabase.cs index 0f2a6e995..eb4c10f69 100644 --- a/PKHeX.Core/Editing/Database/TrainerDatabase.cs +++ b/PKHeX.Core/Editing/Database/TrainerDatabase.cs @@ -46,6 +46,9 @@ private static T GetRandomChoice(IReadOnlyList list) private ITrainerInfo? GetTrainerFromGroup(GameVersion version, LanguageID? lang = null) { var possible = Database.Where(z => version.Contains(z.Key)).ToList(); + if (possible.Count == 0) + return null; + if (lang != null) { possible = possible.Select(z => @@ -66,6 +69,9 @@ private static T GetRandomChoice(IReadOnlyList list) public ITrainerInfo? GetTrainerFromGen(byte generation, LanguageID? lang = null) { var possible = Database.Where(z => z.Key.GetGeneration() == generation).ToList(); + if (possible.Count == 0) + return null; + if (lang != null) { possible = possible.Select(z => diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen3/Colo/EncounterShadow3Colo.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen3/Colo/EncounterShadow3Colo.cs index 0c4909fc9..f9e699395 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen3/Colo/EncounterShadow3Colo.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen3/Colo/EncounterShadow3Colo.cs @@ -139,10 +139,6 @@ private void SetPINGA_EReader(CK3 pk) break; } while (++ctr <= max); - -#if DEBUG - System.Diagnostics.Debug.Assert(ctr < max); -#endif } #endregion diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterArea4.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterArea4.cs index 0687784d8..5a0ae1703 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterArea4.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterArea4.cs @@ -34,7 +34,7 @@ private EncounterArea4(ReadOnlySpan data, [ConstantExpected] GameVersion g Type = (SlotType4)data[2]; Rate = data[3]; Version = game; - // although GroundTilePermission flags are 32bit, none have values > 16bit. + // although flags are 32bit, none have values > 16bit. GroundTile = (GroundTileAllowed)ReadUInt16LittleEndian(data[4..]); Slots = ReadRegularSlots(data[6..]); diff --git a/PKHeX.Core/Legality/RNG/PIDIV.cs b/PKHeX.Core/Legality/RNG/PIDIV.cs index cb71236b7..00b309a7b 100644 --- a/PKHeX.Core/Legality/RNG/PIDIV.cs +++ b/PKHeX.Core/Legality/RNG/PIDIV.cs @@ -50,7 +50,6 @@ public PIDIV(PIDType type, ulong seed) #if DEBUG public override string ToString() => NoSeed ? Type.ToString() : $"{Type} - 0x{OriginSeed:X8}"; #endif - public bool IsClassicMethod() => Type.IsClassicMethod(); public bool IsSeed64() => Type is PIDType.Xoroshiro; diff --git a/PKHeX.Core/MysteryGifts/PCD.cs b/PKHeX.Core/MysteryGifts/PCD.cs index 14df6efeb..cd81a2240 100644 --- a/PKHeX.Core/MysteryGifts/PCD.cs +++ b/PKHeX.Core/MysteryGifts/PCD.cs @@ -107,23 +107,11 @@ public override string CardTitle public bool GiftEquals(PGT pgt) { // Skip over the PGT's "Corresponding PCD Slot" @ 0x02 - byte[] g = pgt.Data; - byte[] c = Gift.Data; + ReadOnlySpan g = pgt.Data; + ReadOnlySpan c = Gift.Data; if (g.Length != c.Length || g.Length < 3) return false; - for (int i = 0; i < 2; i++) - { - if (g[i] != c[i]) - return false; - } - - for (int i = 3; i < g.Length; i++) - { - if (g[i] != c[i]) - return false; - } - - return true; + return g[..2].SequenceEqual(c[..2]) && g[3..].SequenceEqual(c[3..]); } public override PK4 ConvertToPKM(ITrainerInfo tr, EncounterCriteria criteria) diff --git a/PKHeX.Core/PKM/PK9.cs b/PKHeX.Core/PKM/PK9.cs index 7c7bd002d..bec61a291 100644 --- a/PKHeX.Core/PKM/PK9.cs +++ b/PKHeX.Core/PKM/PK9.cs @@ -11,12 +11,7 @@ public sealed class PK9 : PKM, ISanityChecksum, ITeraType, ITechRecord, IObedien { public override ReadOnlySpan ExtraBytes => [ - 0x17, - 0x1A, 0x1B, - 0x23, - 0x33, - 0x3E, 0x3F, - 0x90, 0x91, 0x92, 0x93, // Status condition + 0x17, 0x1A, 0x1B, 0x23, 0x33, 0x3E, 0x3F, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xC5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, diff --git a/PKHeX.Core/Saves/Substructures/Misc/SlotGroup.cs b/PKHeX.Core/Saves/Substructures/Misc/SlotGroup.cs index 21f606db8..8fc4a85a0 100644 --- a/PKHeX.Core/Saves/Substructures/Misc/SlotGroup.cs +++ b/PKHeX.Core/Saves/Substructures/Misc/SlotGroup.cs @@ -1,8 +1,3 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; -public sealed record SlotGroup(string GroupName, PKM[] Slots) -{ -#if DEBUG - public override string ToString() => $"{GroupName}: {Slots.Length} {Slots.GetType().Name}"; -#endif -} +public sealed record SlotGroup(string GroupName, PKM[] Slots); diff --git a/PKHeX.Core/Saves/Substructures/PokeDex/Zukan8.cs b/PKHeX.Core/Saves/Substructures/PokeDex/Zukan8.cs index eaae5e101..c4046bf53 100644 --- a/PKHeX.Core/Saves/Substructures/PokeDex/Zukan8.cs +++ b/PKHeX.Core/Saves/Substructures/PokeDex/Zukan8.cs @@ -130,20 +130,6 @@ public static List GetRawIndexes(PersonalTable8SWSH pt, int dex _ => lang - 1, }; -#if DEBUG - public IList GetEntryNames(IReadOnlyList speciesNames) - { - var dex = new List(); - foreach (var (species, entry) in DexLookup) - { - var name = entry.GetEntryName(speciesNames, species); - dex.Add(name); - } - dex.Sort(); - return dex; - } -#endif - #region Structure internal const int EntrySize = 0x30; @@ -718,30 +704,6 @@ private int GetSavedIndex() private const int Rigel1Count = 211; // Count within Armor dex private const int Rigel2Count = 210; // Count within Crown dex public const int TotalCount = GalarCount + Rigel1Count + Rigel2Count; -#if DEBUG - /// - /// Gets the from the absolute (overall) dex index. Don't use this method unless you're analyzing things. - /// - /// Unique Pokédex index (incremental). Should be 0-indexed. - public static Zukan8Index GetFromAbsoluteIndex(ushort index) - { - if (index > TotalCount) - return new Zukan8Index(); - - if (index < GalarCount) - return new Zukan8Index(Zukan8Type.Galar, ++index); - index -= GalarCount; - - if (index < Rigel1Count) - return new Zukan8Index(Zukan8Type.Armor, ++index); - index -= Rigel1Count; - - if (index < Rigel2Count) - return new Zukan8Index(Zukan8Type.Crown, ++index); - - throw new ArgumentOutOfRangeException(nameof(index)); - } -#endif public string DexPrefix => DexType.GetZukanTypeInternalPrefix();