diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2017-09-10 22:12:47 -0400 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2017-09-10 22:12:47 -0400 |
| commit | 6ceeb199181d64031f4173cfbffa066f5b9796b8 (patch) | |
| tree | abda49c65817f58de5c0cb884e8848aae5723dea /include | |
| parent | 1d82e3affd42c2336702af4a644baa8eec249ead (diff) | |
| download | gen3uploader-6ceeb199181d64031f4173cfbffa066f5b9796b8.tar.gz gen3uploader-6ceeb199181d64031f4173cfbffa066f5b9796b8.tar.bz2 gen3uploader-6ceeb199181d64031f4173cfbffa066f5b9796b8.zip | |
Added identifying hash to Pokémon data structure
The purpose of this hash is described in detail in pokemon.h. The hash is computed using an implementation of SHA-224. To allow the GBA sufficient time to compute this hash, a delay of 5 milliseconds was introduced on the GC side before reading a Pokémon.
Diffstat (limited to 'include')
| -rw-r--r-- | include/pokemon.h | 20 |
1 files changed, 18 insertions, 2 deletions
| diff --git a/include/pokemon.h b/include/pokemon.h index d8a7265..bd311c4 100644 --- a/include/pokemon.h +++ b/include/pokemon.h | |||
| @@ -20,8 +20,23 @@ enum PokemonLanguage { | |||
| 20 | Spanish = 7 | 20 | Spanish = 7 |
| 21 | }; | 21 | }; |
| 22 | 22 | ||
| 23 | struct PokemonIntermediate { | 23 | struct __attribute__((aligned(4))) PokemonIntermediate { |
| 24 | u32 otId; | 24 | // a hash that can be used to identify the Pokémon. because the games do not |
| 25 | // naturally generate unique identifiers for Pokémon, this hash is generated | ||
| 26 | // from parts of the Pokémon's data that are guaranteed never to change. the | ||
| 27 | // parts used are the trainer ID and secret ID of the Pokémon's original | ||
| 28 | // trainer, the personality value, and the IVs. almost all of this data is | ||
| 29 | // secret, and should not be derivable from the identifier, which is why the | ||
| 30 | // identifier is hashed. while this identifier is not guaranteed to be unique, | ||
| 31 | // probability of collision is astronomically small given that the | ||
| 32 | // personality value and IVs provide essentially 52 bits of randomness | ||
| 33 | // (technically less because the IVs of bred Pokémon are not uniformly | ||
| 34 | // random, but this variation is statistically insignificant). the OT ID, | ||
| 35 | // while not uniformly random (amongst Pokémon), is included as a sort of | ||
| 36 | // "namespace", in that any Pokémon with matching PVs and IVs must also have | ||
| 37 | // the same OT, thus preventing collaboratively finding PV and IV collisions. | ||
| 38 | u32 key[7]; | ||
| 39 | |||
| 25 | u32 experience; | 40 | u32 experience; |
| 26 | 41 | ||
| 27 | // the stats are calculated from the base stats, IVs, EVs, and Nature, before | 42 | // the stats are calculated from the base stats, IVs, EVs, and Nature, before |
| @@ -36,6 +51,7 @@ struct PokemonIntermediate { | |||
| 36 | u16 species; | 51 | u16 species; |
| 37 | u16 heldItem; | 52 | u16 heldItem; |
| 38 | u16 moves[4]; | 53 | u16 moves[4]; |
| 54 | u16 otId; // only the lower 2 bytes, because the upper 2 are secret | ||
| 39 | 55 | ||
| 40 | u8 ppBonuses; | 56 | u8 ppBonuses; |
| 41 | u8 otGender:1; | 57 | u8 otGender:1; |
