kwsch / PKHeX

Pokémon Save File Editor
https://projectpokemon.org/pkhex/
Other
3.71k stars 698 forks source link

About the HGSS save corrupted when use PKHeX #4368

Open gingrentse opened 3 weeks ago

gingrentse commented 3 weeks ago

Hello, when I use the PKHeX to edit the Heart Gold data then save in PKHeX, I can access the save normally, then I saved in the game and reset the emulator, the game had blue screen and said the save was corrupted and returned to old save. I need to save in game again and fix the problem. I had save two times when use PkHex everytime. Anyone had seen this problem before?

Is this a bug for Load Boxes function in HGSS? The process of bug screen were attached for your reference, thanks.

  1. Normal save 1  Normal Save
  2. Edit to Ultra Ball & Export save 2  Edit to Ultra Ball   Export Save
  3. Found edited to Ultra Ball in HGSS 3  Found edited to Ultra Ball in HGSS
  4. Save in game successfully 4  Save in game successfully
  5. Save corrupted when re-open the game 5  Save Corrupted

Updated on 7/10/2024: I had opened a new game save and try to test the issue:

  1. In new game save, edit monsters in PC boxes
  2. Save in game
  3. Re-open the emulator and save have not corrupted
  4. Use PKHeX > Tools > Data > Load Boxes
  5. After use the Load Boxes function, edit monsters in PC boxes and save in game.
  6. Re-open the emulator, it found corrupted in new game save.
  7. Only found this issue in HGSS, PT and White 2 have not found.

After use Load Boxes, edit monsters in PC boxes, the new game save will corrupt. Load Boxes

Updated on 8/10/2024: I had used a new game save to test again, not only Load Boxes function, if I use PKHeX to move my party pokemon into boxes and export the save, the new game save also corrupt by save once. In addition, I found out that save in game TWICE then re-open the game can fix the issue.

PollyThePancake commented 1 week ago

I get this issue sometimes, but it should have an option to load a backup save and when you select yes it should load your edited save

gingrentse commented 1 week ago

I get this issue sometimes, but it should have an option to load a backup save and when you select yes it should load your edited save

I can load the edited save, but I saved once in game and the edited save will corrupted. The bug only issued in HGSS and I guess it had a checksum error when moved monster into boxes for use PKHeX (or move to other cells in boxes)

Lusamine commented 1 week ago

I was not able to replicate this in ENG HG or JPN SS following your instructions. I assumed "new save" meant "just created a new game and saved". Can you please upload examples of the following?

  1. A new save file before you did anything to it to cause the problem.
  2. A folder of example Pokémon you put in the save with "Load Boxes".
  3. A save file after you followed your own instructions, that you see is corrupted.

And the exact version of the emulator you are using, in case this is related.

gingrentse commented 6 days ago

I was not able to replicate this in ENG HG or JPN SS following your instructions. I assumed "new save" meant "just created a new game and saved". Can you please upload examples of the following?

  1. A new save file before you did anything to it to cause the problem.
  2. A folder of example Pokémon you put in the save with "Load Boxes".
  3. A save file after you followed your own instructions, that you see is corrupted.

And the exact version of the emulator you are using, in case this is related.

Thanks your reply. I have uploaded three saves for your questions.

  1. The new save (clean) had played a short time, I found out if I put the Pokémon to "Load Boxes" in game, save in game and edit the "Load Boxes" for use PKHeX, the save will not corrupted.
  2. If I put the Pokémon to "Load Boxes" for use PKHeX, save in game and edit the "Load Boxes" for use PKHeX, the save will corrupted.
  3. Emulator: DeSmuME_0.9.13_x64, Game: JPN HG, PKHeX: 24.07.27

HGSS (JPN) new game.zip

In addition, the old saves also uploaded as below:

The old save will corrupted if I edit the Pokémon into "Load Boxes" for use PKHeX and save in game.

