-/* $NetBSD: rnd_pos.c,v 1.4 1997/10/12 14:10:02 lukem Exp $ */
+/* $NetBSD: rnd_pos.c,v 1.10 2009/08/12 08:30:55 dholland Exp $ */
/*
* Copyright (c) 1980, 1993
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
#if 0
static char sccsid[] = "@(#)rnd_pos.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: rnd_pos.c,v 1.4 1997/10/12 14:10:02 lukem Exp $");
+__RCSID("$NetBSD: rnd_pos.c,v 1.10 2009/08/12 08:30:55 dholland Exp $");
#endif
#endif /* not lint */
-# include "robots.h"
+#include <curses.h>
+#include <stdlib.h>
+#include "robots.h"
-# define IS_SAME(p,y,x) ((p).y != -1 && (p).y == y && (p).x == x)
+#define IS_SAME(p,y,x) ((p).y != -1 && (p).y == y && (p).x == x)
+
+static int rnd(int);
/*
* rnd_pos:
* Pick a random, unoccupied position
*/
COORD *
-rnd_pos()
+rnd_pos(void)
{
- static COORD pos;
- static int call = 0;
+ static COORD pos;
+ static int call = 0;
do {
pos.y = rnd(Y_FIELDSIZE - 1) + 1;
return &pos;
}
-int
-rnd(range)
- int range;
+static int
+rnd(int range)
{
- return rand() % range;
+ return random() % range;
}