-/* $OpenBSD: extern.h,v 1.7 2013/10/25 21:57:10 millert Exp $ */
+/* $OpenBSD: extern.h,v 1.8 2014/07/13 14:01:04 tedu Exp $ */
/* $NetBSD: extern.h,v 1.4 1995/04/27 21:22:22 mycroft Exp $ */
/*-
int read_file(const char *);
void redraw(void);
void rezero(void);
+void setseed(const char *);
void setup_screen(const C_SCREEN *);
int too_close(const PLANE *p1, const PLANE *p2, int);
void update(int);
-/* $OpenBSD: main.c,v 1.22 2014/07/13 13:00:40 tedu Exp $ */
+/* $OpenBSD: main.c,v 1.23 2014/07/13 14:01:04 tedu Exp $ */
/* $NetBSD: main.c,v 1.4 1995/04/27 21:22:25 mycroft Exp $ */
/*-
}
}
if (seed != NULL)
- srandom(atol(seed));
- else
- srandomdev();
+ setseed(seed);
if (f_usage)
fprintf(stderr,
-/* $OpenBSD: update.c,v 1.13 2014/07/13 13:00:40 tedu Exp $ */
+/* $OpenBSD: update.c,v 1.14 2014/07/13 14:01:04 tedu Exp $ */
/*-
* Copyright (c) 1990, 1993
#include "include.h"
+int seeded;
+void
+setseed(const char *seed)
+{
+ seeded = 1;
+ srandom(atol(seed));
+}
+
+uint32_t
+atcrandom()
+{
+ if (seeded)
+ return random();
+ else
+ return arc4random();
+}
+
void
update(int dummy)
{
* Otherwise, prop jobs show up *on* entrance. Remember that
* we don't update props on odd updates.
*/
- if ((random() % sp->newplane_time) == 0)
+ if ((atcrandom() % sp->newplane_time) == 0)
addplane();
}
memset(&p, 0, sizeof (p));
p.status = S_MARKED;
- p.plane_type = random() % 2;
+ p.plane_type = atcrandom() % 2;
num_starts = sp->num_exits + sp->num_airports;
- rnd = random() % num_starts;
+ rnd = atcrandom() % num_starts;
if (rnd < sp->num_exits) {
p.dest_type = T_EXIT;
/* loop until we get a plane not near another */
for (i = 0; i < num_starts; i++) {
/* loop till we get a different start point */
- while ((rnd2 = random() % num_starts) == rnd)
+ while ((rnd2 = atcrandom() % num_starts) == rnd)
;
if (rnd2 < sp->num_exits) {
p.orig_type = T_EXIT;