HGSS (JPN) old game.zip

Lusamine commented 6 days ago

Can you please clarify what the highlighted part means? Are you not using the "Load Boxes" option?

image

image

gingrentse commented 6 days ago

Can you please clarify what the highlighted part means? Are you not using the "Load Boxes" option?

image

image

The save files is attached as below, thank you.

HGSS (JPN) Load Boxes.zip

Lusamine commented 6 days ago

I am trying to understand what buttons you pressed in PKHeX. I can't tell what you did by looking at the save files.

Can you use a program such as Screen2Gif to record what you did to the save file and upload it here? https://www.screentogif.com/

gingrentse commented 6 days ago

I am trying to understand what buttons you pressed in PKHeX. I can't tell what you did by looking at the save files.

Can you use a program such as Screen2Gif to record what you did to the save file and upload it here? https://www.screentogif.com/

Sorry for your waiting, I had record many times for less than 10MB file.

HG (JPN) Corrput- New game

Lusamine commented 6 days ago

Thank you, this is great! I will try it out too.

You can reduce the size of the recording window for smaller files.

gingrentse commented 6 days ago

Thank you, this is great! I will try it out too.

You can reduce the size of the recording window for smaller files.

Also I have upload the old save for edit Pokemon in PKHeX. Thanks your checking for HGSS version.

HG (JPN) Corrput- Old save

Lusamine commented 6 days ago

Your save corrupts when I put a Pokémon in a box. I don't have the same problem when I create a new game and add the same Pokémon to my own box.

I noticed your "new" save isn't a new save. It has 2 badges in it. At what point did you start editing your save file? What other edits did you make?

gingrentse commented 6 days ago

Your save corrupts when I make any edit to a Pokémon and put it in a box. I don't have the same problem when I create a new game and add the same Pokémon to my own box.

I noticed your "new" save isn't a new save. It has 2 badges in it. At what point did you start editing your save file? What other edits did you make?

Yes, I create a new game and add same Pokémon will not corrupt when save in game. If you move the monster from party to boxes then save in game, it will corrupt.

Lusamine commented 6 days ago

I did not move any Pokémon from the party. All I did was set the Zubat in Box 1 Slot 1 and it caused it to corrupt after a save.

Did you make any other edits before you put Pokémon in the box?

Lusamine commented 6 days ago

I was able to get my brand new save to corrupt like yours. This is what I did:

  1. I started with a brand new JPN SS save with 0 Pokemon in party and 0 Pokemon in box.
  2. I added 1 Pokemon to my party with PKHeX and exported the save.
  3. Booted the game, saved in-game, rebooted. It has no corruption.
  4. I added 1 Pokémon in Box 1 Slot 1 with PKHeX and exported the save.
  5. Booted the game, saved in-game, reboot. It now detects corruption.

I'm guessing that since your party has illegal Pokémon in it, you edited your party before you tried to put Pokémon in the box?

gingrentse commented 6 days ago

I did not move any Pokémon from the party. All I did was set the Zubat in Box 1 Slot 1 and it caused it to corrupt after a save.

Did you make any other edits before you put Pokémon in the box?

I have edited the Pokémon from party only.

gingrentse commented 6 days ago

I was able to get my brand new save to corrupt like yours. This is what I did:

  1. I started with a brand new JPN SS save with 0 Pokemon in party and 0 Pokemon in box.
  2. I added 1 Pokemon to my party with PKHeX and exported the save.
  3. Booted the game, saved in-game, rebooted. It has no corruption.
  4. I added 1 Pokémon in Box 1 Slot 1 with PKHeX and exported the save.
  5. Booted the game, saved in-game, reboot. It now detects corruption.

I'm guessing that since your party has illegal Pokémon in it, you edited your party before you tried to put Pokémon in the box?

I have try to move the legal Pokémon from party to boxes for use PKHeX, it will also corrupt if I save in game. I have try many times for other version, it only issued in HGSS, other version Platinum and White 2 are no problem. I think that this is HGSS originally game issue?

