From e8009bb4cbda9d2c32c1dd6f7b6da10f5ef467e2 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 28 Sep 2014 15:28:14 -0300 Subject: [PATCH] Reverted commit 14ca947 (love.math.setRandomSeed internally calling random() a few times.) The change can break existing 0.9.x games so it will be pushed back to the minor branch. --- src/modules/math/RandomGenerator.cpp | 5 ----- src/scripts/boot.lua | 1 + src/scripts/boot.lua.h | 3 +++ 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/modules/math/RandomGenerator.cpp b/src/modules/math/RandomGenerator.cpp index 6b14390f9..0f1b6bb37 100644 --- a/src/modules/math/RandomGenerator.cpp +++ b/src/modules/math/RandomGenerator.cpp @@ -81,11 +81,6 @@ void RandomGenerator::setSeed(RandomGenerator::Seed newseed) seed = newseed; rng_state = seed; - - // Xorshift's first couple results after seeding will be similar to results - // from very similar seeds, so we immediately discard them here. - for (int i = 0; i < 2; i++) - rand(); } RandomGenerator::Seed RandomGenerator::getSeed() const diff --git a/src/scripts/boot.lua b/src/scripts/boot.lua index c12dd58ed..ddf245f74 100644 --- a/src/scripts/boot.lua +++ b/src/scripts/boot.lua @@ -478,6 +478,7 @@ function love.run() if love.math then love.math.setRandomSeed(os.time()) + for i=1,3 do love.math.random() end end if love.event then diff --git a/src/scripts/boot.lua.h b/src/scripts/boot.lua.h index c00a0f40a..4d6a7b52b 100644 --- a/src/scripts/boot.lua.h +++ b/src/scripts/boot.lua.h @@ -859,6 +859,9 @@ const unsigned char boot_lua[] = 0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x6d, 0x61, 0x74, 0x68, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x73, 0x65, 0x74, 0x52, 0x61, 0x6e, 0x64, 0x6f, 0x6d, 0x53, 0x65, 0x65, 0x64, 0x28, 0x6f, 0x73, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x28, 0x29, 0x29, 0x0a, + 0x09, 0x09, 0x66, 0x6f, 0x72, 0x20, 0x69, 0x3d, 0x31, 0x2c, 0x33, 0x20, 0x64, 0x6f, 0x20, 0x6c, 0x6f, 0x76, + 0x65, 0x2e, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x72, 0x61, 0x6e, 0x64, 0x6f, 0x6d, 0x28, 0x29, 0x20, 0x65, 0x6e, + 0x64, 0x0a, 0x09, 0x65, 0x6e, 0x64, 0x0a, 0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a,