From 061bb35502f2bd33dd536914405cd3e00889dac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Sun, 18 Oct 2015 21:10:13 +0000 Subject: [PATCH] [INTERPRETER] * BUG: Prevent the use of seed 0 for the random-number generator, by replacing it by -1 if Randomize 0 is requested. git-svn-id: svn://localhost/gambas/trunk@7426 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- main/gbx/gbx_math.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main/gbx/gbx_math.c b/main/gbx/gbx_math.c index 3136ac1b3..fba774b0f 100644 --- a/main/gbx/gbx_math.c +++ b/main/gbx/gbx_math.c @@ -54,6 +54,9 @@ static void GFSR_init(uint seed) int i = 0, j; uint t = seed; + if (t == 0) + t = (uint)-1; + do { t ^= (t >> 5) ^ (t << 1);