Skip to content
This repository has been archived by the owner on Jan 16, 2020. It is now read-only.

Commit

Permalink
Fix pass-by-reference bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
SciresM committed May 3, 2016
1 parent 01afa09 commit 3b32296
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Rhydon/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,10 @@ private void InitializeFields()
{
TB_OT.Text = "Rhydon";
TB_Nickname.Text = "RHYDON";
TB_TID.Text = 12345.ToString();
pk1.OT_Name = RBY_Encoding.GetBytes(TB_OT.Text);
pk1.Nickname = RBY_Encoding.GetBytes(TB_Nickname.Text);
TB_TID.Text = 12345.ToString();
pk1.TID = 12345;
CB_PPu1.SelectedIndex = CB_PPu2.SelectedIndex = CB_PPu3.SelectedIndex = CB_PPu4.SelectedIndex = 0;
}
}
Expand Down
9 changes: 9 additions & 0 deletions Rhydon/PK1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ public PK1(byte[] d = null, string i = "")
}
}

public PK1 Clone()
{
PK1 new_pk1 = new PK1();
Array.Copy(Data, 0, new_pk1.Data, 0, Data.Length);
Array.Copy(otname, 0, new_pk1.otname, 0, otname.Length);
Array.Copy(nick, 0, new_pk1.nick, 0, nick.Length);
return new_pk1;
}

// Internal Attributes set on creation
public byte[] Data; // Raw Storage
public string Identifier; // User or Form Custom Attribute
Expand Down
2 changes: 1 addition & 1 deletion Rhydon/PokemonList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public PK1 this[int i]
set
{
if (value == null) return;
Pokemon[i] = value;
Pokemon[i] = value.Clone();
}
}

Expand Down

0 comments on commit 3b32296

Please sign in to comment.