1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-20 00:46:34 +00:00

Fix Save State Slots menu crash (#526)

* Update options.rs

* Update save_states.rs

* Update options.rs
This commit is contained in:
jugeeya 2023-04-29 12:22:45 -07:00 committed by GitHub
parent 9b9070cff2
commit dbfa60bebc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions

View file

@ -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(),

View file

@ -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 {