Lusamine commented 6 days ago

I have try to move the legal Pokémon from party to boxes for use PKHeX, it will also corrupt if I save in game. I have try many times for other version, it only issued in HGSS, other version Platinum and White 2 are no problem. I think that this is HGSS game issue?

This didn't cause the corruption for me:

These caused the corruption for me:

So I think the issue is happening if you use PKHeX to add anything into the box after receiving at least 1 Pokemon, but before you have put anything into the box in-game.

gingrentse commented 6 days ago

I have try to move the legal Pokémon from party to boxes for use PKHeX, it will also corrupt if I save in game. I have try many times for other version, it only issued in HGSS, other version Platinum and White 2 are no problem. I think that this is HGSS game issue?

This didn't cause the corruption for me:

  • With 0 Pokemon in party or boxes, use PKHeX to add a Pokémon in Box 1 Slot 1, save in-game, reboot.
  • Play until I can deposit a Pokémon in the box, then use PKHeX to add a Pokémon into party and another into box, save and reboot.

These caused the corruption for me:

  • Playing normally until I get my starter in party, then use PKHeX to put my starter in Box 1 Slot 1, save in-game, reboot.
  • Playing normally until I get my starter in party, then use PKHeX to put a copy of my starter in Box 1 Slot 1, save in-game, reboot.
  • Playing normally until I get my starter in party and catch a HootHoot, then use PKHeX to put any Pokémon in Box 1 Slot 1, save in-game, reboot.

So I think the issue is happening if you use PKHeX to add anything into the box after receiving at least 1 Pokemon, but before you have put anything into the box in-game.

Yes, it is exactly happened when I get the starter pokemon, then I move any pokemon (legal and illegal) into the box and save in game, the save will corrupt. Thank you for testing.

WonderSquid commented 6 days ago

for what it is worth, i've encountered this issue on and off for a few years including in saves that have many pokemon in the box and are very deep into the game, but have been unable to get it to trigger consistently. empty boxes definitely aren't a requirement, but moving pokemon from the box to the party and vice versa seems to have a higher chance of setting it off.

i suspect but can't prove it has something to do with how the game alternates banks due to how certain saves and save blocks are cut off (pokemon in corrupted files will either be missing from the party and boxes, or present in both the party and boxes, so clearly half the save didn't finish updating), and how saving twice out of paranoia (even in games that have hundreds of hours in them) generally helps prevent it. i will try to look into this more later.

gingrentse commented 6 days ago

for what it is worth, i've encountered this issue on and off for a few years including in saves that have many pokemon in the box and are very deep into the game, but have been unable to get it to trigger consistently. empty boxes definitely aren't a requirement, but moving pokemon from the box to the party and vice versa seems to have a higher chance of setting it off.

i suspect but can't prove it has something to do with how the game alternates banks due to how certain saves and save blocks are cut off (pokemon in corrupted files will either be missing from the party and boxes, or present in both the party and boxes, so clearly half the save didn't finish updating), and how saving twice out of paranoia (even in games that have hundreds of hours in them) generally helps prevent it. i will try to look into this more later.

I had checked If I saved once in game and opened PKHeX to verify the checksum, it said the save file “Large Block checksum is invalid”, and I try to move any monsters to other box cells, the save can work suddenly. There are some bugs for moving monsters from party to boxes, or from box cells to box cells. Thanks for look up.

Lusamine commented 5 days ago

for what it is worth, i've encountered this issue on and off for a few years including in saves that have many pokemon in the box and are very deep into the game, but have been unable to get it to trigger consistently. empty boxes definitely aren't a requirement, but moving pokemon from the box to the party and vice versa seems to have a higher chance of setting it off.

