From 55170fcca302f142a270ee29b5cfbcc3ae69386d Mon Sep 17 00:00:00 2001 From: Logan McNaughton <848146+loganmc10@users.noreply.github.com> Date: Mon, 9 Feb 2026 12:16:10 +0100 Subject: [PATCH] use Xoshiro256PlusPlus (#668) --- Cargo.toml | 2 +- src/device.rs | 8 ++++---- src/device/pi.rs | 2 +- src/device/si.rs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d17bed3..7c576fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ regex = "1.11" tokio-tungstenite = "0.28" futures = "0.3" socket2 = { version = "0.6", features = ["all"] } -rand = { version = "0.10", features = ["chacha"] } +rand = "0.10" fatfs = "0.3" semver = "1.0" postcard = { version = "1.1", features = ["use-std"] } diff --git a/src/device.rs b/src/device.rs index 80fd653..2409507 100644 --- a/src/device.rs +++ b/src/device.rs @@ -87,8 +87,8 @@ pub fn run_game(device: &mut Device, rom_contents: Vec, game_settings: ui::g ui::video::close(&device.ui); } -fn set_rng() -> rand::rngs::ChaCha8Rng { - rand::rngs::ChaCha8Rng::try_from_rng(&mut rand::rngs::SysRng).unwrap() +fn set_rng() -> rand::rngs::Xoshiro256PlusPlus { + rand::rngs::Xoshiro256PlusPlus::try_from_rng(&mut rand::rngs::SysRng).unwrap() } fn init_rng(device: &mut Device) { @@ -100,7 +100,7 @@ fn init_rng(device: &mut Device) { rng_seed = netplay::receive_rng(netplay); } } - device.rng = rand::rngs::ChaCha8Rng::seed_from_u64(rng_seed); + device.rng = rand::rngs::Xoshiro256PlusPlus::seed_from_u64(rng_seed); } fn swap_rom(contents: Vec) -> Option> { @@ -206,7 +206,7 @@ pub struct Device { pub si: si::Si, pub ri: ri::Ri, #[serde(skip, default = "set_rng")] - pub rng: rand::rngs::ChaCha8Rng, + pub rng: rand::rngs::Xoshiro256PlusPlus, pub vru: controller::vru::Vru, pub transferpaks: [controller::transferpak::TransferPak; 4], pub cheats: cheats::Cheats, diff --git a/src/device/pi.rs b/src/device/pi.rs index c5d9a27..8de8c2f 100644 --- a/src/device/pi.rs +++ b/src/device/pi.rs @@ -169,7 +169,7 @@ pub fn write_regs(device: &mut device::Device, address: u64, value: u32, mask: u } } -fn randomize_interrupt_time(rng: &mut rand::rngs::ChaCha8Rng) -> u64 { +fn randomize_interrupt_time(rng: &mut rand::rngs::Xoshiro256PlusPlus) -> u64 { rng.next_u64() % 0x10 } diff --git a/src/device/si.rs b/src/device/si.rs index 03e561d..79e109f 100644 --- a/src/device/si.rs +++ b/src/device/si.rs @@ -38,7 +38,7 @@ pub fn read_regs( device.si.regs[((address & 0xFFFF) >> 2) as usize] } -fn randomize_interrupt_time(rng: &mut rand::rngs::ChaCha8Rng) -> u64 { +fn randomize_interrupt_time(rng: &mut rand::rngs::Xoshiro256PlusPlus) -> u64 { rng.next_u64() % 0x100 }