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] 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) {