From fc77e8f9f03f556d7185604dbdb8eb206227eee7 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sat, 15 Mar 2014 21:43:25 -0300 Subject: [PATCH] Throw away the first 3 love.math.random results after seeding it (xorshift outputs less random results the first few times when the seed is very similar to a previous one) --- src/libraries/enet/enet.cpp | 2 +- src/scripts/boot.lua | 1 + src/scripts/boot.lua.h | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libraries/enet/enet.cpp b/src/libraries/enet/enet.cpp index 34e215c78..7d915cfce 100644 --- a/src/libraries/enet/enet.cpp +++ b/src/libraries/enet/enet.cpp @@ -89,7 +89,7 @@ static void parse_address(lua_State *l, const char *addr_str, ENetAddress *addre /** * Find the index of a given peer for which we only have the pointer. */ -size_t find_peer_index (lua_State *l, ENetHost *enet_host, ENetPeer *peer) { +static size_t find_peer_index(lua_State *l, ENetHost *enet_host, ENetPeer *peer) { size_t peer_index; for (peer_index = 0; peer_index < enet_host->peerCount; peer_index++) { if (peer == &(enet_host->peers[peer_index])) diff --git a/src/scripts/boot.lua b/src/scripts/boot.lua index 183b1725f..577b615fe 100644 --- a/src/scripts/boot.lua +++ b/src/scripts/boot.lua @@ -468,6 +468,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 0c2b2712b..69c5998ee 100644 --- a/src/scripts/boot.lua.h +++ b/src/scripts/boot.lua.h @@ -836,6 +836,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,