kwsch / PKHeX

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

Quicksave area sometimes showing pokémon as invalid even when it's shown as valid elsewhere #3416

Closed BtEtta closed 2 years ago

BtEtta commented 2 years ago

Describe the problem Sometimes when viewing a pokémon the quicksave area will show as invalid even though there is no invalid mark in the box viewer

To Reproduce

  1. Create a blank PLA save and import the two attached pokémon
  2. View 1417C0AEC90C — the quicksave box will correctly show as valid
  3. View D121164E98F1 — the quicksave box will show as invalid (Invalid: Calculated Height does not match stored value.)
  4. Without viewing any other pokémon select view on D121164E98F1 again — the quicksave box will now show valid

Expected behavior Quicksave box should show as valid in all above circumstances.

Screenshots 1417C0AEC90C D121164E98F1

712 - Bergmite - 1417C0AEC90C.zip 712 - Bergmite - D121164E98F1.zip

kwsch commented 2 years ago

https://projectpokemon.org/home/forums/topic/48524-cp-height-weight-calculations/

.NET Framework's float calculations do not match the results stored in the data; the framework doesn't read/write the value correctly.

It calculates closer on the NET6 build, but still isn't exact; however, it's within the legality check's tolerances (off by 3 lowest bits max).

NET6:
obj.HeightAbsolute.ToString("F8") = "100.86275482"
obj.CalcHeightAbsolute.ToString("F8") = "100.86273956"

NET4.6:
obj.HeightAbsolute.ToString("F8") = "100.86280000"
obj.CalcHeightAbsolute.ToString("F8") = "100.86270000"

Emulating the Switch's floating point calculations & representations would be required for accurate calculations, but that has not been implemented (even 3 years later). No estimate of if/when accuracy will be available, hence the current behavior as-is.

kwsch commented 2 years ago

Ha, I've figured something out ;)

kwsch commented 2 years ago

Fixed by https://github.com/kwsch/PKHeX/pull/3417