Skip to content

Commit

Permalink
Important update which fixes mishandling of Pokemon species lists
Browse files Browse the repository at this point in the history
  • Loading branch information
junebug12851 committed Feb 25, 2019
1 parent bb4d501 commit 4d17ab8
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pokered-save-editor",
"productName": "Pokered Save Editor",
"description": "Pokemon Red/Blue Save Editor",
"version": "1.3.0",
"version": "1.3.1",
"repository": {
"type": "git",
"url": "https://github.com/junebug12851/pokered-save-editor.git"
Expand Down
7 changes: 7 additions & 0 deletions src/app/data/savefile-expanded/fragments/PokemonBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export class PokemonBox {

public save(saveFile: SaveFileService,
startOffset: number,
speciesStartOffset: number | null,
nicknameStartOffset: number,
otNameStartOffset: number,
index: number,
Expand All @@ -142,6 +143,12 @@ export class PokemonBox {
const otNameOffset = (index * 0xB) + otNameStartOffset;
const nicknameOffset = (index * 0xB) + nicknameStartOffset;

// Add species to species list if exists
if(speciesStartOffset !== null) {
const speciesOffset = index + speciesStartOffset;
saveFile.setByte(speciesOffset, this.species);
}

// Re-save back
it.setByte(this.species);
it.setWord(this.hp);
Expand Down
2 changes: 2 additions & 0 deletions src/app/data/savefile-expanded/fragments/PokemonParty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ export class PokemonParty extends PokemonBox {

public save(saveFile: SaveFileService,
offset: number,
speciesStartOffset: number | null,
nicknameStartOffset: number,
otNameStartOffset: number,
index: number): SaveFileIterator {

const it: SaveFileIterator = super.save(saveFile,
offset,
speciesStartOffset,
nicknameStartOffset,
otNameStartOffset,
index,
Expand Down
2 changes: 1 addition & 1 deletion src/app/data/savefile-expanded/sections/Daycare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class Daycare {
public save(saveFile: SaveFileService) {
saveFile.setByte(0x2CF4, (this.dayCare != null) ? 1 : 0);
if (this.dayCare != null)
this.dayCare.save(saveFile, 0x2D0B, 0x2CF5, 0x2D00, 0);
this.dayCare.save(saveFile, 0x2D0B, null, 0x2CF5, 0x2D00, 0);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,25 @@ export class PlayerPokemon {
}

public save(saveFile: SaveFileService) {
// Set party length and save current party data
saveFile.setByte(0x2F2C, this.playerParty.length);
for (let i = 0; i < this.playerParty.length && i < 6; i++) {
this.playerParty[i].save(
saveFile,
0x2F34,
0x2F2D,
0x307E,
0x303C,
i
)
}

// Mark end of species list if not full party
if(this.playerParty.length >= 6)
return;

let speciesOffset = 0x2F2D + this.playerParty.length;
saveFile.setByte(speciesOffset, 0xFF);
}

public playerParty: PokemonParty[] = [];
Expand Down
8 changes: 8 additions & 0 deletions src/app/data/savefile-expanded/sections/Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,19 @@ export class Storage {
this.pokemonBoxes[boxInd][i].save(
saveFile,
boxOffset + 0x16,
boxOffset + 0x1,
boxOffset + 0x386,
boxOffset + 0x2AA,
i
);
}

// Mark end of species list if not full box
if(this.pokemonBoxes[boxInd].length >= 20)
return;

let speciesOffset = boxOffset + 1 + this.pokemonBoxes[boxInd].length;
saveFile.setByte(speciesOffset, 0xFF);
}

saveBoxes(saveFile: SaveFileService, boxesOffset: number, boxSet: number) {
Expand Down

0 comments on commit 4d17ab8

Please sign in to comment.