Browse Source

Fix setRandomSeed and setRandomState not fully invalidating the state used by randomNormal (resolves issue #1516).

Alex Szpakowski 5 years ago
parent
commit
83e74e5e6c
1 changed files with 4 additions and 0 deletions
  1. 4 0
      src/modules/math/RandomGenerator.cpp

+ 4 - 0
src/modules/math/RandomGenerator.cpp

@@ -104,6 +104,8 @@ void RandomGenerator::setSeed(RandomGenerator::Seed newseed)
 	} while (newseed.b64 == 0);
 	} while (newseed.b64 == 0);
 
 
 	rng_state = newseed;
 	rng_state = newseed;
+
+	last_randomnormal = std::numeric_limits<double>::infinity();
 }
 }
 
 
 RandomGenerator::Seed RandomGenerator::getSeed() const
 RandomGenerator::Seed RandomGenerator::getSeed() const
@@ -129,6 +131,8 @@ void RandomGenerator::setState(const std::string &statestr)
 		throw love::Exception("Invalid random state: %s", statestr.c_str());
 		throw love::Exception("Invalid random state: %s", statestr.c_str());
 
 
 	rng_state = state;
 	rng_state = state;
+
+	last_randomnormal = std::numeric_limits<double>::infinity();
 }
 }
 
 
 std::string RandomGenerator::getState() const
 std::string RandomGenerator::getState() const