Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/sail Use random() instead of rand(), and seed from tim...



details:   https://anonhg.NetBSD.org/src/rev/1226b560d75c
branches:  trunk
changeset: 499857:1226b560d75c
user:      jwise <jwise%NetBSD.org@localhost>
date:      Thu Nov 30 22:06:04 2000 +0000

description:
Use random() instead of rand(), and seed from time(3) instead of from getpid().

diffstat:

 games/sail/extern.h |  4 ++--
 games/sail/main.c   |  6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diffs (45 lines):

diff -r baa3588cd7df -r 1226b560d75c games/sail/extern.h
--- a/games/sail/extern.h       Thu Nov 30 22:02:20 2000 +0000
+++ b/games/sail/extern.h       Thu Nov 30 22:06:04 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.16 2000/11/30 22:02:20 jwise Exp $ */
+/*     $NetBSD: extern.h,v 1.17 2000/11/30 22:06:04 jwise Exp $ */
 
 /*
  * Copyright (c) 1983, 1993
@@ -60,7 +60,7 @@
 extern gid_t gid;
 extern gid_t egid;
 
-#define dieroll()              ((rand() >> 3) % 6 + 1)
+#define dieroll()              ((random()) % 6 + 1)
 #define sqr(a)         ((a) * (a))
 #define abs(a)         ((a) > 0 ? (a) : -(a))
 #define min(a,b)       ((a) < (b) ? (a) : (b))
diff -r baa3588cd7df -r 1226b560d75c games/sail/main.c
--- a/games/sail/main.c Thu Nov 30 22:02:20 2000 +0000
+++ b/games/sail/main.c Thu Nov 30 22:06:04 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.11 2000/11/30 22:02:20 jwise Exp $  */
+/*     $NetBSD: main.c,v 1.12 2000/11/30 22:06:04 jwise Exp $  */
 
 /*
  * Copyright (c) 1983, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.2 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: main.c,v 1.11 2000/11/30 22:02:20 jwise Exp $");
+__RCSID("$NetBSD: main.c,v 1.12 2000/11/30 22:06:04 jwise Exp $");
 #endif
 #endif /* not lint */
 
@@ -71,7 +71,7 @@
                exit(1);
        close(fd);
 
-       srand(getpid());
+       srandom((u_long)time(NULL));
 
        if ((p = strrchr(*argv, '/')) != NULL)
                p++;



Home | Main Index | Thread Index | Old Index