Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/games/hunt/huntd use random(), not a handrolled 16-bit gener...
details: https://anonhg.NetBSD.org/src/rev/a592c3bc2bbe
branches: trunk
changeset: 328229:a592c3bc2bbe
user: dholland <dholland%NetBSD.org@localhost>
date: Sat Mar 29 19:33:03 2014 +0000
description:
use random(), not a handrolled 16-bit generator
diffstat:
games/hunt/huntd/driver.c | 16 ++++------------
1 files changed, 4 insertions(+), 12 deletions(-)
diffs (51 lines):
diff -r 7f5c4edb043a -r a592c3bc2bbe games/hunt/huntd/driver.c
--- a/games/hunt/huntd/driver.c Sat Mar 29 19:30:49 2014 +0000
+++ b/games/hunt/huntd/driver.c Sat Mar 29 19:33:03 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: driver.c,v 1.22 2013/10/19 17:23:08 christos Exp $ */
+/* $NetBSD: driver.c,v 1.23 2014/03/29 19:33:03 dholland Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
* All rights reserved.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: driver.c,v 1.22 2013/10/19 17:23:08 christos Exp $");
+__RCSID("$NetBSD: driver.c,v 1.23 2014/03/29 19:33:03 dholland Exp $");
#endif /* not lint */
#include <sys/ioctl.h>
@@ -45,14 +45,6 @@
#include <unistd.h>
#include"hunt.h"
-#ifndef pdp11
-#define RN (((Seed = Seed * 11109 + 13849) >> 16) & 0xffff)
-#else
-#define RN ((Seed = Seed * 11109 + 13849) & 0x7fff)
-#endif
-
-static int Seed = 0;
-
static SOCKET Daemon;
static char *First_arg; /* pointer to argv[0] */
@@ -411,7 +403,7 @@
fdset[2].fd = -1;
#endif
- Seed = getpid() + time(NULL);
+ srandom(time(NULL));
makemaze();
#ifdef BOOTS
makeboots();
@@ -810,7 +802,7 @@
int
rand_num(int range)
{
- return (range == 0 ? 0 : RN % range);
+ return (range == 0 ? 0 : random() % range);
}
/*
Home |
Main Index |
Thread Index |
Old Index