From 5b2e2e44e647ec5001c1e3164fbfeecfe01827a5 Mon Sep 17 00:00:00 2001 From: Miguel Terol Espino Date: Thu, 15 Jun 2023 18:46:04 +0200 Subject: [PATCH] Fixes #21 --- DS_Map/Main Window.cs | 2 -- DS_Map/ROMFiles/TrainerFile.cs | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/DS_Map/Main Window.cs b/DS_Map/Main Window.cs index 8331fca..9f957b9 100644 --- a/DS_Map/Main Window.cs +++ b/DS_Map/Main Window.cs @@ -8693,7 +8693,6 @@ namespace DSPRE { string[] trNames = RomInfo.GetSimpleTrainerNames(); bool error = currentIndex >= trNames.Length; - currentTrainerFile = new TrainerFile( new TrainerProperties( (ushort)trainerComboBox.SelectedIndex, @@ -8702,7 +8701,6 @@ namespace DSPRE { new FileStream(RomInfo.gameDirs[DirNames.trainerParty].unpackedDir + suffix, FileMode.Open), error ? TrainerFile.NAME_NOT_FOUND : trNames[currentIndex] ); - RefreshTrainerPartyGUI(); RefreshTrainerPropertiesGUI(); diff --git a/DS_Map/ROMFiles/TrainerFile.cs b/DS_Map/ROMFiles/TrainerFile.cs index 9e4a400..8c9c00e 100644 --- a/DS_Map/ROMFiles/TrainerFile.cs +++ b/DS_Map/ROMFiles/TrainerFile.cs @@ -3,6 +3,7 @@ using System; using System.Collections; using System.IO; using System.Windows.Forms; +using static DSPRE.DSUtils.ARM9; namespace DSPRE.ROMFiles { public class PartyPokemon : RomFile { @@ -36,6 +37,15 @@ namespace DSPRE.ROMFiles { this.heldItem = heldItem; this.moves = moves; } + public PartyPokemon(ushort difficulty, ushort Level, ushort pokeNum, ushort? heldItem = null, ushort[] moves = null) + { + // Simply adding a new constructor for Diamond and Pearl since they dont have ball seal config + pokeID = pokeNum; + level = Level; + this.difficulty = difficulty; + this.heldItem = heldItem; + this.moves = moves; + } public PartyPokemon(ushort difficulty, ushort Level, ushort pokeNum, ushort formNum, ushort ballSealConfig, ushort? heldItem = null, ushort[] moves = null) : this(difficulty, Level, pokeNum, ballSealConfig, heldItem, moves) { @@ -57,7 +67,8 @@ namespace DSPRE.ROMFiles { writer.Write(move); } } - writer.Write(ballSeals); + if(RomInfo.gameFamily == RomInfo.gFamEnum.HGSS || RomInfo.gameFamily == RomInfo.gFamEnum.Plat) + writer.Write(ballSeals); // Diamond and Pearl apparently dont save ball capsule data in enemy trainer pokedata!!! } return newData.ToArray(); } @@ -224,8 +235,11 @@ namespace DSPRE.ROMFiles { moves[m] = (ushort)(val == ushort.MaxValue ? 0 : val); } } + if (RomInfo.gameFamily == RomInfo.gFamEnum.HGSS || RomInfo.gameFamily == RomInfo.gFamEnum.Plat) + content[i] = new PartyPokemon(unknown1, level, pokemon, form_no, reader.ReadUInt16(), heldItem, moves); + else + content[i] = new PartyPokemon(unknown1, level, pokemon, form_no, heldItem, moves); // Diamond and Pearl apparently dont save ball capsule data in enemy trainer pokedata!!! - content[i] = new PartyPokemon(unknown1, level, pokemon, form_no, reader.ReadUInt16(), heldItem, moves); } for (int i = endval; i < maxPoke; i++) { content[i] = new PartyPokemon();