Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Mixone-FinallyHere authored and AdAstra-LD committed Jul 18, 2023
1 parent 7b9d9ac commit 5b2e2e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 0 additions & 2 deletions DS_Map/Main Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8693,7 +8693,6 @@ private void trainerComboBox_SelectedIndexChanged(object sender, EventArgs e) {
string[] trNames = RomInfo.GetSimpleTrainerNames();

bool error = currentIndex >= trNames.Length;

currentTrainerFile = new TrainerFile(
new TrainerProperties(
(ushort)trainerComboBox.SelectedIndex,
Expand All @@ -8702,7 +8701,6 @@ private void trainerComboBox_SelectedIndexChanged(object sender, EventArgs e) {
new FileStream(RomInfo.gameDirs[DirNames.trainerParty].unpackedDir + suffix, FileMode.Open),
error ? TrainerFile.NAME_NOT_FOUND : trNames[currentIndex]
);

RefreshTrainerPartyGUI();
RefreshTrainerPropertiesGUI();

Expand Down
18 changes: 16 additions & 2 deletions DS_Map/ROMFiles/TrainerFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections;
using System.IO;
using System.Windows.Forms;
using static DSPRE.DSUtils.ARM9;

namespace DSPRE.ROMFiles {
public class PartyPokemon : RomFile {
Expand Down Expand Up @@ -36,6 +37,15 @@ public PartyPokemon(ushort difficulty, ushort Level, ushort pokeNum, ushort ball
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) {

Expand All @@ -57,7 +67,8 @@ public override byte[] ToByteArray() {
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();
}
Expand Down Expand Up @@ -224,8 +235,11 @@ public Party(bool readFirstByte, int maxPoke, Stream partyData, TrainerPropertie
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();
Expand Down

0 comments on commit 5b2e2e4

Please sign in to comment.