X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/94d9f7fcc59fe7e9cd723a48abcf4564575862cc..da6a856c31649c6fc011d45d51542876e1b13539:/atc/update.c diff --git a/atc/update.c b/atc/update.c index 197077ff..b736624a 100644 --- a/atc/update.c +++ b/atc/update.c @@ -1,4 +1,4 @@ -/* $NetBSD: update.c,v 1.22 2011/02/15 08:25:25 is Exp $ */ +/* $NetBSD: update.c,v 1.27 2015/06/25 05:33:02 dholland Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -46,11 +46,19 @@ #if 0 static char sccsid[] = "@(#)update.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: update.c,v 1.22 2011/02/15 08:25:25 is Exp $"); +__RCSID("$NetBSD: update.c,v 1.27 2015/06/25 05:33:02 dholland Exp $"); #endif #endif /* not lint */ -#include "include.h" +#include +#include +#include +#include + +#include "def.h" +#include "struct.h" +#include "extern.h" +#include "tunable.h" static int next_plane(void); static int too_close(const PLANE *p1, const PLANE *p2, int); @@ -60,7 +68,8 @@ static int dir_deg(int); void update(int dummy __unused) { - int i, dir_diff, unclean; + int dir_diff, unclean; + unsigned i; PLANE *pp, *p1, *p2; #ifdef SYSV @@ -123,7 +132,7 @@ update(int dummy __unused) if (pp->delayd && pp->xpos == sp->beacon[pp->delayd_no].x && pp->ypos == sp->beacon[pp->delayd_no].y) { - pp->delayd = 0; + pp->delayd = false; if (pp->status == S_UNMARKED) pp->status = S_MARKED; } @@ -216,13 +225,39 @@ update(int dummy __unused) * we don't update props on odd updates. */ if ((rand() % sp->newplane_time) == 0) - (void)addplane(); + addplane(); #ifdef SYSV alarm(sp->update_secs); #endif } +void +loser(const PLANE *p, const char *s) +{ + int c; +#ifdef BSD + struct itimerval itv; +#endif + + /* disable timer */ +#ifdef BSD + itv.it_value.tv_sec = 0; + itv.it_value.tv_usec = 0; + (void)setitimer(ITIMER_REAL, &itv, NULL); +#endif +#ifdef SYSV + alarm(0); +#endif + + losermsg(p, s); + while ((c = getAChar()) != EOF && c != ' ') + ; + shutdown_gr(); + (void)log_score(0); + exit(0); +} + const char * command(const PLANE *pp) { @@ -232,14 +267,14 @@ command(const PLANE *pp) buf[0] = '\0'; bp = buf; bpsize = sizeof(buf); - (void)snprintf(bp, bpsize, "%c%d%c%c%d: ", name(pp), pp->altitude, + (void)snprintf(bp, bpsize, "%c%d%c%c%u: ", name(pp), pp->altitude, (pp->fuel < LOWFUEL) ? '*' : ' ', (pp->dest_type == T_AIRPORT) ? 'A' : 'E', pp->dest_no); comm_start = bp = strchr(buf, '\0'); bpsize = buf + sizeof(buf) - bp; if (pp->altitude == 0) - (void)snprintf(bp, bpsize, "Holding @ A%d", pp->orig_no); + (void)snprintf(bp, bpsize, "Holding @ A%u", pp->orig_no); else if (pp->new_dir >= MAXDIR || pp->new_dir < 0) (void)snprintf(bp, bpsize, "Circle"); else if (pp->new_dir != pp->dir) @@ -248,7 +283,7 @@ command(const PLANE *pp) bp = strchr(buf, '\0'); bpsize = buf + sizeof(buf) - bp; if (pp->delayd) - (void)snprintf(bp, bpsize, " @ B%d", pp->delayd_no); + (void)snprintf(bp, bpsize, " @ B%u", pp->delayd_no); bp = strchr(buf, '\0'); bpsize = buf + sizeof(buf) - bp; @@ -307,11 +342,12 @@ next_plane(void) return (last_plane); } -int +void addplane(void) { PLANE p, *pp, *p1; - int i, num_starts, isclose, rnd, rnd2, pnum; + int isclose, pnum; + unsigned num_starts, rnd, rnd2, i; (void)memset(&p, 0, sizeof (p)); @@ -361,10 +397,10 @@ addplane(void) break; } if (i >= num_starts) - return (-1); + return; pnum = next_plane(); if (pnum < 0) - return (-1); + return; p.plane_no = pnum; pp = newplane(); @@ -376,8 +412,6 @@ addplane(void) append(&ground, pp); else append(&air, pp); - - return (pp->dest_type); } PLANE *