From 05a90734158a979f2f0444fe94d62b67bdc0ffbc Mon Sep 17 00:00:00 2001 From: GradualSyrup <68757075+GradualSyrup@users.noreply.github.com> Date: Fri, 15 Sep 2023 13:37:53 -0500 Subject: [PATCH 1/3] Greatly improve recording playback --- src/training/input_record.rs | 9 ++++++++- src/training/mod.rs | 7 +++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/training/input_record.rs b/src/training/input_record.rs index fe3c20f..89dd16c 100644 --- a/src/training/input_record.rs +++ b/src/training/input_record.rs @@ -172,7 +172,14 @@ fn into_transition_term(starting_status: StartingStatus) -> i32 { } } -pub unsafe fn get_command_flag_cat(module_accessor: &mut BattleObjectModuleAccessor) { +pub unsafe fn handle_recording() { + let player_module_accessor = get_module_accessor(FighterId::Player); + let cpu_module_accessor = get_module_accessor(FighterId::CPU); + handle_recording_for_fighter(&mut *player_module_accessor); + handle_recording_for_fighter(&mut *cpu_module_accessor); +} + +unsafe fn handle_recording_for_fighter(module_accessor: &mut BattleObjectModuleAccessor) { // Allow this because sometimes we want to make sure our NNSDK doesn't have // an erroneous definition #[allow(clippy::unnecessary_cast)] diff --git a/src/training/mod.rs b/src/training/mod.rs index a663392..8bc1a36 100644 --- a/src/training/mod.rs +++ b/src/training/mod.rs @@ -138,7 +138,6 @@ fn once_per_frame_per_fighter( ); } - input_record::get_command_flag_cat(module_accessor); combo::get_command_flag_cat(module_accessor); hitbox_visualizer::get_command_flag_cat(module_accessor); save_states::save_states(module_accessor); @@ -797,6 +796,7 @@ static OPCF_OFFSET: usize = 0x06b7fdc; // One instruction after the CPU Control function completes #[skyline::hook(offset = OPCF_OFFSET, inline)] unsafe fn handle_once_per_cpu_frame(_ctx: &mut InlineCtx) { + input_record::handle_recording(); frame_counter::tick_ingame(); tech::hide_tech(); // Tick notifications @@ -881,7 +881,10 @@ pub fn training_mods() { // Enable Custom Stages for Training Mode // Specifically, we prevent a field in StageSelectInfo of the Scene that controls if the Custom Stage tab is loaded // from being set to false when we load the SSS in Training Mode - skyline::patching::Patch::in_text(0x184d1d8).nop().unwrap(); + static SSS_TRAINING_OFFSET: usize = 0x184d1d8; + skyline::patching::Patch::in_text(SSS_TRAINING_OFFSET) + .nop() + .unwrap(); skyline::install_hooks!( // Mash airdodge/jump From d7a00e7227e499e81e951a573dce274bf6cd49eb Mon Sep 17 00:00:00 2001 From: GradualSyrup <68757075+GradualSyrup@users.noreply.github.com> Date: Thu, 21 Sep 2023 13:05:37 -0500 Subject: [PATCH 2/3] safer option usage --- src/training/input_record.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/training/input_record.rs b/src/training/input_record.rs index 89dd16c..d74c079 100644 --- a/src/training/input_record.rs +++ b/src/training/input_record.rs @@ -173,10 +173,12 @@ fn into_transition_term(starting_status: StartingStatus) -> i32 { } pub unsafe fn handle_recording() { - let player_module_accessor = get_module_accessor(FighterId::Player); - let cpu_module_accessor = get_module_accessor(FighterId::CPU); - handle_recording_for_fighter(&mut *player_module_accessor); - handle_recording_for_fighter(&mut *cpu_module_accessor); + let player_module_accessor = try_get_module_accessor(FighterId::Player); + let cpu_module_accessor = try_get_module_accessor(FighterId::CPU); + if player_module_accessor.is_some() && cpu_module_accessor.is_some() { + handle_recording_for_fighter(&mut *player_module_accessor.unwrap()); + handle_recording_for_fighter(&mut *cpu_module_accessor.unwrap()); + } } unsafe fn handle_recording_for_fighter(module_accessor: &mut BattleObjectModuleAccessor) { From 069bdd320b27a54750da49f71b129635e5d324f8 Mon Sep 17 00:00:00 2001 From: GradualSyrup <68757075+GradualSyrup@users.noreply.github.com> Date: Thu, 21 Sep 2023 13:25:53 -0500 Subject: [PATCH 3/3] clippy allow --- src/training/input_record.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/training/input_record.rs b/src/training/input_record.rs index d74c079..ba6ad6a 100644 --- a/src/training/input_record.rs +++ b/src/training/input_record.rs @@ -172,6 +172,7 @@ fn into_transition_term(starting_status: StartingStatus) -> i32 { } } +#[allow(clippy::unnecessary_unwrap)] pub unsafe fn handle_recording() { let player_module_accessor = try_get_module_accessor(FighterId::Player); let cpu_module_accessor = try_get_module_accessor(FighterId::CPU);