From 0ac5d57224017175868face6c09aff9340047253 Mon Sep 17 00:00:00 2001 From: Philipp Joram Date: Sun, 29 Jan 2017 14:10:54 +0100 Subject: [PATCH 01/10] Fix tabs for bag pouches not showing on Linux/Mono Passing a height of 0 lets the TabControl dissapear, making it impossible to switch tabs between different pouches. To fix this, use the same approach as for the width and pass the height of the first icon. --- PKHeX.WinForms/Subforms/Save Editors/SAV_Inventory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PKHeX.WinForms/Subforms/Save Editors/SAV_Inventory.cs b/PKHeX.WinForms/Subforms/Save Editors/SAV_Inventory.cs index f7e3c83eb..97d52812e 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/SAV_Inventory.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/SAV_Inventory.cs @@ -51,7 +51,7 @@ private void B_Save_Click(object sender, EventArgs e) private void initBags() { tabControl1.SizeMode = TabSizeMode.Fixed; - tabControl1.ItemSize = new Size(IL_Pouch.Images[0].Width + 4, 0); + tabControl1.ItemSize = new Size(IL_Pouch.Images[0].Width + 4, IL_Pouch.Images[0].Height + 4); for (int i = 0; i < Pouches.Length; i++) { // Add Tab From dfc518faab345e7bb0a7707d84323e8b5a79ec71 Mon Sep 17 00:00:00 2001 From: javierhimura Date: Sun, 29 Jan 2017 18:11:48 +0100 Subject: [PATCH 02/10] Get lineage using the source generation of the pokemon (#769) * Added function get max species by source game of a pokemon * Tweak get lineage function to take into account the source generation of the pokemon --- PKHeX/Legality/Checks.cs | 2 +- PKHeX/Legality/Core.cs | 34 ++++++++++++++++++++++ PKHeX/Legality/Structures/EvolutionTree.cs | 3 ++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index c14e682ec..582240ff3 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -369,7 +369,7 @@ private CheckResult verifyEncounter() if (pkm.VC) { - int baseSpecies = Legal.getEvolutionChain(pkm, null).Min(entry => entry.Species); + int baseSpecies = Legal.getBaseSpecies(pkm); if ((pkm.VC1 && baseSpecies > Legal.MaxSpeciesID_1) || (pkm.VC2 && baseSpecies > Legal.MaxSpeciesID_2)) return new CheckResult(Severity.Invalid, "VC: Unobtainable species.", CheckIdentifier.Encounter); diff --git a/PKHeX/Legality/Core.cs b/PKHeX/Legality/Core.cs index e6d989a18..7cf9016a8 100644 --- a/PKHeX/Legality/Core.cs +++ b/PKHeX/Legality/Core.cs @@ -365,6 +365,40 @@ private static EvolutionTree getEvolutionTable(PKM pkm) return Evolves6; } } + + private static int getMaxSpeciesOrigin(int generation) + { + switch (generation) + { + case 1: + return Legal.MaxSpeciesID_1; + case 2: + return Legal.MaxSpeciesID_2; + case 3: + return Legal.MaxSpeciesID_3; + case 4: + return Legal.MaxSpeciesID_4; + case 5: + return Legal.MaxSpeciesID_5; + case 6: + return Legal.MaxSpeciesID_6; + case 7: + return Legal.MaxSpeciesID_7; + default: + return Legal.MaxSpeciesID_7; + } + } + + internal static int getMaxSpeciesOrigin(PKM pkm) + { + if (pkm.Format == 1 || pkm.VC1) //Gen1 VC could not trade with gen 2 yet + return getMaxSpeciesOrigin(1); + else if (pkm.Format == 2 || pkm.VC2) + return getMaxSpeciesOrigin(2); + else + return getMaxSpeciesOrigin(pkm.GenNumber); + } + internal static IEnumerable getValidGifts(PKM pkm) { switch (pkm.GenNumber) diff --git a/PKHeX/Legality/Structures/EvolutionTree.cs b/PKHeX/Legality/Structures/EvolutionTree.cs index cfd838f34..d618c1761 100644 --- a/PKHeX/Legality/Structures/EvolutionTree.cs +++ b/PKHeX/Legality/Structures/EvolutionTree.cs @@ -354,6 +354,7 @@ public void Insert(EvolutionStage evo) public IEnumerable getExplicitLineage(PKM pkm, int lvl, bool skipChecks, int maxSpecies) { + int maxSpeciesOrigin = Legal.getMaxSpeciesOrigin(pkm); List dl = new List { new DexLevel { Species = pkm.Species, Level = lvl, Form = pkm.AltForm } }; for (int i = Chain.Count-1; i >= 0; i--) // reverse evolution! { @@ -376,6 +377,8 @@ public IEnumerable getExplicitLineage(PKM pkm, int lvl, bool skipCheck if (!oneValid) break; } + if (dl.Any(d=>d.Species <= maxSpeciesOrigin) && dl.Last().Species > maxSpeciesOrigin) + dl.RemoveAt(dl.Count - 1);//remove future gen preevolutions, no munchlax in a gen3 snorlax, no pichu in a gen1 vc raichu, etc return dl; } } From fefd3e6e72f5d64435eb3b096e064aa71fa512b3 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 29 Jan 2017 09:26:40 -0800 Subject: [PATCH 03/10] Simplification changes remove dexlevel(lvl) call in favor of single species call, differentiate maxSpeciesOrigin from maxSpeciesTree --- PKHeX/Legality/Structures/EvolutionTree.cs | 42 ++++++++++------------ 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/PKHeX/Legality/Structures/EvolutionTree.cs b/PKHeX/Legality/Structures/EvolutionTree.cs index d618c1761..1d2c7af00 100644 --- a/PKHeX/Legality/Structures/EvolutionTree.cs +++ b/PKHeX/Legality/Structures/EvolutionTree.cs @@ -10,13 +10,13 @@ public class EvolutionTree private readonly EvolutionLineage[] Lineage; private readonly GameVersion Game; private readonly PersonalTable Personal; - private readonly int MaxSpecies; + private readonly int MaxSpeciesTree; - public EvolutionTree(byte[][] data, GameVersion game, PersonalTable personal, int maxSpecies) + public EvolutionTree(byte[][] data, GameVersion game, PersonalTable personal, int maxSpeciesTree) { Game = game; Personal = personal; - MaxSpecies = maxSpecies; + MaxSpeciesTree = maxSpeciesTree; switch (game) { case GameVersion.SM: @@ -32,7 +32,7 @@ public EvolutionTree(byte[][] data, GameVersion game, PersonalTable personal, in for (int i = 0; i < Entries.Count; i++) Lineage[i] = new EvolutionLineage(); if (Game == GameVersion.ORAS) - Array.Resize(ref Lineage, maxSpecies + 1); + Array.Resize(ref Lineage, maxSpeciesTree + 1); // Populate Lineages for (int i = 1; i < Lineage.Length; i++) @@ -149,7 +149,8 @@ private int getIndex(EvolutionMethod evo) public IEnumerable getValidPreEvolutions(PKM pkm, int lvl, bool skipChecks = false) { int index = getIndex(pkm); - return Lineage[index].getExplicitLineage(pkm, lvl, skipChecks, MaxSpecies); + int maxSpeciesOrigin = Legal.getMaxSpeciesOrigin(pkm); + return Lineage[index].getExplicitLineage(pkm, lvl, skipChecks, MaxSpeciesTree, maxSpeciesOrigin); } } @@ -293,16 +294,6 @@ public bool Valid(PKM pkm, int lvl, bool skipChecks) } } - public DexLevel GetDexLevel(int lvl) - { - return new DexLevel - { - Species = Species, - Level = lvl, - Form = Form, - Flag = Method, - }; - } public DexLevel GetDexLevel(int species, int lvl) { @@ -352,9 +343,8 @@ public void Insert(EvolutionStage evo) Chain.Insert(0, evo); } - public IEnumerable getExplicitLineage(PKM pkm, int lvl, bool skipChecks, int maxSpecies) + public IEnumerable getExplicitLineage(PKM pkm, int lvl, bool skipChecks, int maxSpeciesTree, int maxSpeciesOrigin) { - int maxSpeciesOrigin = Legal.getMaxSpeciesOrigin(pkm); List dl = new List { new DexLevel { Species = pkm.Species, Level = lvl, Form = pkm.AltForm } }; for (int i = Chain.Count-1; i >= 0; i--) // reverse evolution! { @@ -365,11 +355,14 @@ public IEnumerable getExplicitLineage(PKM pkm, int lvl, bool skipCheck continue; oneValid = true; - if (evo.Species > maxSpecies) // Gen7 Personal Formes -- unmap the forme personal entry to the actual species ID since species are consecutive - dl.Add(evo.GetDexLevel(pkm.Species - Chain.Count + i, lvl)); - else - dl.Add(evo.GetDexLevel(lvl)); + int species = evo.Species; + // Gen7 Personal Formes -- unmap the forme personal entry ID to the actual species ID since species are consecutive + if (evo.Species > maxSpeciesTree) + species = pkm.Species - Chain.Count + i; + + dl.Add(evo.GetDexLevel(species, lvl)); + if (evo.RequiresLevelUp) lvl--; break; @@ -377,8 +370,11 @@ public IEnumerable getExplicitLineage(PKM pkm, int lvl, bool skipCheck if (!oneValid) break; } - if (dl.Any(d=>d.Species <= maxSpeciesOrigin) && dl.Last().Species > maxSpeciesOrigin) - dl.RemoveAt(dl.Count - 1);//remove future gen preevolutions, no munchlax in a gen3 snorlax, no pichu in a gen1 vc raichu, etc + + // Remove future gen preevolutions, no munchlax in a gen3 snorlax, no pichu in a gen1 vc raichu, etc + if (dl.Any(d => d.Species <= maxSpeciesOrigin) && dl.Last().Species > maxSpeciesOrigin) + dl.RemoveAt(dl.Count - 1); + return dl; } } From 6a63137ca68262998a0e7c5307005882451568ad Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 29 Jan 2017 10:45:02 -0800 Subject: [PATCH 04/10] Fix forme display Closes #771 --- PKHeX.WinForms/MainWindow/Main.cs | 6 ++++++ PKHeX/PKM/PKX.cs | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/PKHeX.WinForms/MainWindow/Main.cs b/PKHeX.WinForms/MainWindow/Main.cs index f49ec50a0..16982a41b 100644 --- a/PKHeX.WinForms/MainWindow/Main.cs +++ b/PKHeX.WinForms/MainWindow/Main.cs @@ -2281,6 +2281,9 @@ private void updateForm(object sender, EventArgs e) changingFields = true; MT_Form.Text = CB_Form.SelectedIndex.ToString(); changingFields = false; + + if (fieldsLoaded) + getQuickFiller(dragout); } private void updateHaXForm(object sender, EventArgs e) { @@ -2290,6 +2293,9 @@ private void updateHaXForm(object sender, EventArgs e) int form = pkm.AltForm = Util.ToInt32(MT_Form.Text); CB_Form.SelectedIndex = CB_Form.Items.Count > form ? form : -1; changingFields = false; + + if (fieldsLoaded) + getQuickFiller(dragout); } private void updatePP(object sender, EventArgs e) { diff --git a/PKHeX/PKM/PKX.cs b/PKHeX/PKM/PKX.cs index 35349a12d..8b829b5ce 100644 --- a/PKHeX/PKM/PKX.cs +++ b/PKHeX/PKM/PKX.cs @@ -636,7 +636,7 @@ public static string[] getFormList(int species, string[] t, string[] f, string[] { f[412], // Plant f[905], // Sandy - f[904], // Trash + f[906], // Trash }; case 421: @@ -841,7 +841,7 @@ public static string[] getFormList(int species, string[] t, string[] f, string[] f[976], // Savannah f[977], // Sun f[978], // Ocean - f[989], // Jungle + f[979], // Jungle f[980], // Fancy f[981], // Poké Ball }; @@ -871,7 +871,7 @@ public static string[] getFormList(int species, string[] t, string[] f, string[] case 676: return new[] { - f[994], // Natural + f[676], // Natural f[995], // Heart f[996], // Star f[997], // Diamond From 3da9bcd0dfc40f291975a0174caf0c51f4d06c7c Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 29 Jan 2017 16:55:35 -0800 Subject: [PATCH 05/10] update SM dex iterator #772 sneak in misc changes to PKM.cs, to snazzify HPType calc and to allow markings to be converted from g7 format to g6 --- .../Save Editors/Gen7/SAV_PokedexSM.cs | 82 +++++++++++++------ PKHeX/PKM/PKM.cs | 4 +- 2 files changed, 58 insertions(+), 28 deletions(-) diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexSM.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexSM.cs index 9aec766ce..16091d3b4 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexSM.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexSM.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Windows.Forms; @@ -30,7 +31,8 @@ public SAV_PokedexSM() // Add Formes int ctr = SAV.MaxSpeciesID; - for (int i = 0; i < SAV.MaxSpeciesID + 1; i++) + baseSpecies = new List(); + for (int i = 1; i < SAV.MaxSpeciesID + 1; i++) { int c = SAV.Personal[i].FormeCount; for (int j = 0; j < c; j++) @@ -38,6 +40,7 @@ public SAV_PokedexSM() int x = SaveUtil.getDexFormIndexSM(i, c, j); if (x == -1 || j == 0) continue; + baseSpecies.Add(i); ctr++; LB_Species.Items.Add($"{ctr:000} - {GameInfo.Strings.specieslist[i]}-{j}"); } @@ -54,6 +57,16 @@ public SAV_PokedexSM() private int species = -1; private readonly CheckBox[] CP, CL; + private readonly List baseSpecies; + private int getBaseSpeciesGender(int index) + { + if (index <= SAV.MaxSpeciesID) + return SAV.Personal[index + 1].Gender; + + index -= SAV.MaxSpeciesID; + return SAV.Personal[baseSpecies[index]].Gender; + } + private void changeCBSpecies(object sender, EventArgs e) { if (editing) return; @@ -120,6 +133,11 @@ private void getEntry() CHK_P1.Enabled = species <= SAV.MaxSpeciesID; CHK_P1.Checked = CHK_P1.Enabled && Dex.Owned[pk]; + int gt = getBaseSpeciesGender(LB_Species.SelectedIndex); + + CHK_P2.Enabled = CHK_P4.Enabled = CHK_P6.Enabled = CHK_P8.Enabled = gt != 254; // Not Female-Only + CHK_P3.Enabled = CHK_P5.Enabled = CHK_P7.Enabled = CHK_P9.Enabled = gt != 0 && gt != 255; // Not Male-Only and Not Genderless + for (int i = 0; i < 4; i++) CP[i + 1].Checked = Dex.Seen[i][pk]; @@ -260,8 +278,7 @@ private void B_GiveAll_Click(object sender, EventArgs e) { CHK_P1.Checked = ModifierKeys != Keys.Control; } - int index = LB_Species.SelectedIndex+1; - int gt = SAV.Personal[index].Gender; + int gt = getBaseSpeciesGender(LB_Species.SelectedIndex); CHK_P2.Checked = CHK_P4.Checked = gt != 254 && ModifierKeys != Keys.Control; CHK_P3.Checked = CHK_P5.Checked = gt != 0 && gt != 255 && ModifierKeys != Keys.Control; @@ -282,18 +299,21 @@ private void modifyAll(object sender, EventArgs e) int lang = SAV.Language; if (lang > 5) lang -= 1; lang -= 1; + int[] totem = { 811, 1018, 1019, 1024, 1025, 1026, 1058, 1059, 1060 }; if (sender == mnuSeenNone || sender == mnuSeenAll || sender == mnuComplete) - for (int i = 0; i < CB_Species.Items.Count; i++) + for (int i = 0; i < LB_Species.Items.Count; i++) { - int gt = SAV.Personal[i + 1].Gender; LB_Species.SelectedIndex = i; + int gt = getBaseSpeciesGender(LB_Species.SelectedIndex); foreach (CheckBox t in new[] { CHK_P2, CHK_P3, CHK_P4, CHK_P5 }) t.Checked = mnuSeenNone != sender && t.Enabled; - if (mnuSeenNone != sender) + if (mnuSeenNone != sender && !totem.Contains(i+1)) { - // if seen ensure at least one Displayed + // ensure at least one Displayed except for formes + if (i >= CB_Species.Items.Count) + continue; if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) (gt != 254 ? CHK_P6 : CHK_P7).Checked = true; } @@ -309,41 +329,51 @@ private void modifyAll(object sender, EventArgs e) } if (sender == mnuCaughtNone || sender == mnuCaughtAll || sender == mnuComplete) + { for (int i = 0; i < LB_Species.Items.Count; i++) { - int gt = SAV.Personal[i + 1].Gender; + int gt = getBaseSpeciesGender(LB_Species.SelectedIndex); LB_Species.SelectedIndex = i; foreach (CheckBox t in new[] { CHK_P1 }) t.Checked = mnuCaughtNone != sender; for (int j = 0; j < CL.Length; j++) CL[j].Checked = CL[j].Enabled && (sender == mnuComplete || (mnuCaughtNone != sender && j == lang)); + + // Don't modify totem entries + if (totem.Contains(i+1)) + continue; if (mnuCaughtNone == sender) { + if (i >= CB_Species.Items.Count) + continue; if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked)) // if seen if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) // not displayed (gt != 254 ? CHK_P6 : CHK_P7).Checked = true; // check one - } - if (mnuCaughtNone != sender) - { - if (mnuComplete == sender) - { - // Seen All - foreach (var chk in new[] { CHK_P2, CHK_P3, CHK_P4, CHK_P5 }) - chk.Checked = true; - } - else - { - // ensure at least one SEEN - if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked)) - (gt != 254 ? CHK_P2 : CHK_P3).Checked = true; - } - // ensure at least one Displayed - if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) - (gt != 254 ? CHK_P6 : CHK_P7).Checked = CHK_P1.Enabled; // except for formes -- base species is set as default seen + continue; } + + if (mnuComplete == sender) + { + // Seen All + foreach (var chk in new[] { CHK_P2, CHK_P3, CHK_P4, CHK_P5 }) + chk.Checked = chk.Enabled; + } + else + { + // ensure at least one SEEN + if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked)) + (gt != 254 ? CHK_P2 : CHK_P3).Checked = true; + } + + // ensure at least one Displayed except for formes + if (i >= CB_Species.Items.Count) + continue; + if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) + (gt != 254 ? CHK_P6 : CHK_P7).Checked = CHK_P1.Enabled; } + } setEntry(); // Turn off zh2 Petilil diff --git a/PKHeX/PKM/PKM.cs b/PKHeX/PKM/PKM.cs index 035890b9c..fa243874a 100644 --- a/PKHeX/PKM/PKM.cs +++ b/PKHeX/PKM/PKM.cs @@ -374,7 +374,7 @@ public virtual int[] Markings return; byte b = 0; for (int i = 0; i < value.Length; i++) - b |= (byte)((value[i] & 1) << i); + b |= (byte)(Math.Max(value[i], 1) << i); MarkValue = b; } } @@ -386,7 +386,7 @@ public int[] CNTs } public virtual int HPType { - get { return 15 * ((IV_HP & 1) + 2 * (IV_ATK & 1) + 4 * (IV_DEF & 1) + 8 * (IV_SPE & 1) + 16 * (IV_SPA & 1) + 32 * (IV_SPD & 1)) / 63; } + get { return 0xF * ((IV_HP & 1) << 0 | (IV_ATK & 1) << 1 | (IV_DEF & 1) << 2 | (IV_SPE & 1) << 3 | (IV_SPA & 1) << 4 | (IV_SPD & 1) << 5) / 0x3F; } set { IV_HP = (IV_HP & ~1) + PKX.hpivs[value, 0]; From 9506b3bbe1f02d7cbc62341bcec0e3ced7088c26 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 29 Jan 2017 17:50:06 -0800 Subject: [PATCH 06/10] Fix cloning overflow use the count of slots in a box, not 30 hardcoded Thanks Wanderer1391! --- PKHeX.WinForms/MainWindow/Main.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PKHeX.WinForms/MainWindow/Main.cs b/PKHeX.WinForms/MainWindow/Main.cs index 16982a41b..2fa8e13dc 100644 --- a/PKHeX.WinForms/MainWindow/Main.cs +++ b/PKHeX.WinForms/MainWindow/Main.cs @@ -3506,7 +3506,7 @@ private void clickClone(object sender, EventArgs e) PKM pk = preparePKM(); int slotSkipped = 0; - for (int i = 0; i < 30; i++) // set to every slot in box + for (int i = 0; i < SAV.BoxSlotCount; i++) // set to every slot in box { if (SAV.getIsSlotLocked(CB_BoxSelect.SelectedIndex, i)) { slotSkipped++; continue; } From bcf4c72e86f9755b83f281d614c9e9ac53a52114 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 29 Jan 2017 19:03:50 -0800 Subject: [PATCH 07/10] Clarify PersonalInfoSM local bool FormVariantEggMoves are used? #774 --- PKHeX/Legality/Core.cs | 6 ++---- PKHeX/PersonalInfo/PersonalInfoSM.cs | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/PKHeX/Legality/Core.cs b/PKHeX/Legality/Core.cs index 7cf9016a8..2ca4089e5 100644 --- a/PKHeX/Legality/Core.cs +++ b/PKHeX/Legality/Core.cs @@ -987,11 +987,9 @@ private static IEnumerable getEggMoves(PKM pkm, int species, int formnum) case 6: // entries per species return EggMovesAO[species].Moves.Concat(EggMovesXY[species].Moves); - case 7: // entries per form - if (species == 678) - { species = 677; formnum = 0; } + case 7: // entries per form if required var entry = EggMovesSM[species]; - if (formnum > 0) + if (formnum > 0 && ((PersonalInfoSM)PersonalTable.SM[species]).FormVariantEggMoves) entry = EggMovesSM[entry.FormTableIndex + formnum - 1]; return entry.Moves; diff --git a/PKHeX/PersonalInfo/PersonalInfoSM.cs b/PKHeX/PersonalInfo/PersonalInfoSM.cs index cc887e01b..0f02092c6 100644 --- a/PKHeX/PersonalInfo/PersonalInfoSM.cs +++ b/PKHeX/PersonalInfo/PersonalInfoSM.cs @@ -25,6 +25,6 @@ public override byte[] Write() public int SpecialZ_Item { get { return BitConverter.ToUInt16(Data, 0x4C); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x4C); } } public int SpecialZ_BaseMove { get { return BitConverter.ToUInt16(Data, 0x4E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x4E); } } public int SpecialZ_ZMove { get { return BitConverter.ToUInt16(Data, 0x50); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x50); } } - public bool LocalVariant { get { return Data[0x52] == 1; } set { Data[0x52] = (byte)(value ? 1 : 0); } } + public bool FormVariantEggMoves { get { return Data[0x52] == 1; } set { Data[0x52] = (byte)(value ? 1 : 0); } } } } From f7e354a839b1a1fef45a947f831b092eb51daf2d Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 29 Jan 2017 19:11:40 -0800 Subject: [PATCH 08/10] Allow gen3/4 balls on gen3/4 starters Closes #774 Thanks @PKMWM1 ! --- PKHeX/Legality/Checks.cs | 13 ++++--------- PKHeX/Legality/Tables6.cs | 2 +- PKHeX/Legality/Tables7.cs | 9 ++------- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index 582240ff3..6bdab2726 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -991,7 +991,7 @@ private void verifyEggBallGen6() } if (0x0D <= pkm.Ball && pkm.Ball <= 0x0F) { - if (Legal.Ban_Gen4Ball.Contains(pkm.Species)) + if (Legal.Ban_Gen4Ball_6.Contains(pkm.Species)) AddLine(Severity.Invalid, "Unobtainable capture for Gen4 Ball.", CheckIdentifier.Ball); else AddLine(Severity.Valid, "Obtainable capture for Gen4 Ball.", CheckIdentifier.Ball); @@ -1087,15 +1087,10 @@ private void verifyEggBallGen7() return; } - if (0x0D <= pkm.Ball && pkm.Ball <= 0x0F) + if (0x0D <= pkm.Ball && pkm.Ball <= 0x0F) // Dusk Heal Quick { - if (Legal.Ban_Gen4Ball.Contains(pkm.Species)) - { - if (!Legal.Ban_Gen4Ball_AllowG7.Contains(pkm.Species)) - AddLine(Severity.Invalid, "Unobtainable capture for Gen4 Ball.", CheckIdentifier.Ball); - else - AddLine(Severity.Valid, "Obtainable capture for Gen4 Ball.", CheckIdentifier.Ball); - } + if (Legal.Ban_Gen4Ball_7.Contains(pkm.Species)) + AddLine(Severity.Invalid, "Unobtainable capture for Gen4 Ball.", CheckIdentifier.Ball); else AddLine(Severity.Valid, "Obtainable capture for Gen4 Ball.", CheckIdentifier.Ball); diff --git a/PKHeX/Legality/Tables6.cs b/PKHeX/Legality/Tables6.cs index dcd694a84..26dbe5ff2 100644 --- a/PKHeX/Legality/Tables6.cs +++ b/PKHeX/Legality/Tables6.cs @@ -682,7 +682,7 @@ public static partial class Legal 497, 500, 503, //3 566, 567, 696, 697, 698, 699 // Fossil Only obtain }; - internal static readonly int[] Ban_Gen4Ball = + internal static readonly int[] Ban_Gen4Ball_6 = { 152, 155, 158, //1 - Chikorita, Cyndaquil, Totodile 153, 156, 159, //2 diff --git a/PKHeX/Legality/Tables7.cs b/PKHeX/Legality/Tables7.cs index 5ac1c896a..b8e5320d4 100644 --- a/PKHeX/Legality/Tables7.cs +++ b/PKHeX/Legality/Tables7.cs @@ -434,14 +434,9 @@ public static partial class Legal 496, 499, 502, //2 497, 500, 503, //3 }; - internal static readonly int[] Ban_Gen4Ball_AllowG7 = + internal static readonly int[] Ban_Gen4Ball_7 = { - 152, 155, 158, //1 - Chikorita, Cyndaquil, Totodile - 153, 156, 159, //2 - 154, 157, 160, //3 - 495, 498, 501, //1 - Snivy, Tepig, Oshawott - 496, 499, 502, //2 - 497, 500, 503, //3 + 566, 567, 696, 697, 698, 699 // Fossil Only obtain }; internal static readonly int[] ZygardeMoves = From 1c599e8baa3572292ffa3e0dda38b93db0a375fb Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 29 Jan 2017 20:15:03 -0800 Subject: [PATCH 09/10] Update 170130 Fixed wc7 binary, added 6->7 transfer georegion (was missing). --- PKHeX/PKM/PK6.cs | 2 ++ PKHeX/Resources/byte/wc7.pkl | Bin 30096 -> 30096 bytes PKHeX/Resources/text/changelog.txt | 14 +++++++++++++- PKHeX/Resources/text/version.txt | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/PKHeX/PKM/PK6.cs b/PKHeX/PKM/PK6.cs index eaede7f40..a113f3130 100644 --- a/PKHeX/PKM/PK6.cs +++ b/PKHeX/PKM/PK6.cs @@ -627,6 +627,8 @@ public PK7 convertToPK7() pk7.Data[0xDE] = 0; /* Gen IV encounter type. */ pk7.TradeMemory(Bank: true); // oh no, memories on gen7 pkm + pk7.Geo1_Country = PKMConverter.Country; + pk7.Geo1_Region = PKMConverter.Region; // Fix Checksum pk7.RefreshChecksum(); diff --git a/PKHeX/Resources/byte/wc7.pkl b/PKHeX/Resources/byte/wc7.pkl index 8bb0915e39e6a9a47a8fdcf14fbcb7bf9722859e..38f7a111c0e19893aa5457f37b2b97768316e300 100644 GIT binary patch delta 18 acmbR6nsLHw#tkjZlX=V}H_v7MTnGS7EC7 transfer not applying geolocation data. Thanks RoC! + - Fixed: English Demo Greninja now is recognized correctly. + +17/01/28 - New Update: (23464) [241859] - Added: Gen6->Gen7 transfer logic and Gen1->Gen7 transfer logic. - - Note: Bank adds memories and geolocation data to all pk7 files it touches. - Legality: diff --git a/PKHeX/Resources/text/version.txt b/PKHeX/Resources/text/version.txt index 865f764c2..bf4c306cd 100644 --- a/PKHeX/Resources/text/version.txt +++ b/PKHeX/Resources/text/version.txt @@ -1 +1 @@ -20170128 \ No newline at end of file +20170130 \ No newline at end of file From 9c788d1c8a24c2b01dc88ed16ffbd36495265e3a Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 29 Jan 2017 21:41:42 -0800 Subject: [PATCH 10/10] Fix coins OverflowException cap to 9999 before casting Closes #775 Thanks @ThunderRemix --- PKHeX.WinForms/Subforms/Save Editors/SAV_SimpleTrainer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PKHeX.WinForms/Subforms/Save Editors/SAV_SimpleTrainer.cs b/PKHeX.WinForms/Subforms/Save Editors/SAV_SimpleTrainer.cs index b6f6cb251..96a0139d1 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/SAV_SimpleTrainer.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/SAV_SimpleTrainer.cs @@ -176,7 +176,7 @@ private void B_Save_Click(object sender, EventArgs e) if (SAV is SAV1) { SAV1 sav1 = (SAV1) SAV; - sav1.Coin = (ushort) Util.ToUInt32(MT_Coins.Text); + sav1.Coin = (ushort)Math.Max(Util.ToUInt32(MT_Coins.Text), 9999); sav1.Badges = badgeval & 0xFF; var pf = Util.ToUInt32(MT_PikaFriend.Text); @@ -193,7 +193,7 @@ private void B_Save_Click(object sender, EventArgs e) if (SAV is SAV2) { SAV2 sav2 = (SAV2)SAV; - sav2.Coin = (ushort)Util.ToUInt32(MT_Coins.Text); + sav2.Coin = (ushort)Math.Max(Util.ToUInt32(MT_Coins.Text), 9999); sav2.Badges = badgeval & 0xFFFF; sav2.BattleEffects = CHK_BattleEffects.Checked;