Mon May 25 23:41:23 2009 UTC ()
Use the time to call srandom(), not getpid().


(dholland)
diff -r1.18 -r1.19 src/games/mille/mille.c

cvs diff -r1.18 -r1.19 src/games/mille/mille.c (expand / switch to unified diff)

--- src/games/mille/mille.c 2009/05/25 23:34:50 1.18
+++ src/games/mille/mille.c 2009/05/25 23:41:23 1.19
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mille.c,v 1.18 2009/05/25 23:34:50 dholland Exp $ */ 1/* $NetBSD: mille.c,v 1.19 2009/05/25 23:41:23 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1982, 1993 4 * Copyright (c) 1982, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -29,30 +29,31 @@ @@ -29,30 +29,31 @@
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34__COPYRIGHT("@(#) Copyright (c) 1982, 1993\ 34__COPYRIGHT("@(#) Copyright (c) 1982, 1993\
35 The Regents of the University of California. All rights reserved."); 35 The Regents of the University of California. All rights reserved.");
36#endif /* not lint */ 36#endif /* not lint */
37 37
38#ifndef lint 38#ifndef lint
39#if 0 39#if 0
40static char sccsid[] = "@(#)mille.c 8.1 (Berkeley) 5/31/93"; 40static char sccsid[] = "@(#)mille.c 8.1 (Berkeley) 5/31/93";
41#else 41#else
42__RCSID("$NetBSD: mille.c,v 1.18 2009/05/25 23:34:50 dholland Exp $"); 42__RCSID("$NetBSD: mille.c,v 1.19 2009/05/25 23:41:23 dholland Exp $");
43#endif 43#endif
44#endif /* not lint */ 44#endif /* not lint */
45 45
 46#include <time.h>
46#include "mille.h" 47#include "mille.h"
47#include <signal.h> 48#include <signal.h>
48 49
49/* 50/*
50 * @(#)mille.c 1.3 (Berkeley) 5/10/83 51 * @(#)mille.c 1.3 (Berkeley) 5/10/83
51 */ 52 */
52 53
53int 54int
54main(int ac, char *av[]) 55main(int ac, char *av[])
55{ 56{
56 bool restore; 57 bool restore;
57 58
58 /* Revoke setgid privileges */ 59 /* Revoke setgid privileges */
@@ -81,27 +82,27 @@ main(int ac, char *av[]) @@ -81,27 +82,27 @@ main(int ac, char *av[])
81 delwin(stdscr); 82 delwin(stdscr);
82 stdscr = Board = newwin(BOARD_Y, BOARD_X, 0, 0); 83 stdscr = Board = newwin(BOARD_Y, BOARD_X, 0, 0);
83 Score = newwin(SCORE_Y, SCORE_X, 0, 40); 84 Score = newwin(SCORE_Y, SCORE_X, 0, 40);
84 Miles = newwin(MILES_Y, MILES_X, 17, 0); 85 Miles = newwin(MILES_Y, MILES_X, 17, 0);
85#ifdef attron 86#ifdef attron
86 idlok(Board, TRUE); 87 idlok(Board, TRUE);
87 idlok(Score, TRUE); 88 idlok(Score, TRUE);
88 idlok(Miles, TRUE); 89 idlok(Miles, TRUE);
89#endif 90#endif
90 leaveok(Score, TRUE); 91 leaveok(Score, TRUE);
91 leaveok(Miles, TRUE); 92 leaveok(Miles, TRUE);
92 clearok(curscr, TRUE); 93 clearok(curscr, TRUE);
93#ifndef PROF 94#ifndef PROF
94 srandom(getpid()); 95 srandom((long) time(NULL));
95#else 96#else
96 srandom(0); 97 srandom(0);
97#endif 98#endif
98 cbreak(); 99 cbreak();
99 noecho(); 100 noecho();
100 signal(SIGINT, rub); 101 signal(SIGINT, rub);
101 for (;;) { 102 for (;;) {
102 if (!restore || (Player[PLAYER].total >= 5000 103 if (!restore || (Player[PLAYER].total >= 5000
103 || Player[COMP].total >= 5000)) { 104 || Player[COMP].total >= 5000)) {
104 if (Player[COMP].total < Player[PLAYER].total) 105 if (Player[COMP].total < Player[PLAYER].total)
105 Player[PLAYER].games++; 106 Player[PLAYER].games++;
106 else if (Player[COMP].total > Player[PLAYER].total) 107 else if (Player[COMP].total > Player[PLAYER].total)
107 Player[COMP].games++; 108 Player[COMP].games++;