kwsch / PKHeX

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

Trainer Name/Pokemon OT Mismatch w/ Symbols in Name #3172

Closed SYZekrom closed 3 years ago

SYZekrom commented 3 years ago

Describe the bug If a Pokemon with an OT who has symbols such as hearts or music notes in their names is edited in PKHex, OT's symbols will be different, causing the Pokemon to be recognized as a traded Pokemon (Apparently met, boosted EXP). PKHex will not recognize differences in these names. This happened in Platinum on melonDS.

To Reproduce Steps to reproduce the behavior:

  1. Load a sav in Platinum with a trainer with symbols in their name. My used name appears as Faye⑱⑹⑿ in the program in all instances.
  2. Drag a caught Pokemon to the left, edit anything and drag it back into a box or party. In my case I edited the level of the Pokemon.
  3. There is no change in the OT seen in the program, but the heart and music note appear to be a different character in the game, they are both wider than the original name.

Screenshots How the OT appears in-game from a Pokemon placed into PKHex. https://cdn.discordapp.com/attachments/367479180398428170/818301066180427797/unknown.png

Pokemon that were untouched. https://cdn.discordapp.com/attachments/367479180398428170/818301078813540362/unknown.png

Atrius97 commented 3 years ago

I was also able to reproduce this issue on retail, (my cousin had the same heart character shown in SYZekrom's screenshots in her OT as well), and checking via hex editor it appears PKHeX is indeed changing the character when viewed in the editor, example PK4's before and after provided below:

Example PK4s with ⑱ character in OT.zip

kwsch commented 3 years ago

Gen4's string conversion has duplicate Code->Glyph mappings.

https://github.com/kwsch/PKHeX/blob/7b163147ef518e10b131f36da135ea9f0cdb727d/PKHeX.Core/PKM/Strings/StringConverter4.cs#L603-L606

Here's a list of the problematic half/full-width codes:

z | 00DF 00F5
⑯ | 00FA 01C6
⑰ | 00FB 01C7
⑱ | 00FC 01C8
⑲ | 00FD 01C9
⑳ | 00FE 01CA
⑴ | 00FF 01CB
⑵ | 0100 01CC
⑶ | 0101 01CD
⑷ | 0102 01CE
⑸ | 0103 01CF
⑹ | 0105 01D1
⑺ | 0107 01D3
⑻ | 0108 01D4
⑽ | 0109 01D6

The table originates from the Gen4->5 translation table (noted here, originally implemented back with pk2pk in mid 2014).

Notes: F5 should be the wavy symbol (?) 0x1C6 are all the half-width variants of the special glyphs.