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.
This commit is contained in:
Kurt 2015-03-18 20:45:06 -07:00
parent 0839f1b43c
commit 1aa77e2c9b
2 changed files with 11 additions and 8 deletions

View File

@ -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;

View File

@ -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