From 1aa77e2c9bdedc33d91ebeccfc30bcff960e92d5 Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 18 Mar 2015 20:45:06 -0700 Subject: [PATCH] Set Import Fixes & Trash Byte Fix Set will now import gender and set nickname properly, also will now import Showdown's stat descriptions. Latest OT will now write only enough bytes and won't overwrite any previous names, leading to trash bytes. Fun. --- Misc/PKX.cs | 2 +- PKX/f1-Main.cs | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Misc/PKX.cs b/Misc/PKX.cs index efc9d2d7d..12036963d 100644 --- a/Misc/PKX.cs +++ b/Misc/PKX.cs @@ -1647,7 +1647,7 @@ public Set(string input, string[] species, string[] items, string[] natures, str case "EVs": { // Get EV list String - string[] evlist = brokenline[1].Split(new[] { " / ", " " }, StringSplitOptions.None); + string[] evlist = brokenline[1].Replace("SAtk", "SpA").Replace("SDef", "SpD").Replace("Spd", "Spe").Split(new[] { " / ", " " }, StringSplitOptions.None); for (int i = 0; i < evlist.Length / 2; i++) EVs[Array.IndexOf(stats, evlist[1 + i * 2])] = (byte)Util.ToInt32(evlist[0 + 2 * i]); break; diff --git a/PKX/f1-Main.cs b/PKX/f1-Main.cs index 4c3811712..1dc746c93 100644 --- a/PKX/f1-Main.cs +++ b/PKX/f1-Main.cs @@ -2086,8 +2086,11 @@ private void getShowdownSet() // Set Species & Nickname CB_Species.SelectedValue = Set.Species; - CHK_Nicknamed.Checked = false; - if (Set.Nickname != null) TB_Nickname.Text = Set.Nickname; + CHK_Nicknamed.Checked = (Set.Nickname != null); + if (Set.Nickname != null) + TB_Nickname.Text = Set.Nickname; + if (Set.Gender != null && PKX.getGender(Label_Gender.Text) != 2 && PKX.getGender(Set.Gender) != 2) + Label_Gender.Text = Set.Gender; // Set Form string[] formStrings = PKX.getFormList(Set.Species, @@ -2318,14 +2321,14 @@ private byte[] preparepkx(bool click = true) Array.Copy(BitConverter.GetBytes(IV32), 0, pkx, 0x74, 4); // Copy in IVs // Block C - // Convert OTT2 field back to bytes - byte[] OT2 = Encoding.Unicode.GetBytes(TB_OTt2.Text.Replace("\u0027", "\u2019")); - Array.Resize(ref OT2, 24); + // Convert Latest OT field back to bytes + byte[] OT2 = Encoding.Unicode.GetBytes(Util.TrimFromZero(TB_OTt2.Text).Replace("\u0027", "\u2019")); + Array.Resize(ref OT2, OT2.Length + 2); // Allow Trash Array.Copy(OT2, 0, pkx, 0x78, OT2.Length); - //0x90-0xAF + // 0x90-0xAF pkx[0x92] = Convert.ToByte(PKX.getGender(Label_CTGender.Text) == 1); - //Plus more, set by MemoryAmie (already in buff) + // Plus more, set by MemoryAmie (already in buff) // Block D // Convert OT field back to bytes