diff --git a/PKHeX/Game/GameInfo.cs b/PKHeX/Game/GameInfo.cs index 3cfbd13f6..658d82915 100644 --- a/PKHeX/Game/GameInfo.cs +++ b/PKHeX/Game/GameInfo.cs @@ -254,14 +254,12 @@ public string[] getItemStrings(int generation, GameVersion game) case GameVersion.XD: return g3xditems; default: - if (!Legal.EReaderBerryIsEnigma) - { - var g3itemsEBerry = new string[g3items.Length]; - Array.Copy(g3items, g3itemsEBerry, g3items.Length); - g3itemsEBerry[175] = Legal.EReaderBerryDisplayName; - return g3itemsEBerry; - } - return g3items; + if (Legal.EReaderBerryIsEnigma) + return g3items; + + var g3itemsEBerry = (string[])g3items.Clone(); + g3itemsEBerry[175] = Legal.EReaderBerryDisplayName; + return g3itemsEBerry; } default: return itemlist; diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index 99f5ae6e9..70607204d 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -3006,7 +3006,7 @@ private void ParseShedinjaEvolveMoves(int[] moves, ref CheckResult[] res) { List[] ShedinjaEvoMoves = Legal.getShedinjaEvolveMoves(pkm); var ShedinjaEvoMovesLearned = new List(); - for (int gen = Math.Min(pkm.Format,4); gen >= 3; gen--) + for (int gen = Math.Min(pkm.Format, 4); gen >= 3; gen--) { bool native = gen == pkm.Format; for (int m = 0; m < 4; m++) diff --git a/PKHeX/Legality/Core.cs b/PKHeX/Legality/Core.cs index 57c363d20..ddb708a3c 100644 --- a/PKHeX/Legality/Core.cs +++ b/PKHeX/Legality/Core.cs @@ -15,6 +15,12 @@ public static partial class Legal /// Setting to specify if an analysis should permit data sourced from the physical cartridge era of GameBoy games. public static bool AllowGBCartEra = false; + /// Setting to specify if the e-berry index item is an eningma berry or a e-reader berry and the name of the e-reader berry + public static bool EReaderBerryIsEnigma = true; + public static string EReaderBerryName = string.Empty; + public static string EReaderBerryDisplayName => string.Format(V372, CultureInfo.CurrentCulture.TextInfo.ToTitleCase(EReaderBerryName.ToLower())); + public static bool SavegameJapanese = false; + // Gen 1 private static readonly Learnset[] LevelUpRB = Learnset1.getArray(Resources.lvlmove_rb, MaxSpeciesID_1); private static readonly Learnset[] LevelUpY = Learnset1.getArray(Resources.lvlmove_y, MaxSpeciesID_1); @@ -39,13 +45,7 @@ public static partial class Legal private static readonly EggMoves[] EggMovesRS = EggMoves6.getArray(Data.unpackMini(Resources.eggmove_rs, "rs")); private static readonly EvolutionTree Evolves3; private static readonly EncounterArea[] SlotsR, SlotsS, SlotsE, SlotsFR, SlotsLG; - private static readonly EncounterStatic[] StaticR, StaticS, StaticE, StaticFR, StaticLG; - - /// Setting to specify if the e-berry index item is an eningma berry or a e-reader berry and the name of the e-reader berry - public static bool EReaderBerryIsEnigma = true; - public static string EReaderBerryName = string.Empty; - public static string EReaderBerryDisplayName => string.Format(V372, CultureInfo.CurrentCulture.TextInfo.ToTitleCase(EReaderBerryName.ToLower())); - public static bool SavegameJapanese = false; + private static readonly EncounterStatic[] StaticR, StaticS, StaticE, StaticFR, StaticLG; // Gen 4 private static readonly Learnset[] LevelUpDP = Learnset6.getArray(Data.unpackMini(Resources.lvlmove_dp, "dp")); diff --git a/PKHeX/Legality/LegalityCheckStrings.cs b/PKHeX/Legality/LegalityCheckStrings.cs index c5d9a1738..51148a336 100644 --- a/PKHeX/Legality/LegalityCheckStrings.cs +++ b/PKHeX/Legality/LegalityCheckStrings.cs @@ -363,7 +363,7 @@ public static class LegalityCheckStrings public static string V368 {get; set;} = "Eggs can not be infected with Pokérus."; // Invalid public static string V369 {get; set;} = "Invalid E-Reader Berry."; public static string V370 {get; set;} = "Japanese E-Reader Berry in international savegame."; - public static string V371 {get; set;} = "American E-Reader Berry in japanese savegame."; + public static string V371 {get; set;} = "American E-Reader Berry in Japanese savegame."; #endregion } diff --git a/PKHeX/Legality/Tables3.cs b/PKHeX/Legality/Tables3.cs index 74561e717..49e086d31 100644 --- a/PKHeX/Legality/Tables3.cs +++ b/PKHeX/Legality/Tables3.cs @@ -107,7 +107,7 @@ public static partial class Legal 005, // Safari Ball }; internal static readonly bool[] ReleasedHeldItems_3 = Enumerable.Range(0, MaxItemID_3+1).Select(i => HeldItems_RS.Contains((ushort)i) && !UnreleasedItems_3.Contains(i)).ToArray(); - internal static readonly string[] EReaderBerriesNames_USA = new[] + internal static readonly string[] EReaderBerriesNames_USA = { // USA Series 1 "PUMKIN", @@ -117,7 +117,7 @@ public static partial class Legal "CHILAN", "NUTPEA", }; - internal static readonly string[] EReaderBerriesNames_JP = new[] + internal static readonly string[] EReaderBerriesNames_JP = { // JP Series 1 "カチャ", // PUMKIN diff --git a/PKHeX/Resources/text/en/LegalityCheckStrings_en.txt b/PKHeX/Resources/text/en/LegalityCheckStrings_en.txt index befa01a45..37fbeb7a8 100644 --- a/PKHeX/Resources/text/en/LegalityCheckStrings_en.txt +++ b/PKHeX/Resources/text/en/LegalityCheckStrings_en.txt @@ -303,4 +303,4 @@ V367 = Individual EV for a level 100 encounter in generation 4 cannot be greater V368 = Eggs can not be infected with Pokérus. V369 = Invalid E-Reader Berry. V370 = Japanese E-Reader Berry in international savegame. -V371 = American E-Reader Berry in japanese savegame. \ No newline at end of file +V371 = American E-Reader Berry in Japanese savegame. \ No newline at end of file diff --git a/PKHeX/Resources/text/zh/LegalityCheckStrings_zh.txt b/PKHeX/Resources/text/zh/LegalityCheckStrings_zh.txt index cc57927fb..006364e98 100644 --- a/PKHeX/Resources/text/zh/LegalityCheckStrings_zh.txt +++ b/PKHeX/Resources/text/zh/LegalityCheckStrings_zh.txt @@ -303,4 +303,4 @@ V367 = Individual EV for a level 100 encounter in generation 4 cannot be greater V368 = Eggs can not be infected with Pokérus. V369 = Invalid E-Reader Berry. V370 = Japanese E-Reader Berry in international savegame. -V371 = American E-Reader Berry in japanese savegame. \ No newline at end of file +V371 = American E-Reader Berry in Japanese savegame. \ No newline at end of file diff --git a/PKHeX/Saves/SAV3.cs b/PKHeX/Saves/SAV3.cs index 4660ae1ba..f9ea4dfc7 100644 --- a/PKHeX/Saves/SAV3.cs +++ b/PKHeX/Saves/SAV3.cs @@ -610,16 +610,13 @@ private void LoadEReaderBerryData() if (!GameVersion.RS.Contains(Version)) return; - byte[] chk = getData(BlockOfs[4] + OFFSET_EBERRY, SIZE_EBERRY - 4); - for (int i = 0; i < 8; i++) - //These 8 bytes are taken as 0x00 for chk calculation - chk[0xC + i] = 0x00; + byte[] data = getData(BlockOfs[4] + OFFSET_EBERRY, SIZE_EBERRY - 4); - var calc_cksum = 0; - for (int i = 0; i < chk.Length; i++) - calc_cksum = unchecked(calc_cksum + chk[i]); - - eBerryChecksumValid = calc_cksum == eBerryChecksum; + // 8 bytes are 0x00 for chk calculation + for (int i = 0; i < 8; i++) + data[0xC + i] = 0x00; + uint chk = (uint)data.Sum(z => z); + eBerryChecksumValid = eBerryChecksum == chk; } #endregion }