Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed dv rand #113

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions src/pksavhelper.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ enum eligible_evolution_status check_trade_evolution_gen2(PokemonSave *pkmn_save
// Species index of pokemon being checked
int species = pkmn_save->save.gen2_save.pokemon_storage.p_party->species[pkmn_party_index];
struct pkmn_evolution_pair_data evo_pair = pkmn_evolution_pairs_gen2[species];

// If the pkmn species has an initialized evolution pair
if (species == evo_pair.species_index)
{
Expand Down Expand Up @@ -199,13 +199,13 @@ uint8_t calculate_stat(uint8_t level, uint8_t base_stat, uint8_t dv, uint16_t st
/************************************************************************
* Simulate the random number generation for Generation 1
*/
uint8_t r_div = 0;
uint8_t carry_bit = 0;
uint8_t add_byte = 0;
uint8_t subtract_byte = 0;
static uint8_t r_div = 0;
static uint8_t carry_bit = 0;
static uint8_t add_byte = 0;
static uint8_t subtract_byte = 0;
// Simulated hardware registers
uint8_t h_random_add = 0; // h_random_add register
uint8_t h_random_sub = 0; // h_random_sub register
static uint8_t h_random_add = 0; // h_random_add register
static uint8_t h_random_sub = 0; // h_random_sub register

// Simulate one step of the random number generation process
void generate_random_number_step(void)
Expand Down Expand Up @@ -254,13 +254,16 @@ void generate_random_number_step_gen2(void)

void generate_rand_num_step(SaveGenerationType save_generation_type)
{
if (save_generation_type == SAVE_GENERATION_1)
{
generate_random_number_step();
}
else
for (int i = 0; i < rand(); i++)
{
generate_random_number_step_gen2();
if (save_generation_type == SAVE_GENERATION_1)
{
generate_random_number_step();
}
else
{
generate_random_number_step_gen2();
}
}
}

Expand Down
Loading