Module Name: src
Committed By: nia
Date: Tue Jul 21 02:42:05 UTC 2020
Modified Files:
src/games/tetris: tetris.c tetris.h
Log Message:
tetris: Use arc4random_uniform instead of modulo for better randomness
To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/games/tetris/tetris.c
cvs rdiff -u -r1.15 -r1.16 src/games/tetris/tetris.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/games/tetris/tetris.c
diff -u src/games/tetris/tetris.c:1.32 src/games/tetris/tetris.c:1.33
--- src/games/tetris/tetris.c:1.32 Thu Mar 3 21:38:55 2016
+++ src/games/tetris/tetris.c Tue Jul 21 02:42:05 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: tetris.c,v 1.32 2016/03/03 21:38:55 nat Exp $ */
+/* $NetBSD: tetris.c,v 1.33 2020/07/21 02:42:05 nia Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -207,7 +207,6 @@ main(int argc, char *argv[])
scr_init();
setup_board();
- srandom(getpid());
scr_set();
pos = A_FIRST*B_COLS + (B_COLS/2)-1;
Index: src/games/tetris/tetris.h
diff -u src/games/tetris/tetris.h:1.15 src/games/tetris/tetris.h:1.16
--- src/games/tetris/tetris.h:1.15 Thu Mar 3 21:38:55 2016
+++ src/games/tetris/tetris.h Tue Jul 21 02:42:05 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: tetris.h,v 1.15 2016/03/03 21:38:55 nat Exp $ */
+/* $NetBSD: tetris.h,v 1.16 2020/07/21 02:42:05 nia Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -130,7 +130,7 @@ struct shape {
};
extern const struct shape shapes[];
-#define randshape() (&shapes[random() % 7])
+#define randshape() (&shapes[arc4random_uniform(7)])
extern const struct shape *nextshape;