Avoid overflow panic

This commit is contained in:
Lucas Schumacher 2024-05-06 21:29:06 -04:00
parent f6f6a5b1ef
commit e59f6ce896

View File

@ -20,8 +20,8 @@ mod deadbeef_rand {
static mut RNG_BEEF: u32 = 0xdeadbeef; static mut RNG_BEEF: u32 = 0xdeadbeef;
pub fn rand() -> u8 { pub fn rand() -> u8 {
unsafe { unsafe {
RNG_SEED = (RNG_SEED << 7) ^ ((RNG_SEED >> 25) + RNG_BEEF); RNG_SEED = (RNG_SEED << 7) ^ ((RNG_SEED >> 25).wrapping_add(RNG_BEEF));
RNG_BEEF = (RNG_BEEF << 7) ^ ((RNG_BEEF >> 25) + 0xdeadbeef); RNG_BEEF = (RNG_BEEF << 7) ^ ((RNG_BEEF >> 25).wrapping_add(0xdeadbeef));
(RNG_SEED & 0xff) as u8 (RNG_SEED & 0xff) as u8
} }
} }