mirror of
https://github.com/Lorenzooone/Pokemon-Gen3-to-Gen-X.git
synced 2026-04-26 00:27:27 -05:00
Fix issue with wrong index whit illegal mon in Gen 3 trades
This commit is contained in:
parent
4b00d24f35
commit
e6d5ca3403
|
|
@ -39,7 +39,7 @@ static u16 applied_ball;
|
|||
static u8 egg_met_location;
|
||||
static u8 first_set_egg_met_location;
|
||||
|
||||
const struct version_t version = { .main_version = 1, .sub_version = 1, .revision_version = 2, .revision_letter = CONSOLE_LETTER};
|
||||
const struct version_t version = { .main_version = 1, .sub_version = 1, .revision_version = 3, .revision_letter = CONSOLE_LETTER};
|
||||
const u8* egg_valid_met_locations[NUMBER_OF_GAMES+FIRST_VERSION_ID] = {valid_egg_locations_rs_bin, valid_egg_locations_rs_bin, valid_egg_locations_rs_bin, valid_egg_locations_e_bin, valid_egg_locations_frlg_bin, valid_egg_locations_frlg_bin};
|
||||
|
||||
void set_default_settings() {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
#define FRAMES_BETWEEN_CHECKS ((1*FPS)/12)
|
||||
|
||||
#define MAGIC_NUMBER 0x08012025
|
||||
#define INVALID_MAGIC_NUMBER 0xFFFFFFFF
|
||||
#define NUM_SLOTS 2
|
||||
#define INVALID_SLOT NUM_SLOTS
|
||||
#define SAVE_SLOT_INDEX_POS 0xDFFC
|
||||
|
|
@ -80,7 +79,6 @@ void trade_reorder_party_entries(struct game_data_t*, struct gen3_mon_data_unenc
|
|||
u32 calc_checksum_save_buffer(u32*, u16);
|
||||
static void start_gen3_save_data_transfer(void);
|
||||
static void end_gen3_save_data_transfer(void);
|
||||
void write_magic_number(u8, u8, u32);
|
||||
|
||||
const u16 summable_bytes[SECTION_TOTAL] = {3884, MAX_SECTION_SIZE, MAX_SECTION_SIZE, MAX_SECTION_SIZE, 3848, MAX_SECTION_SIZE, MAX_SECTION_SIZE, MAX_SECTION_SIZE, MAX_SECTION_SIZE, MAX_SECTION_SIZE, MAX_SECTION_SIZE, MAX_SECTION_SIZE, MAX_SECTION_SIZE, 2000};
|
||||
const u16 summable_bytes_section0[NUM_MAIN_GAME_ID] = {0x890, 0xF24, 0xF2C};
|
||||
|
|
@ -724,6 +722,7 @@ u8 pre_update_save(struct game_data_t* game_data, struct game_data_priv_t* game_
|
|||
|
||||
u8 complete_save(u8 base_slot, struct game_data_t* game_data) {
|
||||
u8 target_slot = get_next_slot(base_slot);
|
||||
u32 old_slot_save_index = read_slot_index(target_slot) - 1;
|
||||
|
||||
for(int i = 0; i < SECTION_TOTAL; i++) {
|
||||
// Clear sector
|
||||
|
|
@ -731,9 +730,12 @@ u8 complete_save(u8 base_slot, struct game_data_t* game_data) {
|
|||
|
||||
// Fix issue with EZ Flash not really deleting the data...
|
||||
// Maybe other Flashcarts too... :/
|
||||
if((i == 0) && (read_magic_number(base_slot, i) == MAGIC_NUMBER))
|
||||
// Invalidate the slot
|
||||
write_magic_number(base_slot, i, INVALID_MAGIC_NUMBER);
|
||||
if(read_magic_number(base_slot, i) == MAGIC_NUMBER)
|
||||
// Set index to "value before the new one".
|
||||
// It shadows the old save and allows easy recovering if it fails.
|
||||
// (On the EZ Flash, that can happen if you don't wait enough
|
||||
// before turning off the console)
|
||||
write_int_save((base_slot * SAVE_SLOT_SIZE) + SAVE_NUMBER_POS + (i * SECTION_SIZE), old_slot_save_index);
|
||||
}
|
||||
|
||||
if(get_slot(&game_data->game_identifier) != target_slot)
|
||||
|
|
@ -800,10 +802,6 @@ IWRAM_CODE u32 read_magic_number(u8 slot, u8 section){
|
|||
return read_int_save((slot * SAVE_SLOT_SIZE) + MAGIC_NUMBER_POS + (section * SECTION_SIZE));
|
||||
}
|
||||
|
||||
IWRAM_CODE void write_magic_number(u8 slot, u8 section, u32 value){
|
||||
write_int_save((slot * SAVE_SLOT_SIZE) + MAGIC_NUMBER_POS + (section * SECTION_SIZE), value);
|
||||
}
|
||||
|
||||
IWRAM_CODE u8 has_cartridge_been_removed(){
|
||||
u8 retval = 0;
|
||||
if(get_is_cartridge_loaded()) {
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ void handle_learnable_moves_message(struct game_data_t*, u8, u8*, u32*, enum MOV
|
|||
void change_nature(struct game_data_t*, u8, u8, u8*, u8);
|
||||
void check_bad_trade_received(struct game_data_t*, struct game_data_priv_t*, u8, u8, u8, u8, u8, u8*);
|
||||
void trade_cancel_print_screen(u8);
|
||||
void saving_print_screen(void);
|
||||
void saving_print_screen(u8);
|
||||
void loading_print_screen(void);
|
||||
void rejected_print_screen(u8);
|
||||
void trading_animation_init(struct game_data_t*, u8, u8, u8);
|
||||
|
|
@ -345,12 +345,13 @@ void rejected_print_screen(u8 reason) {
|
|||
prepare_flush();
|
||||
}
|
||||
|
||||
void saving_print_screen() {
|
||||
void saving_print_screen(u8 go_back) {
|
||||
u8 prev_screen = get_screen_num();
|
||||
set_screen(SAVING_WINDOW_SCREEN);
|
||||
print_saving();
|
||||
enable_screen(SAVING_WINDOW_SCREEN);
|
||||
set_screen(prev_screen);
|
||||
if(go_back)
|
||||
set_screen(prev_screen);
|
||||
prepare_flush();
|
||||
}
|
||||
|
||||
|
|
@ -943,7 +944,7 @@ int main(void)
|
|||
else if(!own_menu)
|
||||
waiting_success_init();
|
||||
else {
|
||||
saving_print_screen();
|
||||
saving_print_screen(1);
|
||||
complete_save_menu(&game_data[0], &game_data_priv, 0, master);
|
||||
main_menu_init(&game_data[0], &game_data_priv, target, region, master, &cursor_y_pos);
|
||||
}
|
||||
|
|
@ -975,7 +976,7 @@ int main(void)
|
|||
if(!own_menu)
|
||||
waiting_success_init();
|
||||
else {
|
||||
saving_print_screen();
|
||||
saving_print_screen(1);
|
||||
complete_save_menu(&game_data[0], &game_data_priv, 0, master);
|
||||
main_menu_init(&game_data[0], &game_data_priv, target, region, master, &cursor_y_pos);
|
||||
}
|
||||
|
|
@ -1105,7 +1106,10 @@ int main(void)
|
|||
}
|
||||
else if(!cursor_x_pos) {
|
||||
prepare_gen3_offer(&game_data[0].party_3_undec[curr_mon]);
|
||||
waiting_offer_init(0, cursor_y_pos);
|
||||
if(curr_gen == 3)
|
||||
waiting_offer_init(0, curr_mon);
|
||||
else
|
||||
waiting_offer_init(0, cursor_y_pos);
|
||||
}
|
||||
else
|
||||
nature_menu_init(game_data, cursor_x_pos, curr_mon, &submenu_cursor_y_pos);
|
||||
|
|
@ -1171,7 +1175,7 @@ int main(void)
|
|||
game_data[cursor_x_pos].party_3_undec[curr_mon].fix_has_altered_ot = 0;
|
||||
set_default_gift_ribbons(&game_data[cursor_x_pos]);
|
||||
if(!cursor_x_pos) {
|
||||
saving_print_screen();
|
||||
saving_print_screen(1);
|
||||
success = pre_write_gen_3_data(&game_data[0], &game_data_priv, 1);
|
||||
if(!success)
|
||||
crash_on_bad_save(0, master);
|
||||
|
|
@ -1237,7 +1241,7 @@ int main(void)
|
|||
base_settings_menu_init(&game_data[0], &cursor_y_pos);
|
||||
else {
|
||||
if(get_is_cartridge_loaded() && give_pokerus_to_party(&game_data[0])) {
|
||||
saving_print_screen();
|
||||
saving_print_screen(0);
|
||||
success = pre_write_gen_3_data(&game_data[0], &game_data_priv, 1);
|
||||
if(!success)
|
||||
crash_on_bad_save(0, master);
|
||||
|
|
@ -1261,7 +1265,7 @@ int main(void)
|
|||
clock_warning_menu_init(&cursor_x_pos);
|
||||
else {
|
||||
run_daily_update(&game_data[0], &game_data_priv.clock_events, &time_change, game_data_priv.game_cleared_flag);
|
||||
saving_print_screen();
|
||||
saving_print_screen(0);
|
||||
success = pre_write_gen_3_data(&game_data[0], &game_data_priv, 1);
|
||||
if(!success)
|
||||
crash_on_bad_save(0, master);
|
||||
|
|
@ -1282,7 +1286,7 @@ int main(void)
|
|||
clock_settings_menu_init(&game_data_priv, &time_change, &cursor_y_pos, 0);
|
||||
else {
|
||||
run_daily_update(&game_data[0], &game_data_priv.clock_events, &time_change, game_data_priv.game_cleared_flag);
|
||||
saving_print_screen();
|
||||
saving_print_screen(0);
|
||||
success = pre_write_gen_3_data(&game_data[0], &game_data_priv, 1);
|
||||
if(!success)
|
||||
crash_on_bad_save(0, master);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user