diff options
Diffstat (limited to 'gba/source/serialize.c')
-rw-r--r-- | gba/source/serialize.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/gba/source/serialize.c b/gba/source/serialize.c index c5e8570..ddd3ef2 100644 --- a/gba/source/serialize.c +++ b/gba/source/serialize.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include "basestats.h" | 10 | #include "basestats.h" |
11 | #include "exptables.h" | 11 | #include "exptables.h" |
12 | #include "dexorder.h" | 12 | #include "dexorder.h" |
13 | #include "sha2.h" | ||
13 | 14 | ||
14 | u32 CalculateStat( | 15 | u32 CalculateStat( |
15 | u8 base, | 16 | u8 base, |
@@ -51,6 +52,16 @@ void PokemonIntermediateInit( | |||
51 | struct PokemonSubstruct2* sub2 = GetBoxPokemonSubstruct2(bpkm); | 52 | struct PokemonSubstruct2* sub2 = GetBoxPokemonSubstruct2(bpkm); |
52 | struct PokemonSubstruct3* sub3 = GetBoxPokemonSubstruct3(bpkm); | 53 | struct PokemonSubstruct3* sub3 = GetBoxPokemonSubstruct3(bpkm); |
53 | 54 | ||
55 | u32 identifier[3]; | ||
56 | identifier[0] = bpkm->otId; // original trainer | ||
57 | identifier[1] = bpkm->personality; // personality value | ||
58 | identifier[2] = ((const u32*)sub3)[1]; // IVs (plus two non-random bits) | ||
59 | |||
60 | sha224( | ||
61 | (const unsigned char*)identifier, | ||
62 | 12, | ||
63 | (unsigned char*)pki->key); | ||
64 | |||
54 | const struct SmallBaseStats* baseStats = BaseStatsForSpecies(sub0->species); | 65 | const struct SmallBaseStats* baseStats = BaseStatsForSpecies(sub0->species); |
55 | 66 | ||
56 | for (int i=0; i<POKEMON_NAME_LENGTH; i++) | 67 | for (int i=0; i<POKEMON_NAME_LENGTH; i++) |
@@ -63,7 +74,7 @@ void PokemonIntermediateInit( | |||
63 | pki->otName[i] = bpkm->otName[i]; | 74 | pki->otName[i] = bpkm->otName[i]; |
64 | } | 75 | } |
65 | 76 | ||
66 | pki->otId = bpkm->otId; | 77 | pki->otId = bpkm->otId & 0x0000FFFF; |
67 | pki->otGender = sub3->otGender; | 78 | pki->otGender = sub3->otGender; |
68 | pki->species = gSpeciesToNationalPokedexNum[sub0->species - 1]; | 79 | pki->species = gSpeciesToNationalPokedexNum[sub0->species - 1]; |
69 | pki->heldItem = sub0->heldItem; | 80 | pki->heldItem = sub0->heldItem; |