+/* $NetBSD: update.c,v 1.7 1998/09/11 12:53:29 hubertf Exp $ */
+
/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ed James.
* For more info on this and all of my stuff, mail edjames@berkeley.edu.
*/
+#include <sys/cdefs.h>
#ifndef lint
-static char sccsid[] = "@(#)update.c 5.5 (Berkeley) 10/30/90";
+#if 0
+static char sccsid[] = "@(#)update.c 8.1 (Berkeley) 5/31/93";
+#else
+__RCSID("$NetBSD: update.c,v 1.7 1998/09/11 12:53:29 hubertf Exp $");
+#endif
#endif not lint
#include "include.h"
-update()
+void
+update(dummy)
+ int dummy;
{
- int i, dir_diff, mask, unclean;
- PLANE *pp, *p1, *p2, *p;
+ int i, dir_diff, unclean;
+ PLANE *pp, *p1, *p2;
-#ifdef BSD
- mask = sigblock(sigmask(SIGINT));
-#endif
#ifdef SYSV
alarm(0);
signal(SIGALRM, update);
if ((rand() % sp->newplane_time) == 0)
addplane();
-#ifdef BSD
- sigsetmask(mask);
-#endif
#ifdef SYSV
alarm(sp->update_secs);
#endif
PLANE *pp;
{
static char buf[50], *bp, *comm_start;
- char *index();
buf[0] = '\0';
bp = buf;
(pp->fuel < LOWFUEL) ? '*' : ' ',
(pp->dest_type == T_AIRPORT) ? 'A' : 'E', pp->dest_no);
- comm_start = bp = index(buf, '\0');
+ comm_start = bp = strchr(buf, '\0');
if (pp->altitude == 0)
(void)sprintf(bp, "Holding @ A%d", pp->orig_no);
else if (pp->new_dir >= MAXDIR || pp->new_dir < 0)
else if (pp->new_dir != pp->dir)
(void)sprintf(bp, "%d", dir_deg(pp->new_dir));
- bp = index(buf, '\0');
+ bp = strchr(buf, '\0');
if (pp->delayd)
(void)sprintf(bp, " @ B%d", pp->delayd_no);
- bp = index(buf, '\0');
+ bp = strchr(buf, '\0');
if (*comm_start == '\0' &&
(pp->status == S_UNMARKED || pp->status == S_IGNORED))
strcpy(bp, "---------");
return (buf);
}
-/* char */
+char
name(p)
PLANE *p;
{
return ('a' + p->plane_no);
}
+int
number(l)
+ char l;
{
if (l < 'a' && l > 'z' && l < 'A' && l > 'Z')
return (-1);
return (l - 'A');
}
+int
next_plane()
{
static int last_plane = -1;
return (last_plane);
}
+int
addplane()
{
PLANE p, *pp, *p1;
int i, num_starts, close, rnd, rnd2, pnum;
- bzero(&p, sizeof (p));
+ memset(&p, 0, sizeof (p));
p.status = S_MARKED;
p.plane_type = random() % 2;
p.plane_no = pnum;
pp = newplane();
- bcopy(&p, pp, sizeof (p));
+ memcpy(pp, &p, sizeof (p));
if (pp->orig_type == T_AIRPORT)
append(&ground, pp);
PLANE *
findplane(n)
+ int n;
{
PLANE *pp;
return (NULL);
}
+int
too_close(p1, p2, dist)
PLANE *p1, *p2;
+ int dist;
{
if (ABS(p1->altitude - p2->altitude) <= dist &&
ABS(p1->xpos - p2->xpos) <= dist && ABS(p1->ypos - p2->ypos) <= dist)
return (0);
}
+int
dir_deg(d)
+ int d;
{
switch (d) {
case 0: return (0);