X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=roguelike.c;h=2952daf94e548e33acd16d5a9a94cc82677b0e51;hb=1b2763d9c191be9e3917ca3c180d918ace19810b;hp=7b2d159f878b5ea3fa4e5278d5295f5488abbd55;hpb=67396848cb5e3e55385a466d7a24a4f68d0a6c9c;p=plomrogue
diff --git a/roguelike.c b/roguelike.c
index 7b2d159..2952daf 100644
--- a/roguelike.c
+++ b/roguelike.c
@@ -8,15 +8,11 @@
#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;
- seed = ((seed * a) + b) % mod;
- return (seed / 65536); } // Ignore least significant 16 bits (they are less random).
+ static uint32_t seed = 0;
+ seed = ((seed * 1103515245) + 12345) % 2147483648; // Values as recommended by POSIX.1-2001 (see rand(3)).
+ return (seed / 65536); } // Ignore least significant 16 bits (they are less random).
void toggle_window (struct WinMeta * win_meta, struct Win * win) {
// Toggle display of window win.