From fe66a654642b050f8b10b5dc078b2da2ba72b207 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 12 Mar 2017 16:36:23 -0700 Subject: [PATCH] Misc updates Closes #860 by adding in prompt for Gen1 saves to determine if the save originated from VC. Will disable Gen2 legality sources when checking pk1 files. -- Fixes froslass/gallade evolution tree pruning movesets. For whatever reason, the level argument of the Evolution is not 0 when using the item; I manually edited the evos_sm.pkl binary to set the 2 evolutions from [XX] -> 00. Fixes gen1 ingame trades slipping through the getEncounter12 preference. Gen2 has set TIDs, so check if TID is set. Loosens checks for Gen7 trades (including prior transfers) as trading between games clears the memory. Add 3 more g7 trainer stat records too. Thanks Holla! -- Add getMoves(100) optimization as gen7 learnsets can grab 1->100, better than looping over the range every time it's checked. --- PKHeX.WinForms/MainWindow/Main.cs | 15 ++++++++++++--- .../Save Editors/Gen7/SAV_Trainer7.cs | 3 +++ PKHeX/Legality/Checks.cs | 17 ++++++++++++----- PKHeX/Legality/Core.cs | 13 ++++++++----- PKHeX/Legality/Structures/Learnset.cs | 2 ++ PKHeX/Resources/byte/evos_sm.pkl | Bin 65356 -> 65356 bytes 6 files changed, 37 insertions(+), 13 deletions(-) diff --git a/PKHeX.WinForms/MainWindow/Main.cs b/PKHeX.WinForms/MainWindow/Main.cs index d2e840b46..91dc7f116 100644 --- a/PKHeX.WinForms/MainWindow/Main.cs +++ b/PKHeX.WinForms/MainWindow/Main.cs @@ -204,7 +204,6 @@ public Main() } catch (Exception ex) { - // Todo: translate this ErrorWindow.ShowErrorDialog("An error occurred while attempting to auto-load your save file.", ex, true); } @@ -894,7 +893,17 @@ private void openSAV(SaveFile sav, string path) } } // Finish setting up the save file. - if (sav.Generation == 3 && (sav.IndeterminateGame || ModifierKeys == Keys.Control)) + if (sav.Generation == 1) + { + // Ask the user if it is a VC save file or if it is from a physical cartridge. + // Necessary for legality checking possibilities that are only obtainable on GSC (non VC) or event distributions. + var drVC = WinFormsUtil.Prompt(MessageBoxButtons.YesNoCancel, $"{sav.Version} Save File detected. Is this a Virtual Console Save File?", + "Yes: Virtual Console" + Environment.NewLine + "No: Physical Cartridge"); + if (drVC == DialogResult.Cancel) + return; + Legal.AllowGBCartEra = drVC == DialogResult.No; // physical cart selected + } + else if (sav.Generation == 3 && (sav.IndeterminateGame || ModifierKeys == Keys.Control)) { // Hacky cheats invalidated the Game Code value. var drGame = WinFormsUtil.Prompt(MessageBoxButtons.YesNoCancel, @@ -1670,7 +1679,7 @@ private void setMarkings() } } // Clicked Label Shortcuts // - private bool QR6Notified = false; + private bool QR6Notified; private void clickQR(object sender, EventArgs e) { if (ModifierKeys == Keys.Alt) diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.cs index 463c0c611..98f7e08be 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.cs @@ -423,7 +423,10 @@ private void B_GenTID_Click(object sender, EventArgs e) {011, "Link Trades"}, {012, "Link Battles"}, {013, "Link Battle Wins"}, + {014, "Link Battle Losses"}, {015, "Battle Spot Battles"}, + {016, "Battle Spot Wins"}, + {017, "Battle Spot Losses"}, {018, "Mart Stack Purchases"}, {019, "Money Spent"}, {020, "Pokémon deposited at Nursery"}, diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index 6df04e9a6..ff0357e64 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -209,7 +209,7 @@ private void verifyNickname() var et = EncounterOriginal as EncounterTrade; if (et?.TID == 0) // Gen1 Trade { - if (!Legal.getEncounterTrade1Valid(pkm, et)) + if (!Legal.getEncounterTrade1Valid(pkm)) AddLine(Severity.Invalid, "Incorrect OT name for RBY in-game trade.", CheckIdentifier.Trainer); } else // Gen2 @@ -567,7 +567,7 @@ private CheckResult verifyEncounterTrade() } private CheckResult verifyEncounterG12() { - var obj = Legal.getEncounter12(pkm, pkm.Format < 3); + var obj = Legal.getEncounter12(pkm, Legal.AllowGBCartEra && pkm.Format < 3); if (obj == null) return new CheckResult(Severity.Invalid, "Unknown encounter.", CheckIdentifier.Encounter); @@ -1619,11 +1619,18 @@ private void verifyHTMemory() if (!History.Valid) return; - if (pkm.GenNumber == 7 || pkm.GenNumber == 1) + if (pkm.Format >= 7) { - bool check = pkm.VC1 || pkm.HT_Memory != 0; - if (!check) + /* + * Bank Transfer adds in the Link Trade Memory. + * Trading 7<->7 between games (not Bank) clears this data. + */ + if (pkm.HT_Memory == 0) + { + if (pkm.HT_TextVar != 0 || pkm.HT_Intensity != 0 || pkm.HT_Feeling != 0) + AddLine(Severity.Invalid, "HT memory not cleared properly.", CheckIdentifier.Memory); return; + } if (pkm.HT_Memory != 4) AddLine(Severity.Invalid, "Should have a Link Trade HT Memory.", CheckIdentifier.Memory); diff --git a/PKHeX/Legality/Core.cs b/PKHeX/Legality/Core.cs index 48f18f30d..e480f75cf 100644 --- a/PKHeX/Legality/Core.cs +++ b/PKHeX/Legality/Core.cs @@ -7,8 +7,11 @@ namespace PKHeX.Core { public static partial class Legal { - // Event Database(s) - public static MysteryGift[] MGDB_G6, MGDB_G7 = new MysteryGift[0]; + /// Event Database for a given Generation + public static MysteryGift[] MGDB_G4, MGDB_G5, MGDB_G6, MGDB_G7 = new MysteryGift[0]; + + /// Setting to specify if an analysis should permit data sourced from the physical cartridge era of GameBoy games. + public static bool AllowGBCartEra = false; // Gen 1 private static readonly Learnset[] LevelUpRB = Learnset1.getArray(Resources.lvlmove_rb, MaxSpeciesID_1); @@ -505,7 +508,7 @@ private static EncounterTrade getValidEncounterTradeVC1(PKM pkm, DexLevel[] p, E return new Tuple(s, s.Level, 20); // special move if (game == GameVersion.GSC) { - if (t != null) + if (t != null && t.TID != 0) return new Tuple(t, t.Level, 10); // gen2 trade if (WasEgg && new[] { sm, em, tm }.Min(a => a) >= 5) return new Tuple(true, 5, 9); // gen2 egg @@ -527,7 +530,7 @@ private static EncounterTrade getValidEncounterTradeVC1(PKM pkm, DexLevel[] p, E return g1 ?? g2; var t = g1.Item1 as EncounterTrade; - if (t != null && getEncounterTrade1Valid(pkm, t)) + if (t != null && getEncounterTrade1Valid(pkm)) return g1; // Both generations can provide an encounter. Return highest preference @@ -538,7 +541,7 @@ private static EncounterTrade getValidEncounterTradeVC1(PKM pkm, DexLevel[] p, E // Return lowest level encounter return g1.Item2 < g2.Item2 ? g1 : g2; } - internal static bool getEncounterTrade1Valid(PKM pkm, EncounterTrade t) + internal static bool getEncounterTrade1Valid(PKM pkm) { string ot = pkm.OT_Name; string tr = pkm.Format <= 2 ? "TRAINER" : "Trainer"; // decaps on transfer diff --git a/PKHeX/Legality/Structures/Learnset.cs b/PKHeX/Legality/Structures/Learnset.cs index 4a973c7f0..1bceabb26 100644 --- a/PKHeX/Legality/Structures/Learnset.cs +++ b/PKHeX/Legality/Structures/Learnset.cs @@ -12,6 +12,8 @@ public abstract class Learnset public int[] getMoves(int level) { + if (level >= 100) + return Moves; for (int i = 0; i < Levels.Length; i++) if (Levels[i] > level) return Moves.Take(i).ToArray(); diff --git a/PKHeX/Resources/byte/evos_sm.pkl b/PKHeX/Resources/byte/evos_sm.pkl index f4004de53a56850fca65609ea6959f604cf7e61b..5a8f1500b6d1ab7e1d6d07fe534353ace234f406 100644 GIT binary patch delta 27 fcmX@}kNM0$<_*!IlP4<|Zax#*FAQO1HcSNo$d3); delta 27 icmX@}kNM0$<_*!IlPAX&Zax#*FFZLo8pz0Om