-/* $NetBSD: rnd_pos.c,v 1.5 2003/08/07 09:37:37 agc Exp $ */
+/* $NetBSD: rnd_pos.c,v 1.11 2020/07/26 15:38:22 nia Exp $ */
/*
* Copyright (c) 1980, 1993
#if 0
static char sccsid[] = "@(#)rnd_pos.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: rnd_pos.c,v 1.5 2003/08/07 09:37:37 agc Exp $");
+__RCSID("$NetBSD: rnd_pos.c,v 1.11 2020/07/26 15:38:22 nia 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)
/*
* 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;
- pos.x = rnd(X_FIELDSIZE - 1) + 1;
+ pos.y = arc4random_uniform(Y_FIELDSIZE - 1) + 1;
+ pos.x = arc4random_uniform(X_FIELDSIZE - 1) + 1;
refresh();
} while (Field[pos.y][pos.x] != 0);
call++;
return &pos;
}
-
-int
-rnd(range)
- int range;
-{
-
- return rand() % range;
-}