From 9de36d038f47f3b00212b341fb8a1e2a13f099cd Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 20 Oct 2015 07:39:30 -0700 Subject: [PATCH] Fix saving altered trainers Saving with no Pokemon will default to 1. A different amount of Pokemon will require a new skeleton to be filled in with the entered data, instead of not having anything allocated to hold the data. --- pk3DS/Subforms/RSTE.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pk3DS/Subforms/RSTE.cs b/pk3DS/Subforms/RSTE.cs index b30f8b0..04b0fa3 100644 --- a/pk3DS/Subforms/RSTE.cs +++ b/pk3DS/Subforms/RSTE.cs @@ -361,6 +361,8 @@ private void writeFile() tr.Class = CB_Trainer_Class.SelectedIndex; tr.BattleType = (byte)CB_Battle_Type.SelectedIndex; tr.NumPokemon = (byte)CB_numPokemon.SelectedIndex; + if (tr.NumPokemon == 0) + tr.NumPokemon = 1; // No empty teams! tr.Items[0] = (ushort)CB_Item_1.SelectedIndex; tr.Items[1] = (ushort)CB_Item_2.SelectedIndex; tr.Items[2] = (ushort)CB_Item_3.SelectedIndex; @@ -371,8 +373,11 @@ private void writeFile() tr.Prize = (ushort)CB_Prize.SelectedIndex; // Set Pokemon Data + Array.Resize(ref tr.Team, tr.NumPokemon); for (int i = 0; i < tr.NumPokemon; i++) { + if (tr.Team[i] == null) + tr.Team[i] = new Trainer.Pokemon(new byte[100], false, false); // Initialize with zeroes tr.Team[i].IVs = (byte)trpk_IV[i].SelectedIndex; tr.Team[i].Ability = trpk_abil[i].SelectedIndex; tr.Team[i].Gender = trpk_gender[i].SelectedIndex;