codemonkey85 / PKMDS-Blazor

PKMDS for Blazor (powered by PKHeX.Core)
https://www.pkmds.app/
The Unlicense
36 stars 5 forks source link

File is wiped upon export #13

Open Luna-Karch opened 5 months ago

Luna-Karch commented 5 months ago

Steps to reproduce

  1. Upload Pokémon White 2.dsv save file using google chrome at pkmds.app on an android phone

  2. Make any edit

  3. Hit save on your edits

  4. Export save file

  5. Move the save file to the correct location

  6. Try running the game via emulator

  7. Save file is wiped empty

codemonkey85 commented 4 months ago

Thanks for the report. Would you mind sharing your 'Pokémon White 2.dsv' save file so I can test with it?

Luna-Karch commented 4 months ago

Unfortunately I don't think I have it anymore, honestly didn't expect a reply, but I did supply my exact steps to replicate the problem, the save file must have been reset to be an empty one.

I moved it to replace the old save file, so the original was lost, and the new save started off with "New Game" at the top, and continue wasn't an option so I knew my progress had been lost.

Edit: If I find it, how would you like me to send it to you?

codemonkey85 commented 4 months ago

Edit: If I find it, how would you like me to send it to you?

You should be able to attach it to a comment in this thread.

Luna-Karch commented 4 months ago

I couldn't find it so I recreated the error with a new file, when attempting to open it with PKHeX it says it's unsupported

Edit: However, github doesn't support .dsv file attachments so I'll attach it as a zip instead

Luna-Karch commented 4 months ago

White_2.zip

After checking a hex viewer, it seems like it's full of FF for some reason except for the DeSmuME file footer which looks like this

image

codemonkey85 commented 4 months ago

Thank you for sharing. I will look into this.

Luna-Karch commented 3 months ago

Any updates?

codemonkey85 commented 3 months ago

Not yet. This is a hobby project, finding time to work on it is challenging.

Luna-Karch commented 3 months ago

Okay! Thanks regardless!

codemonkey85 commented 3 months ago

@Luna-Karch I started looking into this today. The save file you shared with me - is it the corrupted file? Can you share the original file you tried to load into PKMDS? That's the one I need to debug this issue.

Luna-Karch commented 3 months ago

The one I shared to you is the corrupted one yes. I would have to recreate the white 2.dsv file but I was able to reproduce the issue multiple times with any generic white 2.dsv

arleypadua commented 13 hours ago

I faced the same issue while developing a cross platform CLI

It turns out that PKHeX.Core doesn't know the format of the file unless you specifically tell it what the file name is (including the file extension)

So, whenever it loads up a Desmume save, it will strip out the Desmume specific footer.

Without the footer, it is a totally valid save file, but invalid for Desmume

When Desmume sees a save without the footer, it will wipe out the whole save adding the footer back.

I solved it by passing down the file path when loading the file:

https://github.com/arleypadua/PKHeX.CLI/blob/ee9d7ddbb9b681b1cd295b312cb72f4a67c89c6e/src/PKHeX.Facade/Game.cs#L27