X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/80c0ba03f49e892862ae80118ab5455c8256b0ab..4fa17c6f9afc7c76d0350d5d9e5996391aa18137:/sail/misc.c?ds=inline diff --git a/sail/misc.c b/sail/misc.c index d576b35e..ac94e295 100644 --- a/sail/misc.c +++ b/sail/misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: misc.c,v 1.14 2004/02/08 00:32:48 jsm Exp $ */ +/* $NetBSD: misc.c,v 1.18 2009/03/14 19:35:13 dholland Exp $ */ /* * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)misc.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: misc.c,v 1.14 2004/02/08 00:32:48 jsm Exp $"); +__RCSID("$NetBSD: misc.c,v 1.18 2009/03/14 19:35:13 dholland Exp $"); #endif #endif /* not lint */ @@ -46,9 +46,10 @@ __RCSID("$NetBSD: misc.c,v 1.14 2004/02/08 00:32:48 jsm Exp $"); #include "extern.h" #include "pathnames.h" -#define distance(x,y) (abs(x) >= abs(y) ? abs(x) + abs(y)/2 : abs(y) + abs(x)/2) +#define distance(x,y) \ + (abs(x) >= abs(y) ? abs(x) + abs(y)/2 : abs(y) + abs(x)/2) -static int angle(int, int); +static int angle(int, int); /* XXX */ int @@ -106,27 +107,27 @@ closestenemy(struct ship *from, int side, int anyship) } static int -angle(int dr, int dc) +angle(int Dr, int Dc) { int i; - if (dc >= 0 && dr > 0) + if (Dc >= 0 && Dr > 0) i = 0; - else if (dr <= 0 && dc > 0) + else if (Dr <= 0 && Dc > 0) i = 2; - else if (dc <= 0 && dr < 0) + else if (Dc <= 0 && Dr < 0) i = 4; else i = 6; - dr = abs(dr); - dc = abs(dc); - if ((i == 0 || i == 4) && dc * 2.4 > dr) { + Dr = abs(Dr); + Dc = abs(Dc); + if ((i == 0 || i == 4) && Dc * 2.4 > Dr) { i++; - if (dc > dr * 2.4) + if (Dc > Dr * 2.4) i++; - } else if ((i == 2 || i == 6) && dr * 2.4 > dc) { + } else if ((i == 2 || i == 6) && Dr * 2.4 > Dc) { i++; - if (dr > dc * 2.4) + if (Dr > Dc * 2.4) i++; } return i % 8 + 1; @@ -188,7 +189,7 @@ colours(struct ship *sp) if (sp->file->struck) return flag; flag = *countryname[capship(sp)->nationality]; - return sp->file->FS ? flag : tolower(flag); + return sp->file->FS ? flag : tolower((unsigned char)flag); } void @@ -213,7 +214,7 @@ logger(struct ship *s) #endif net = (float)s->file->points / s->specs->pts; persons = getw(fp); - n = fread((char *)log, sizeof(struct logs), NLOG, fp); + n = fread(log, sizeof(struct logs), NLOG, fp); for (lp = &log[n]; lp < &log[NLOG]; lp++) lp->l_name[0] = lp->l_uid = lp->l_shipnum = lp->l_gamenum = lp->l_netpoints = 0; @@ -225,14 +226,14 @@ logger(struct ship *s) for (lp = log; lp < &log[NLOG]; lp++) if (net > (float)lp->l_netpoints / scene[lp->l_gamenum].ship[lp->l_shipnum].specs->pts) { - fwrite((char *)log, sizeof (struct logs), lp - log, fp); + fwrite(log, sizeof (struct logs), lp - log, fp); strcpy(log[NLOG-1].l_name, s->file->captain); log[NLOG-1].l_uid = getuid(); log[NLOG-1].l_shipnum = s->file->index; log[NLOG-1].l_gamenum = game; log[NLOG-1].l_netpoints = s->file->points; - fwrite((char *)&log[NLOG-1], sizeof (struct logs), 1, fp); - fwrite((char *)lp, sizeof (struct logs), &log[NLOG-1] - lp, fp); + fwrite(&log[NLOG-1], sizeof (struct logs), 1, fp); + fwrite(lp, sizeof (struct logs), &log[NLOG-1] - lp, fp); break; } #ifdef LOCK_EX