Jump to content

Did i make a mistake storing PKM raw storage data ?


Recommended Posts

Posted

I'm using PKHeX.Core inside of a (closed) community PokéBank-like project, I didn't figure out yet what every little line of code does inside PKHeX (I must admit that it is a pretty big project), yet the bank seemed to work enough to "release it", and is holding right now a few thousands of mons, all supposed to be 100% legit. (Some of them don't even have backups even if I told everyone to do so)

But, I just figured out that my pokemon file size for .pk6 files was 260, when using the save pokemon button inside PKHeX creates a file which size is 232.

Since the beginning i was creating the files and writing the content of (byte[]) PKHeX.Core.PKM.Data inside those, while PKHeX seems to prefer writing the EncryptedBoxData or DecryptedBoxData . Is there any chance, by doing so, that I modified any of the data of those pokemons, or might have caused some issues later on that will occur during the re import of those pokemon files inside save files ? From my tests and thoughts, it seems I didn't, but I prefer to make sure and ask professionals , because if I did, I must prepare myself to get slain / run away to Mexico. 

Please Halp. (Thanks for reading)

 

Posted

When pkm are stored in the box, their party stats are discarded in order to save space. Only 232 bytes are needed, the rest can be recreated on demand. When they are in party format, they have an extra 28 bytes at the end of the array to store party stats (current hp, stats, status affliction, etc).

EncryptedBoxData is the format a pkm is in when it does not have party stats and is encrypted.

DecryptedBoxData is the above format, without the encryption (easy to reference in a hex editor).

EncryptedPartyData is the format... when it has battle stats and is currently encrypted.

DecryptedPartyData is the format when it has battle stats and is decrypted.

 

Easiest to save pkm files it in the Decrypted Box format (232), since the party stats are negligible and in bulk they consume space. Decrypted because you don't need the encryption.

 

When PKHeX handles a PKM, it keeps it in the Decrypted Party format (260) so that if stats are required for logic, the array is ready to go.

  • Like 2
Posted

Thanks a lot for making things clear, phew ! And on top of that, i can take 3 KB of data back from this zigzagoon folder !

From the quality of the things i can understand while reading those lines of code, I had the feeling it was all okay. But every time I play with numbers in a project that includes bit shifting, byte arrays, encryption, and conversion, I can't stop myself from having goosebumps.

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...