From: Christian Heller Date: Sun, 26 May 2013 03:31:44 +0000 (+0200) Subject: Moved seed initialization into rrand(). X-Git-Tag: tce~1275 X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/static/%7B%7B%20web_path%20%7D%7D/day_todos?a=commitdiff_plain;h=66bc25319591a8e1b4688285c4a441faa1d78437;p=plomrogue Moved seed initialization into rrand(). --- diff --git a/roguelike.c b/roguelike.c index 7b2d159..c91c407 100644 --- a/roguelike.c +++ b/roguelike.c @@ -8,13 +8,12 @@ #include "roguelike.h" #include "keybindings.h" -static uint32_t seed = 0; - uint16_t rrand() { // Pseudo-random number generator (LGC algorithm). Use instead of rand() to ensure portable predictability. uint32_t a = 1103515245; // Values for a and b as recommended by POSIX.1-2001 (see man page rand(3)). uint16_t b = 12345; uint32_t mod = 2147483648; + static uint32_t seed = 0; seed = ((seed * a) + b) % mod; return (seed / 65536); } // Ignore least significant 16 bits (they are less random).