diff --git a/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs b/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs index 0ed25ba2c..8d32bec77 100644 --- a/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs +++ b/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using static PKHeX.Core.GameVersion; +using static PKHeX.Core.Legal; namespace PKHeX.Core { @@ -13,32 +14,21 @@ namespace PKHeX.Core /// public sealed class EvolutionTree { - private static readonly EvolutionTree Evolves1; - private static readonly EvolutionTree Evolves2; - private static readonly EvolutionTree Evolves3; - private static readonly EvolutionTree Evolves4; - private static readonly EvolutionTree Evolves5; - private static readonly EvolutionTree Evolves6; - private static readonly EvolutionTree Evolves7; - private static readonly EvolutionTree Evolves7b; - private static readonly EvolutionTree Evolves8; + private static readonly EvolutionTree Evolves1 = new EvolutionTree(new[] { Get("rby") }, Gen1, PersonalTable.Y, MaxSpeciesID_1); + private static readonly EvolutionTree Evolves2 = new EvolutionTree(new[] { Get("gsc") }, Gen2, PersonalTable.C, MaxSpeciesID_2); + private static readonly EvolutionTree Evolves3 = new EvolutionTree(new[] { Get("g3") }, Gen3, PersonalTable.RS, MaxSpeciesID_3); + private static readonly EvolutionTree Evolves4 = new EvolutionTree(new[] { Get("g4") }, Gen4, PersonalTable.DP, MaxSpeciesID_4); + private static readonly EvolutionTree Evolves5 = new EvolutionTree(new[] { Get("g5") }, Gen5, PersonalTable.BW, MaxSpeciesID_5); + private static readonly EvolutionTree Evolves6 = new EvolutionTree(Unpack("ao"), Gen6, PersonalTable.AO, MaxSpeciesID_6); + private static readonly EvolutionTree Evolves7 = new EvolutionTree(Unpack("uu"), Gen7, PersonalTable.USUM, MaxSpeciesID_7_USUM); + private static readonly EvolutionTree Evolves7b = new EvolutionTree(Unpack("gg"), Gen7, PersonalTable.GG, MaxSpeciesID_7b); + private static readonly EvolutionTree Evolves8 = new EvolutionTree(Unpack("ss"), Gen8, PersonalTable.SWSH, MaxSpeciesID_8); + + private static byte[] Get(string resource) => Util.GetBinaryResource($"evos_{resource}.pkl"); + private static byte[][] Unpack(string resource) => BinLinker.Unpack(Get(resource), resource); static EvolutionTree() { - // Evolution tables need Personal Tables initialized beforehand, hence why the EvolutionTree data is initialized here. - static byte[] get(string resource) => Util.GetBinaryResource($"evos_{resource}.pkl"); - static byte[][] unpack(string resource) => BinLinker.Unpack(get(resource), resource); - - Evolves1 = new EvolutionTree(new[] { get("rby") }, Gen1, PersonalTable.Y, Legal.MaxSpeciesID_1); - Evolves2 = new EvolutionTree(new[] { get("gsc") }, Gen2, PersonalTable.C, Legal.MaxSpeciesID_2); - Evolves3 = new EvolutionTree(new[] { get("g3") }, Gen3, PersonalTable.RS, Legal.MaxSpeciesID_3); - Evolves4 = new EvolutionTree(new[] { get("g4") }, Gen4, PersonalTable.DP, Legal.MaxSpeciesID_4); - Evolves5 = new EvolutionTree(new[] { get("g5") }, Gen5, PersonalTable.BW, Legal.MaxSpeciesID_5); - Evolves6 = new EvolutionTree(unpack("ao"), Gen6, PersonalTable.AO, Legal.MaxSpeciesID_6); - Evolves7 = new EvolutionTree(unpack("uu"), Gen7, PersonalTable.USUM, Legal.MaxSpeciesID_7_USUM); - Evolves7b = new EvolutionTree(unpack("gg"), Gen7, PersonalTable.GG, Legal.MaxSpeciesID_7b); - Evolves8 = new EvolutionTree(unpack("ss"), Gen8, PersonalTable.SWSH, Legal.MaxSpeciesID_8); - // Throw in banned evolution data! Evolves7.FixEvoTreeSM(); Evolves8.FixEvoTreeSS(); diff --git a/PKHeX.Core/Legality/RNG/Xoroshiro128Plus.cs b/PKHeX.Core/Legality/RNG/Xoroshiro128Plus.cs index ded1dde96..dc8869ddc 100644 --- a/PKHeX.Core/Legality/RNG/Xoroshiro128Plus.cs +++ b/PKHeX.Core/Legality/RNG/Xoroshiro128Plus.cs @@ -68,5 +68,13 @@ private static ulong GetBitmask(ulong x) x |= x >> 16; return x; } + + // ReSharper disable once NonReadonlyMemberInGetHashCode + // ReSharper disable once NonReadonlyMemberInGetHashCode + public override int GetHashCode() => (int)s0; + public override bool Equals(object obj) => obj is Xoroshiro128Plus s && Equals(s); + public bool Equals(Xoroshiro128Plus obj) => obj.s0 == s0 && obj.s1 == s1; + public static bool operator ==(Xoroshiro128Plus left, Xoroshiro128Plus right) => left.Equals(right); + public static bool operator !=(Xoroshiro128Plus left, Xoroshiro128Plus right) => !(left == right); } } diff --git a/PKHeX.Core/Saves/SAV3Colosseum.cs b/PKHeX.Core/Saves/SAV3Colosseum.cs index d37574523..73efcca74 100644 --- a/PKHeX.Core/Saves/SAV3Colosseum.cs +++ b/PKHeX.Core/Saves/SAV3Colosseum.cs @@ -360,7 +360,7 @@ public override int PlayedSeconds // Trainer Info (offset 0x78, length 0xB18, end @ 0xB90) public override string OT { get => GetString(0x78, 20); set { SetString(value, 10).CopyTo(Data, 0x78); OT2 = value; } } - private string OT2 { get => GetString(0x8C, 20); set => SetString(value, 10).CopyTo(Data, 0x8C); } + public string OT2 { get => GetString(0x8C, 20); set => SetString(value, 10).CopyTo(Data, 0x8C); } public override int SID { get => BigEndian.ToUInt16(Data, 0xA4); set => BigEndian.GetBytes((ushort)value).CopyTo(Data, 0xA4); } public override int TID { get => BigEndian.ToUInt16(Data, 0xA6); set => BigEndian.GetBytes((ushort)value).CopyTo(Data, 0xA6); } diff --git a/PKHeX.Core/Saves/SaveFile.cs b/PKHeX.Core/Saves/SaveFile.cs index e0a3d768e..8fffde343 100644 --- a/PKHeX.Core/Saves/SaveFile.cs +++ b/PKHeX.Core/Saves/SaveFile.cs @@ -81,7 +81,7 @@ protected virtual byte[] GetFinalData() #region Savedata Container Handling public byte[] GetData(int offset, int length) => GetData(Data, offset, length); - public byte[] GetData(byte[] data, int offset, int length) => data.Slice(offset, length); + protected static byte[] GetData(byte[] data, int offset, int length) => data.Slice(offset, length); public void SetData(byte[] input, int offset) => SetData(Data, input, offset); public void SetData(byte[] dest, byte[] input, int offset) diff --git a/PKHeX.Core/Saves/Substructures/Gen7/JoinFesta7.cs b/PKHeX.Core/Saves/Substructures/Gen7/JoinFesta7.cs index 7ead1efca..40784cb91 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/JoinFesta7.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/JoinFesta7.cs @@ -21,7 +21,7 @@ public int FestaCoins } } - private int TotalFestaCoins + public int TotalFestaCoins { get => BitConverter.ToInt32(Data, Offset + 0x50C); set diff --git a/PKHeX.Core/Saves/Substructures/Gen8/TeamIndexes8.cs b/PKHeX.Core/Saves/Substructures/Gen8/TeamIndexes8.cs index 09ab1119b..ebad71dce 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/TeamIndexes8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/TeamIndexes8.cs @@ -64,10 +64,6 @@ public void SaveBattleTeams() } public bool GetIsTeamLocked(int team) => true; - - public void SetIsTeamLocked(int team, bool value) - { - - } + public void SetIsTeamLocked(int team, bool value) { } } -} \ No newline at end of file +} diff --git a/PKHeX.WinForms/Controls/PKM Editor/DrawConfig.cs b/PKHeX.WinForms/Controls/PKM Editor/DrawConfig.cs index bf6b89d2a..1da79ced9 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/DrawConfig.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/DrawConfig.cs @@ -147,6 +147,8 @@ private void ApplyLine(string l) try { var pi = t.GetProperty(name); + if (pi == null) + throw new ArgumentNullException(name); if (pi.PropertyType == typeof(Color)) { var color = Color.FromArgb(int.Parse(value));