From: David Given Date: Sat, 17 Oct 2015 22:10:19 +0000 (+0200) Subject: Fix a whole bunch of show-stopping bugs --- how did this ever work? X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=9c2e772ec8542905683d5af1c0b83b48ffea1366;p=FUZIX.git Fix a whole bunch of show-stopping bugs --- how did this ever work? --- diff --git a/Applications/V7/games/wump.c b/Applications/V7/games/wump.c index 8b2ac787..de55f26c 100644 --- a/Applications/V7/games/wump.c +++ b/Applications/V7/games/wump.c @@ -98,6 +98,7 @@ char rline(void) { register char c, r; + fflush(stdout); while ((c = getchar()) == ' '); r = c; while (c != '\n' && c != ' ') { @@ -111,16 +112,19 @@ char rline(void) int rnum(int n) { - time_t t; - static int16_t first[2]; + static char seeded = 0; - if (first[1] == 0) { + if (!seeded) { + static int16_t first[2]; + time_t t; + + seeded = 1; time(&t); first[0] = (int) t; first[1] = ((uint32_t) t) >> 16; srand((first[1] * first[0]) ^ first[1]); } - return (((long)rand() / 32768L) * n); + return rand() % n; } int rin(void) @@ -128,6 +132,7 @@ int rin(void) register int n, c; n = 0; + fflush(stdout); c = getchar(); while (c != '\n' && c != ' ') { if (c < '0' || c > '9') {