From 5175d50aa871a5368c79cb8c9f2b16da07366114 Mon Sep 17 00:00:00 2001 From: Logan McNaughton <848146+loganmc10@users.noreply.github.com> Date: Sun, 31 May 2026 19:49:07 +0200 Subject: [PATCH] save video state before cloning device (#997) --- src/savestates.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/savestates.rs b/src/savestates.rs index cc03bf9..273ab5f 100644 --- a/src/savestates.rs +++ b/src/savestates.rs @@ -95,6 +95,12 @@ static SAVES_CLONE: std::sync::LazyLock> = std::sync::LazyLock::new(|| std::sync::Mutex::new(ui::storage::Saves::default())); pub fn create_savestate(device: &mut device::Device, rewind: bool) { + let mut rdp_state: Vec = vec![0; ui::video::state_size()]; + ui::video::save_state(rdp_state.as_mut_ptr(), rewind); + + let mut ra_state: Vec = vec![0; retroachievements::state_size()]; + retroachievements::save_state(ra_state.as_mut_ptr(), ra_state.len()); + if let Ok(mut device_clone) = DEVICE_CLONE.lock() && let Ok(mut saves_clone) = SAVES_CLONE.lock() { @@ -108,12 +114,6 @@ pub fn create_savestate(device: &mut device::Device, rewind: bool) { return; } - let mut rdp_state: Vec = vec![0; ui::video::state_size()]; - ui::video::save_state(rdp_state.as_mut_ptr(), rewind); - - let mut ra_state: Vec = vec![0; retroachievements::state_size()]; - retroachievements::save_state(ra_state.as_mut_ptr(), ra_state.len()); - let save_path = device.ui.storage.paths.savestate_file_path.clone(); let save_state_slot = device.ui.storage.save_state_slot; let rewind_pool = device.savestate.rewind_pool.clone();