kwsch / PKHeX

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

Sorting, Mass Sorting, and Batch Editing existing Pokemon changes Trainer Data values. #2859

Closed Atrius97 closed 4 years ago

Atrius97 commented 4 years ago

Describe the bug I'm having an issue with the latest version of PKHeX, (Stable v20.04.14, and Bleeding Edge v20.4.15+102 as of writing, this bug appears to occur in both versions)

Sorting, (or holding Shift while sorting boxes causing a mass sort for all boxes) seems to unintentionally change a number of Trainer Data values, drastically increasing the values: egg_hatching, capture_wild, total_capture, trade, and wild_pokemon_encountered.

Update: This issue may also potentially affect the values "CaughtPokemon" and "ShinyPokemonFound" in the "*Object TrainerCard" section of the Block Data, which appears on your savefile's League Card.

I believe PKHeX is somehow treating sorting the boxes as brand new encounters (pokemon caught/encountered values) and also new "trades" for pokemon that do not share my save's OT and IDs, regardless if their origin was in-game trade, trade, event, or transfered via Pokemon Home.

I am not sure if this type of issue occurs in pre-Gen 8 savefiles, or what equivalent values would be affected if it does occur.

Update: It appears that virtually any use of the Batch Editor to modify Pokemon also triggers this issue, treating all modified Pokemon as "new encounters" for their respective OT/ID combos/encounter methods.

To Reproduce Steps to reproduce the behavior:

  1. Open a Sword or Shield savefile (that has at least progressed to a point it has obtained several Pokemon via various different methods, Max raids, wild encounters, trades, etc.) in PKHeX.
  2. Under SAV > Trainer Data > Stats, view any of the values "egg_hatching, capture_wild, total_capture, trade, or wild_pokemon_encountered" and note the value.
  3. Click on Box > Sort Boxes > Pokedex No., while holding Shift.
  4. Click Yes on the "Sort ALL Boxes?!" prompt.
  5. Repeat step 2, the value(s) you viewed will now be much higher as a result.

Alternatively, repeat steps 1 and 2 and then: 4: Use the batch editor to change any value for all Pokemon in every box. 5: Repeat step 2, the value(s) you viewed will now be much higher as a result.

Expected behavior These values should remain the same when simply sorting or editing existing pokemon, but change to properly reflect the creation/import of new Pokemon to the savefile, to preserve sanity checks.

Screenshots An example, after sorting a full SWSH living dex into National Dex no. order: before PNG 353962d0d532f8d17a4e0043125a3d64 1202079237_sortingallbynumber PNG cc80d8d252e2c3e449184b2564cce437 after PNG 0f8121c41345149c036a845c291d3fba

kwsch commented 4 years ago

This was fixed the day after the last release; commit here: https://github.com/kwsch/PKHeX/commit/8936c584173aacedbaac1734355a1eb2996d736e

The AddCountAcquired in SAV8 is never called (or SetPKM, or AddRecord, etc) when doing the replication steps that you've listed.