From 4d17ab83b44b4bcc1cb04707c6702b890cd35f9c Mon Sep 17 00:00:00 2001 From: June Hanabi Date: Mon, 25 Feb 2019 12:25:10 -0500 Subject: [PATCH] Important update which fixes mishandling of Pokemon species lists --- package.json | 2 +- src/app/data/savefile-expanded/fragments/PokemonBox.ts | 7 +++++++ src/app/data/savefile-expanded/fragments/PokemonParty.ts | 2 ++ src/app/data/savefile-expanded/sections/Daycare.ts | 2 +- .../savefile-expanded/sections/Player/PlayerPokemon.ts | 9 +++++++++ src/app/data/savefile-expanded/sections/Storage.ts | 8 ++++++++ 6 files changed, 28 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3f5079b..98cbfa0 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/app/data/savefile-expanded/fragments/PokemonBox.ts b/src/app/data/savefile-expanded/fragments/PokemonBox.ts index 613ce96..94f6cd2 100644 --- a/src/app/data/savefile-expanded/fragments/PokemonBox.ts +++ b/src/app/data/savefile-expanded/fragments/PokemonBox.ts @@ -131,6 +131,7 @@ export class PokemonBox { public save(saveFile: SaveFileService, startOffset: number, + speciesStartOffset: number | null, nicknameStartOffset: number, otNameStartOffset: number, index: number, @@ -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); diff --git a/src/app/data/savefile-expanded/fragments/PokemonParty.ts b/src/app/data/savefile-expanded/fragments/PokemonParty.ts index 3ac85b8..45d87a1 100644 --- a/src/app/data/savefile-expanded/fragments/PokemonParty.ts +++ b/src/app/data/savefile-expanded/fragments/PokemonParty.ts @@ -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, diff --git a/src/app/data/savefile-expanded/sections/Daycare.ts b/src/app/data/savefile-expanded/sections/Daycare.ts index 711f15b..dedbb76 100644 --- a/src/app/data/savefile-expanded/sections/Daycare.ts +++ b/src/app/data/savefile-expanded/sections/Daycare.ts @@ -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); } /** diff --git a/src/app/data/savefile-expanded/sections/Player/PlayerPokemon.ts b/src/app/data/savefile-expanded/sections/Player/PlayerPokemon.ts index a338864..9f3f7be 100644 --- a/src/app/data/savefile-expanded/sections/Player/PlayerPokemon.ts +++ b/src/app/data/savefile-expanded/sections/Player/PlayerPokemon.ts @@ -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[] = []; diff --git a/src/app/data/savefile-expanded/sections/Storage.ts b/src/app/data/savefile-expanded/sections/Storage.ts index b542053..b7e5712 100644 --- a/src/app/data/savefile-expanded/sections/Storage.ts +++ b/src/app/data/savefile-expanded/sections/Storage.ts @@ -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) {