diff --git a/src/training/save_states.rs b/src/training/save_states.rs index 197b076..2fed8c8 100644 --- a/src/training/save_states.rs +++ b/src/training/save_states.rs @@ -156,7 +156,7 @@ unsafe fn get_slot() -> usize { if MENU.randomize_slots == OnOff::On { RANDOM_SLOT } else { - MENU.save_state_slot as u32 as usize + MENU.save_state_slot.as_idx() as usize } } @@ -594,8 +594,8 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor) { // Don't begin saving state if Nana's delayed input is captured MIRROR_STATE = 1.0; - save_state_player(MENU.save_state_slot as u32 as usize).state = Save; - save_state_cpu(MENU.save_state_slot as u32 as usize).state = Save; + save_state_player(MENU.save_state_slot.as_idx() as usize).state = Save; + save_state_cpu(MENU.save_state_slot.as_idx() as usize).state = Save; notifications::clear_notifications("Save State"); notifications::notification( "Save State".to_string(), diff --git a/training_mod_consts/src/options.rs b/training_mod_consts/src/options.rs index 5ed0250..58ce6e7 100644 --- a/training_mod_consts/src/options.rs +++ b/training_mod_consts/src/options.rs @@ -1112,11 +1112,11 @@ impl_serde_for_bitflags!(SaveDamage); Debug, Clone, Copy, PartialEq, FromPrimitive, EnumIter, Serialize_repr, Deserialize_repr, )] pub enum SaveStateSlot { - One = 0, - Two = 1, - Three = 2, - Four = 3, - Five = 4, + One = 0x0, + Two = 0x1, + Three = 0x2, + Four = 0x4, + Five = 0x8, } impl SaveStateSlot { @@ -1129,6 +1129,10 @@ impl SaveStateSlot { SaveStateSlot::Five => "5", }) } + + pub fn as_idx(self) -> u32 { + log_2(self as i32 as u32) + } } impl ToggleTrait for SaveStateSlot {