i suspect but can't prove it has something to do with how the game alternates banks due to how certain saves and save blocks are cut off (pokemon in corrupted files will either be missing from the party and boxes, or present in both the party and boxes, so clearly half the save didn't finish updating), and how saving twice out of paranoia (even in games that have hundreds of hours in them) generally helps prevent it. i will try to look into this more later.

If you can find consistent ways to get it to happen, which is what I was trying to do here to have the same problem as OP, it can be helpful for troubleshooting even if you don't know exactly why. This problem is already filled with people saying "Oh it happens randomly and in all these cases and I don't know why" which is a lot of noise and doesn't help much at all.

WonderSquid commented 5 days ago

Did some more testing to narrow it down and can now get it to trigger consistently.

If ANY edits are made to the contents of any box (does not matter what kind, legal, illegal, legit, change its nickname, whatever), and then you only save ONCE after loading the edited file regardless of how long afterwards, and then try to play the game after rebooting, the save file will break. PKHeX and the game will not keep any edits made to boxes, but edits made to the party WILL be preserved, even in the backup file the game loads, resulting in deleted or duplicated pokemon depending on the nature of the edits made. The only thing that does not set this off is using PKHeX to change which box is active, and absolutely nothing else.

Party edits are not affected one way or another, unless they result in a box edit (moving to/from boxes). Saving twice in-game after making box edits in PKHeX prevents the issue, and saves will load normally.

Lusamine commented 5 days ago

If ANY edits are made to the contents of any box (does not matter what kind, legal, illegal, legit, change its nickname, whatever), and then you only save ONCE after loading the edited file regardless of how long afterwards, and then try to play the game after rebooting, the save file will break. PKHeX and the game will not keep any edits made to boxes, but edits made to the party WILL be preserved, even in the backup file the game loads, resulting in deleted or duplicated pokemon depending on the nature of the edits made. The only thing that does not set this off is using PKHeX to change which box is active, and absolutely nothing else.

What kind of save did you test with? Were there any other edits prior to your testing? If you look at my tests, I wasn't able to get this to happen with a completely brand new save that had not received the starter (unless I messed with the party first), or with one that had just boxed its first Pokemon.

WonderSquid commented 5 days ago

I used .dsv files with DeSmuME and a .sav file on a HeartGold cartridge (was too lazy to test with SoulSilver though I've also experienced it on emulator and cartridge with SS as well). I used two postgame saves that had previous general edits made throughout the years I've had them, as well as a fresh game I started today. I was able to get the file to corrupt with a fresh game with no starter just by making a box edit.

Did you save three times before making the edit and then saving a fourth? If the game has any reason to do its "saving a lot of data" type save (you haven't touched the game in ages, there's been a lot of box data changed*, or if you are creating that backup save for the first time on your second save), then the file will save and load normally.

*I did not test this middle cause of "saving a lot of data" because it's been a busy evening but I did test the other two, and they both seem to prevent the game from corrupting itself the way it would normally.

Lusamine commented 5 days ago

Did you save three times before making the edit and then saving a fourth? If the game has any reason to do its "saving a lot of data" type save (you haven't touched the game in ages, there's been a lot of box data changed*, or if you are creating that backup save for the first time on your second save), then the file will save and load normally.

My saves were sequential and look like this:

  1. Made a new save, saved once, tried to put one mon in box and save ingame, no error. Same save if I put 1 mon in party and 1 mon in box, save ingame, causes the error.
  2. Took the previous save before editing until I got Cyndaquil, then saved after. Putting a mon in the box with PKHeX, then saving ingame causes the error.
  3. Took the previous save before editing until I caught a Hoothoot, then saved after. Putting a mon in the box with PKHeX, then saving ingame causes the error.
  4. Took the previous save before editing until I could box my Cyndaquil, then saved after. Putting a mon in the box with PKHeX, then saving ingame causes no error.

I'm trying to determine the least amount of editing required to cause it and unfortunately with "used" saves, it's hard to tell what else has been done to them that may contribute.