]> git.nega.tv - josh/narcissus/commitdiff
core: Fix wrapping assert when seeding Pcg64
authorJoshua Simmons <josh@nega.tv>
Mon, 29 May 2023 07:04:39 +0000 (09:04 +0200)
committerJoshua Simmons <josh@nega.tv>
Mon, 29 May 2023 07:14:05 +0000 (09:14 +0200)
libs/narcissus-core/src/rand.rs

index 1a01910bdd2c6069383035fd15316ac4f60aa760..a8e2b424628fa24cf70edd6716680b770faa4d5e 100644 (file)
@@ -15,7 +15,7 @@ impl Pcg64 {
     pub fn with_seed(seed: u128) -> Self {
         let mut rng = Self { state: 0 };
         let _ = rng.next_u64();
-        rng.state += seed;
+        rng.state = rng.state.wrapping_add(seed);
         let _ = rng.next_u64();
         rng
     }