Build with WARNS=4. Sort out the game's shadowing of its own variables,

which fixes at least one bug.
This commit is contained in:
dholland 2008-01-28 01:58:01 +00:00
parent 05b25a6836
commit a627b0395f
7 changed files with 68 additions and 66 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.13 2000/06/11 15:37:51 mycroft Exp $
# $NetBSD: Makefile,v 1.14 2008/01/28 01:58:01 dholland Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= sail
@ -10,5 +10,6 @@ DPADD= ${LIBCURSES}
LDADD= -lcurses
HIDEGAME=hidegame
SETGIDGAME=yes
WARNS= 4
.include <bsd.prog.mk>

View File

@ -1,4 +1,4 @@
/* $NetBSD: dr_1.c,v 1.22 2006/03/19 00:41:46 christos Exp $ */
/* $NetBSD: dr_1.c,v 1.23 2008/01/28 01:58:01 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)dr_1.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: dr_1.c,v 1.22 2006/03/19 00:41:46 christos Exp $");
__RCSID("$NetBSD: dr_1.c,v 1.23 2008/01/28 01:58:01 dholland Exp $");
#endif
#endif /* not lint */
@ -142,7 +142,7 @@ fightitout(struct ship *from, struct ship *to, int key)
int crewfrom[3], crewto[3], menfrom, mento;
int pcto, pcfrom, fromstrength, strengthto, frominjured, toinjured;
int topoints;
int index, totalfrom = 0, totalto = 0;
int indx, totalfrom = 0, totalto = 0;
int count;
char message[60];
@ -170,15 +170,15 @@ fightitout(struct ship *from, struct ship *to, int key)
((fromstrength < strengthto * 3 && strengthto < fromstrength * 3)
|| fromstrength == -1) && count < 4;
count++) {
index = fromstrength/10;
if (index > 8)
index = 8;
toinjured = MT[index][2 - dieroll() / 3];
indx = fromstrength/10;
if (indx > 8)
indx = 8;
toinjured = MT[indx][2 - dieroll() / 3];
totalto += toinjured;
index = strengthto/10;
if (index > 8)
index = 8;
frominjured = MT[index][2 - dieroll() / 3];
indx = strengthto/10;
if (indx > 8)
indx = 8;
frominjured = MT[indx][2 - dieroll() / 3];
totalfrom += frominjured;
menfrom -= frominjured;
mento -= toinjured;
@ -273,7 +273,7 @@ compcombat(void)
struct ship *closest;
int crew[3], men = 0, target, temp;
int r, guns, ready, load, car;
int index, rakehim, sternrake;
int indx, rakehim, sternrake;
int shootat, hit;
foreachship(sp) {
@ -345,21 +345,21 @@ compcombat(void)
if (temp > 8)
temp -= 8;
sternrake = temp > 4 && temp < 6;
index = guns;
indx = guns;
if (target < 3)
index += car;
index = (index - 1) / 3;
index = index > 8 ? 8 : index;
indx += car;
indx = (indx - 1) / 3;
indx = indx > 8 ? 8 : indx;
if (!rakehim)
hit = HDT[index][target-1];
hit = HDT[indx][target-1];
else
hit = HDTrake[index][target-1];
hit = HDTrake[indx][target-1];
if (rakehim && sternrake)
hit++;
hit += QUAL[index][capship(sp)->specs->qual - 1];
hit += QUAL[indx][capship(sp)->specs->qual - 1];
for (n = 0; n < 3 && sp->file->captured == 0; n++)
if (!crew[n]) {
if (index <= 5)
if (indx <= 5)
hit--;
else
hit -= 2;
@ -369,18 +369,18 @@ compcombat(void)
sp->file->readyL &= ~R_INITIAL;
else
sp->file->readyR &= ~R_INITIAL;
if (index <= 3)
if (indx <= 3)
hit++;
else
hit += 2;
}
if (sp->file->captured != 0) {
if (index <= 1)
if (indx <= 1)
hit--;
else
hit -= 2;
}
hit += AMMO[index][load - 1];
hit += AMMO[indx][load - 1];
temp = sp->specs->class;
if ((temp >= 5 || temp == 1) && windspeed == 5)
hit--;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lo_main.c,v 1.12 2003/08/07 09:37:43 agc Exp $ */
/* $NetBSD: lo_main.c,v 1.13 2008/01/28 01:58:01 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)lo_main.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: lo_main.c,v 1.12 2003/08/07 09:37:43 agc Exp $");
__RCSID("$NetBSD: lo_main.c,v 1.13 2008/01/28 01:58:01 dholland Exp $");
#endif
#endif /* not lint */
@ -61,7 +61,7 @@ lo_main(void)
{
FILE *fp;
char sbuf[32];
int n = 0, people;
int n = 0, npeople;
struct passwd *pass;
struct logs log;
struct ship *ship;
@ -70,7 +70,7 @@ lo_main(void)
perror(_PATH_LOGFILE);
exit(1);
}
switch (fread((char *)&people, sizeof people, 1, fp)) {
switch (fread((char *)&npeople, sizeof npeople, 1, fp)) {
case 0:
printf("Nobody has sailed yet.\n");
exit(0);
@ -91,6 +91,6 @@ lo_main(void)
title[n++], sbuf, ship->shipname, log.l_netpoints,
(float) log.l_netpoints / ship->specs->pts);
}
printf("\n%d people have played.\n", people);
printf("\n%d people have played.\n", npeople);
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.h,v 1.5 2003/08/07 09:37:43 agc Exp $ */
/* $NetBSD: machdep.h,v 1.6 2008/01/28 01:58:01 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@ -36,15 +36,15 @@
/* for POSIX systems */
#define blockalarm() \
do { \
sigset_t sigset; \
sigemptyset(&sigset); \
sigaddset(&sigset, SIGALRM); \
sigprocmask(SIG_BLOCK, &sigset, (sigset_t *)0); \
sigset_t set; \
sigemptyset(&set); \
sigaddset(&set, SIGALRM); \
sigprocmask(SIG_BLOCK, &set, (sigset_t *)0); \
} while (0)
#define unblockalarm() \
do { \
sigset_t sigset; \
sigemptyset(&sigset); \
sigaddset(&sigset, SIGALRM); \
sigprocmask(SIG_UNBLOCK, &sigset, (sigset_t *)0); \
sigset_t set; \
sigemptyset(&set); \
sigaddset(&set, SIGALRM); \
sigprocmask(SIG_UNBLOCK, &set, (sigset_t *)0); \
} while (0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: misc.c,v 1.15 2004/11/05 21:30:32 dsl Exp $ */
/* $NetBSD: misc.c,v 1.16 2008/01/28 01:58:01 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.15 2004/11/05 21:30:32 dsl Exp $");
__RCSID("$NetBSD: misc.c,v 1.16 2008/01/28 01:58:01 dholland Exp $");
#endif
#endif /* not lint */
@ -106,27 +106,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;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pl_5.c,v 1.18 2006/03/18 01:43:52 abs Exp $ */
/* $NetBSD: pl_5.c,v 1.19 2008/01/28 01:58:01 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pl_5.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: pl_5.c,v 1.18 2006/03/18 01:43:52 abs Exp $");
__RCSID("$NetBSD: pl_5.c,v 1.19 2008/01/28 01:58:01 dholland Exp $");
#endif
#endif /* not lint */
@ -59,7 +59,7 @@ acceptmove(void)
char af;
int moved = 0;
int vma, dir;
char prompt[60];
char promptstr[60];
char buf[60], last = '\0';
char *p;
@ -70,8 +70,9 @@ acceptmove(void)
ta = maxturns(ms, &af);
ma = maxmove(ms, mf->dir, 0);
sprintf(prompt, "move (%d,%c%d): ", ma, af ? '\'' : ' ', ta);
sgetstr(prompt, buf, sizeof buf);
snprintf(promptstr, sizeof(promptstr),
"move (%d,%c%d): ", ma, af ? '\'' : ' ', ta);
sgetstr(promptstr, buf, sizeof buf);
dir = mf->dir;
vma = ma;
for (p = buf; *p; p++)

View File

@ -1,4 +1,4 @@
/* $NetBSD: sync.c,v 1.24 2006/05/18 18:42:59 mrg Exp $ */
/* $NetBSD: sync.c,v 1.25 2008/01/28 01:58:01 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)sync.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: sync.c,v 1.24 2006/05/18 18:42:59 mrg Exp $");
__RCSID("$NetBSD: sync.c,v 1.25 2008/01/28 01:58:01 dholland Exp $");
#endif
#endif /* not lint */
@ -118,13 +118,13 @@ makemsg(struct ship *from, const char *fmt, ...)
}
int
sync_exists(int game)
sync_exists(int gamenum)
{
char buf[sizeof sync_file];
struct stat s;
time_t t;
sprintf(buf, SF, game);
sprintf(buf, SF, gamenum);
time(&t);
setegid(egid);
if (stat(buf, &s) < 0) {
@ -133,7 +133,7 @@ sync_exists(int game)
}
if (s.st_mtime < t - 60*60*2) { /* 2 hours */
unlink(buf);
sprintf(buf, LF, game);
sprintf(buf, LF, gamenum);
unlink(buf);
setegid(gid);
return 0;
@ -166,11 +166,11 @@ sync_open(void)
}
void
sync_close(int remove)
sync_close(int doremove)
{
if (sync_fp != 0)
fclose(sync_fp);
if (remove) {
if (doremove) {
setegid(egid);
unlink(sync_file);
setegid(gid);
@ -251,13 +251,13 @@ Sync(void)
if (isstr != 0 && isstr != 1)
goto bad;
if (isstr) {
int c;
int ch;
char *p;
for (p = buf;;) {
c = getc(sync_fp);
*p++ = (char)c;
switch (c) {
ch = getc(sync_fp);
*p++ = (char)ch;
switch (ch) {
case '\n':
p--;
case EOF: