diff src/util/prng.rs @ 687:ac092b70c39a

Fix PRNG not to panic, pass it to Enemy, and initialise it with time in eclrenderer.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 17 Aug 2019 13:49:31 +0200
parents 1520b559cacc
children
line wrap: on
line diff
--- a/src/util/prng.rs
+++ b/src/util/prng.rs
@@ -18,8 +18,8 @@ impl Prng {
     ///
     /// RE’d from 102h.exe@0x41e780
     pub fn get_u16(&mut self) -> u16 {
-        let x = (self.seed ^ 0x9630) - 0x6553;
-        self.seed = (((x & 0xc000) >> 14) | (x << 2)) & 0xffff;
+        let x = (self.seed ^ 0x9630).wrapping_sub(0x6553);
+        self.seed = ((x & 0xc000) >> 14) | (x << 2);
         self.seed
     }