summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--games/adventure/init.c6
-rw-r--r--games/adventure/io.c13
-rw-r--r--games/adventure/vocab.c6
-rw-r--r--games/atc/main.c5
-rw-r--r--games/atc/update.c6
-rw-r--r--games/backgammon/common_source/odds.c6
-rw-r--r--games/backgammon/common_source/save.c5
-rw-r--r--games/backgammon/common_source/table.c7
-rw-r--r--games/boggle/boggle/word.c7
-rw-r--r--games/cribbage/support.c6
-rw-r--r--games/hunt/hunt/otto.c19
-rw-r--r--games/hunt/huntd/shots.c10
-rw-r--r--games/mille/comp.c7
-rw-r--r--games/monop/misc.c28
-rw-r--r--games/sail/dr_1.c6
-rw-r--r--games/sail/pl_5.c6
-rw-r--r--games/snake/snscore.c6
-rw-r--r--games/trek/dumpgame.c9
-rw-r--r--games/trek/schedule.c6
19 files changed, 88 insertions, 76 deletions
diff --git a/games/adventure/init.c b/games/adventure/init.c
index cd249bc050a..1dd1bd81053 100644
--- a/games/adventure/init.c
+++ b/games/adventure/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.9 2004/07/09 15:59:26 deraadt Exp $ */
+/* $OpenBSD: init.c,v 1.10 2006/03/27 00:10:14 tedu Exp $ */
/* $NetBSD: init.c,v 1.4 1996/05/21 21:53:05 mrg Exp $ */
/*-
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 6/2/93";
#else
-static char rcsid[] = "$OpenBSD: init.c,v 1.9 2004/07/09 15:59:26 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: init.c,v 1.10 2006/03/27 00:10:14 tedu Exp $";
#endif
#endif /* not lint */
@@ -89,7 +89,7 @@ linkdata(void) /* secondary data manipulation */
int i, j;
/* array linkages */
- for (i = 1; i <= LOCSIZ; i++)
+ for (i = 1; i < LOCSIZ; i++)
if (ltext[i].seekadr != 0 && travel[i] != 0)
if ((travel[i]->tverb) == 1)
cond[i] = 2;
diff --git a/games/adventure/io.c b/games/adventure/io.c
index d2a03f58e88..7bdd2914757 100644
--- a/games/adventure/io.c
+++ b/games/adventure/io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.c,v 1.15 2004/07/09 15:59:26 deraadt Exp $ */
+/* $OpenBSD: io.c,v 1.16 2006/03/27 00:10:14 tedu Exp $ */
/* $NetBSD: io.c,v 1.3 1995/04/24 12:21:37 cgd Exp $ */
/*-
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: io.c,v 1.15 2004/07/09 15:59:26 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: io.c,v 1.16 2006/03/27 00:10:14 tedu Exp $";
#endif
#endif /* not lint */
@@ -378,7 +378,7 @@ rtrav(void) /* read travel table */
if (locc == -1)
return;
if (locc != oldloc) { /* getting a new entry */
- t = travel[locc] = (struct travlist *) malloc(sizeof (struct travlist));
+ t = travel[locc] = calloc(1, sizeof(*t));
if (t == NULL)
err(1, NULL);
/* printf("New travel list for %d\n", locc); */
@@ -400,10 +400,13 @@ rtrav(void) /* read travel table */
m = atoi(buf);
}
while (breakch != LF) { /* only do one line at a time */
+ if (t == NULL)
+ errx(1, "corrupt file");
if (entries++) {
- t = t->next = (struct travlist *) malloc(sizeof (struct travlist));
- if (t == NULL)
+ t->next = calloc(1, sizeof (*t->next));
+ if (t->next == NULL)
err(1, NULL);
+ t = t->next;
}
t->tverb = rnum();/* get verb from the file */
t->tloc = n; /* table entry mod 1000 */
diff --git a/games/adventure/vocab.c b/games/adventure/vocab.c
index 688a1f5b1c8..5b3ed32fbc6 100644
--- a/games/adventure/vocab.c
+++ b/games/adventure/vocab.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vocab.c,v 1.11 2004/07/09 15:59:26 deraadt Exp $ */
+/* $OpenBSD: vocab.c,v 1.12 2006/03/27 00:10:14 tedu Exp $ */
/* $NetBSD: vocab.c,v 1.2 1995/03/21 12:05:13 cgd Exp $ */
/*-
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)vocab.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: vocab.c,v 1.11 2004/07/09 15:59:26 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: vocab.c,v 1.12 2006/03/27 00:10:14 tedu Exp $";
#endif
#endif /* not lint */
@@ -189,7 +189,7 @@ vocab(const char *word, int type, int value)
}
exitloop2: /* hashed entry does not match */
- if (adr + 1 == hash || (adr == HTSIZE && hash == 0))
+ if (adr + 1 == hash || hash == 0)
errx(1, "Hash table overflow");
}
}
diff --git a/games/atc/main.c b/games/atc/main.c
index f2f07e60e7c..6348ac5f245 100644
--- a/games/atc/main.c
+++ b/games/atc/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.13 2005/05/01 02:43:11 djm Exp $ */
+/* $OpenBSD: main.c,v 1.14 2006/03/27 00:10:14 tedu Exp $ */
/* $NetBSD: main.c,v 1.4 1995/04/27 21:22:25 mycroft Exp $ */
/*-
@@ -52,7 +52,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: main.c,v 1.13 2005/05/01 02:43:11 djm Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.14 2006/03/27 00:10:14 tedu Exp $";
#endif
#endif /* not lint */
@@ -265,6 +265,7 @@ default_game(void)
}
if (fgets(line, sizeof(line), fp) == NULL) {
warnx("%s: no default game available", games);
+ fclose(fp);
return (NULL);
}
fclose(fp);
diff --git a/games/atc/update.c b/games/atc/update.c
index ad1e4472704..40f6cbb3a41 100644
--- a/games/atc/update.c
+++ b/games/atc/update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: update.c,v 1.9 2004/11/29 08:52:28 jsg Exp $ */
+/* $OpenBSD: update.c,v 1.10 2006/03/27 00:10:14 tedu Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -45,7 +45,7 @@
#if 0
static char sccsid[] = "@(#)update.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: update.c,v 1.9 2004/11/29 08:52:28 jsg Exp $";
+static char rcsid[] = "$OpenBSD: update.c,v 1.10 2006/03/27 00:10:14 tedu Exp $";
#endif
#endif /* not lint */
@@ -263,7 +263,7 @@ name(const PLANE *p)
int
number(char l)
{
- if (l < 'a' && l > 'z' && l < 'A' && l > 'Z')
+ if ((l < 'a' && l > 'z') || (l < 'A' && l > 'Z'))
return (-1);
else if (l >= 'a' && l <= 'z')
return (l - 'a');
diff --git a/games/backgammon/common_source/odds.c b/games/backgammon/common_source/odds.c
index 6583458d221..68cbb49fa75 100644
--- a/games/backgammon/common_source/odds.c
+++ b/games/backgammon/common_source/odds.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: odds.c,v 1.3 2003/06/03 03:01:38 millert Exp $ */
+/* $OpenBSD: odds.c,v 1.4 2006/03/27 00:10:14 tedu Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -33,7 +33,7 @@
#if 0
static char sccsid[] = "@(#)odds.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: odds.c,v 1.3 2003/06/03 03:01:38 millert Exp $";
+static char rcsid[] = "$OpenBSD: odds.c,v 1.4 2006/03/27 00:10:14 tedu Exp $";
#endif
#endif /* not lint */
@@ -98,7 +98,7 @@ canhit(i, c)
if (board[j] * a > 0) {
diff = abs(j - i);
addon = place + ((board[j] * a > 2 || j == b) ? 5 : 0);
- if ((j == b && menstuck == 1) &&
+ if ((j == b && menstuck == 1) ||
(j != b && menstuck == 0))
for (k = 1; k < diff; k++)
if (k < 7 && diff - k < 7 &&
diff --git a/games/backgammon/common_source/save.c b/games/backgammon/common_source/save.c
index c638663c517..bf05e16b4af 100644
--- a/games/backgammon/common_source/save.c
+++ b/games/backgammon/common_source/save.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: save.c,v 1.8 2003/06/03 03:01:38 millert Exp $ */
+/* $OpenBSD: save.c,v 1.9 2006/03/27 00:10:14 tedu Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -33,7 +33,7 @@
#if 0
static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: save.c,v 1.8 2003/06/03 03:01:38 millert Exp $";
+static char rcsid[] = "$OpenBSD: save.c,v 1.9 2006/03/27 00:10:14 tedu Exp $";
#endif
#endif /* not lint */
@@ -113,7 +113,6 @@ save(n)
}
}
printw("%s%s.\n", cantuse, fname);
- close(fdesc);
cflag = 1;
}
write(fdesc, board, sizeof(board));
diff --git a/games/backgammon/common_source/table.c b/games/backgammon/common_source/table.c
index 2889ddce890..5ecdac6708e 100644
--- a/games/backgammon/common_source/table.c
+++ b/games/backgammon/common_source/table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: table.c,v 1.6 2003/06/03 03:01:38 millert Exp $ */
+/* $OpenBSD: table.c,v 1.7 2006/03/27 00:10:14 tedu Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -33,7 +33,7 @@
#if 0
static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: table.c,v 1.6 2003/06/03 03:01:38 millert Exp $";
+static char rcsid[] = "$OpenBSD: table.c,v 1.7 2006/03/27 00:10:14 tedu Exp $";
#endif
#endif /* not lint */
@@ -253,6 +253,7 @@ rsetbrd()
for (i = 0; i < 4; i++)
p[i] = g[i] = -1;
for (j = 0; j < ncin; j++)
- n = dotable(cin[j], n);
+ if ((n = dotable(cin[j], n)) < 0)
+ return (n);
return(n);
}
diff --git a/games/boggle/boggle/word.c b/games/boggle/boggle/word.c
index 9ab9627dca8..89b8b425a3d 100644
--- a/games/boggle/boggle/word.c
+++ b/games/boggle/boggle/word.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: word.c,v 1.5 2004/07/10 07:26:22 deraadt Exp $ */
+/* $OpenBSD: word.c,v 1.6 2006/03/27 00:10:14 tedu Exp $ */
/* $NetBSD: word.c,v 1.2 1995/03/21 12:14:45 cgd Exp $ */
/*-
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)word.c 8.1 (Berkeley) 6/11/93";
#else
-static char rcsid[] = "$OpenBSD: word.c,v 1.5 2004/07/10 07:26:22 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: word.c,v 1.6 2006/03/27 00:10:14 tedu Exp $";
#endif
#endif /* not lint */
@@ -192,11 +192,13 @@ loadindex(char *indexfile)
while (fgets(buf, sizeof(buf), fp) != NULL) {
if (strchr(buf, '\n') == NULL) {
warnx("A line in the index file is too long");
+ fclose(fp);
return(-1);
}
j = *buf - 'a';
if (i != j) {
warnx("Bad index order");
+ fclose(fp);
return(-1);
}
dictindex[j].start = atol(buf + 1);
@@ -205,6 +207,7 @@ loadindex(char *indexfile)
}
if (i != 26) {
warnx("Bad index length");
+ fclose(fp);
return(-1);
}
(void) fclose(fp);
diff --git a/games/cribbage/support.c b/games/cribbage/support.c
index 80db1399b47..2e29ccdc58d 100644
--- a/games/cribbage/support.c
+++ b/games/cribbage/support.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: support.c,v 1.9 2004/07/10 07:26:23 deraadt Exp $ */
+/* $OpenBSD: support.c,v 1.10 2006/03/27 00:10:15 tedu Exp $ */
/* $NetBSD: support.c,v 1.3 1995/03/21 15:08:59 cgd Exp $ */
/*-
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)support.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: support.c,v 1.9 2004/07/10 07:26:23 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: support.c,v 1.10 2006/03/27 00:10:15 tedu Exp $";
#endif
#endif /* not lint */
@@ -114,6 +114,8 @@ cchose(CARD h[], int n, int s)
break;
}
}
+ if (j < 0)
+ errx("cchose internal error %d %d", j, n);
return (j);
}
diff --git a/games/hunt/hunt/otto.c b/games/hunt/hunt/otto.c
index f323e63d6e2..f14dc295024 100644
--- a/games/hunt/hunt/otto.c
+++ b/games/hunt/hunt/otto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: otto.c,v 1.8 2003/08/07 20:19:10 jolan Exp $ */
+/* $OpenBSD: otto.c,v 1.9 2006/03/27 00:10:15 tedu Exp $ */
/* $NetBSD: otto.c,v 1.2 1997/10/10 16:32:39 lukem Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
@@ -294,7 +294,8 @@ ottolook(rel_dir, itemp)
cont_north:
if (itemp->flags & DEADEND) {
itemp->flags |= BEEN;
- been_there[r][col] |= NORTH;
+ if (r >= 0)
+ been_there[r][col] |= NORTH;
for (r = row - 1; r > row - itemp->distance; r--)
been_there[r][col] = ALLDIRS;
}
@@ -314,7 +315,8 @@ ottolook(rel_dir, itemp)
cont_south:
if (itemp->flags & DEADEND) {
itemp->flags |= BEEN;
- been_there[r][col] |= SOUTH;
+ if (r < HEIGHT)
+ been_there[r][col] |= SOUTH;
for (r = row + 1; r < row + itemp->distance; r++)
been_there[r][col] = ALLDIRS;
}
@@ -553,17 +555,8 @@ wander()
duck(random() % NUMDIRECTIONS);
num_turns = 0;
return;
- } else if (dir_count == 1)
- rel_dir = ffs(dir_mask) - 1;
- else {
+ } else {
rel_dir = ffs(dir_mask) - 1;
- dir_mask &= ~(1 << rel_dir);
- while (dir_mask != 0) {
- i = ffs(dir_mask) - 1;
- if (random() % 5 == 0)
- rel_dir = i;
- dir_mask &= ~(1 << i);
- }
}
if (rel_dir == FRONT)
num_turns++;
diff --git a/games/hunt/huntd/shots.c b/games/hunt/huntd/shots.c
index 03ffa8991e6..00c79c34dad 100644
--- a/games/hunt/huntd/shots.c
+++ b/games/hunt/huntd/shots.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: shots.c,v 1.8 2004/01/16 00:13:19 espie Exp $ */
+/* $OpenBSD: shots.c,v 1.9 2006/03/27 00:10:15 tedu Exp $ */
/* $NetBSD: shots.c,v 1.3 1997/10/11 08:13:50 lukem Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
@@ -378,7 +378,7 @@ move_normal_shot(bp)
pp->p_ident->i_absorbed += bp->b_charge;
/* Deallocate storage: */
- free((char *) bp);
+ free(bp);
/* Update ammo display: */
ammo_update(pp);
@@ -569,7 +569,7 @@ drone_move:
message(pp, "**** Absorbed drone ****");
/* Release drone storage: */
- free((char *) bp);
+ free(bp);
/* Update ammo: */
ammo_update(pp);
@@ -904,7 +904,7 @@ move_slime(bp, speed, next)
if (speed == 0) {
if (bp->b_charge <= 0)
- free((char *) bp);
+ free(bp);
else
save_bullet(bp);
return;
@@ -1046,7 +1046,7 @@ move_slime(bp, speed, next)
move_slime(nbp, speed - 1, next);
}
- free((char *) bp);
+ free(bp);
}
/*
diff --git a/games/mille/comp.c b/games/mille/comp.c
index 37be4c2d6b8..2f5533291bb 100644
--- a/games/mille/comp.c
+++ b/games/mille/comp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: comp.c,v 1.5 2003/06/03 03:01:40 millert Exp $ */
+/* $OpenBSD: comp.c,v 1.6 2006/03/27 00:10:15 tedu Exp $ */
/* $NetBSD: comp.c,v 1.4 1995/03/24 05:01:11 cgd Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)comp.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: comp.c,v 1.5 2003/06/03 03:01:40 millert Exp $";
+static char rcsid[] = "$OpenBSD: comp.c,v 1.6 2006/03/27 00:10:15 tedu Exp $";
#endif
#endif /* not lint */
@@ -342,8 +342,7 @@ normbad:
*value /= ++badcount;
if (op->mileage == 0)
*value += 5;
- if ((card == C_LIMIT &&
- op->speed == C_LIMIT) ||
+ if ((op->speed == C_LIMIT) ||
!op->can_go)
*value -= 5;
if (cango && pp->safety[S_RIGHT_WAY] !=
diff --git a/games/monop/misc.c b/games/monop/misc.c
index 22b71e7f014..112001987a1 100644
--- a/games/monop/misc.c
+++ b/games/monop/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.8 2003/12/16 19:26:44 deraadt Exp $ */
+/* $OpenBSD: misc.c,v 1.9 2006/03/27 00:10:15 tedu Exp $ */
/* $NetBSD: misc.c,v 1.4 1995/03/23 08:34:47 cgd Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 5/31/93";
#else
-static const char rcsid[] = "$OpenBSD: misc.c,v 1.8 2003/12/16 19:26:44 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: misc.c,v 1.9 2006/03/27 00:10:15 tedu Exp $";
#endif
#endif /* not lint */
@@ -204,19 +204,29 @@ set_ownlist(pl)
#ifdef DEBUG
printf("num = %d\n", num);
#endif
- if (orig == 0) {
+ if (orig == NULL) {
printf("panic: bad monopoly descriptor: orig = %p\n", orig);
printf("player # %d\n", pl+1);
printhold(pl);
printf("orig_op = %p\n", orig_op);
- printf("orig_op->sqr->type = %d (PRPTY)\n", op->sqr->type);
- printf("orig_op->next = %p\n", op->next);
- printf("orig_op->sqr->desc = %p\n", op->sqr->desc);
+ if (orig_op) {
+ printf("orig_op->sqr->type = %d (PRPTY)\n",
+ orig_op->sqr->type);
+ printf("orig_op->next = %p\n",
+ orig_op->next);
+ printf("orig_op->sqr->desc = %p\n",
+ orig_op->sqr->desc);
+ }
printf("op = %p\n", op);
- printf("op->sqr->type = %d (PRPTY)\n", op->sqr->type);
- printf("op->next = %p\n", op->next);
- printf("op->sqr->desc = %p\n", op->sqr->desc);
+ if (op) {
+ printf("op->sqr->type = %d (PRPTY)\n",
+ op->sqr->type);
+ printf("op->next = %p\n", op->next);
+ printf("op->sqr->desc = %p\n",
+ op->sqr->desc);
+ }
printf("num = %d\n", num);
+ exit(1);
}
#ifdef DEBUG
printf("orig->num_in = %d\n", orig->num_in);
diff --git a/games/sail/dr_1.c b/games/sail/dr_1.c
index 8d241aa57f5..107fc7130cc 100644
--- a/games/sail/dr_1.c
+++ b/games/sail/dr_1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dr_1.c,v 1.4 2003/06/03 03:01:41 millert Exp $ */
+/* $OpenBSD: dr_1.c,v 1.5 2006/03/27 00:10:15 tedu Exp $ */
/* $NetBSD: dr_1.c,v 1.4 1995/04/24 12:25:10 cgd Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)dr_1.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: dr_1.c,v 1.4 2003/06/03 03:01:41 millert Exp $";
+static char rcsid[] = "$OpenBSD: dr_1.c,v 1.5 2006/03/27 00:10:15 tedu Exp $";
#endif
#endif /* not lint */
@@ -419,7 +419,7 @@ next()
bestship = s;
}
}
- if (best > 0.0) {
+ if (bestship) {
char *tp = getenv("WOTD");
const char *p;
if (tp == 0)
diff --git a/games/sail/pl_5.c b/games/sail/pl_5.c
index 61efa40d315..2fb27a9bbdd 100644
--- a/games/sail/pl_5.c
+++ b/games/sail/pl_5.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pl_5.c,v 1.4 2003/06/03 03:01:41 millert Exp $ */
+/* $OpenBSD: pl_5.c,v 1.5 2006/03/27 00:10:15 tedu Exp $ */
/* $NetBSD: pl_5.c,v 1.4 1995/04/24 12:25:21 cgd Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pl_5.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: pl_5.c,v 1.4 2003/06/03 03:01:41 millert Exp $";
+static char rcsid[] = "$OpenBSD: pl_5.c,v 1.5 2006/03/27 00:10:15 tedu Exp $";
#endif
#endif /* not lint */
@@ -214,7 +214,7 @@ parties(crew, to, isdefense, buf)
ptr = isdefense ? to->file->DBP : to->file->OBP;
for (j = 0; j < NBP && ptr[j].turnsent; j++)
;
- if (!ptr[j].turnsent && buf > '0') {
+ if (j < NBP && buf > '0') {
men = 0;
for (k = 0; k < 3 && buf > '0'; k++) {
men += crew[k]
diff --git a/games/snake/snscore.c b/games/snake/snscore.c
index 1dff641784f..3dafc2cb34c 100644
--- a/games/snake/snscore.c
+++ b/games/snake/snscore.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: snscore.c,v 1.5 2004/07/10 07:26:24 deraadt Exp $ */
+/* $OpenBSD: snscore.c,v 1.6 2006/03/27 00:10:15 tedu Exp $ */
/* $NetBSD: snscore.c,v 1.5 1995/04/24 12:25:43 cgd Exp $ */
/*
@@ -40,7 +40,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)snscore.c 8.1 (Berkeley) 7/19/93";
#else
-static char rcsid[] = "$OpenBSD: snscore.c,v 1.5 2004/07/10 07:26:24 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: snscore.c,v 1.6 2006/03/27 00:10:15 tedu Exp $";
#endif
#endif /* not lint */
@@ -89,7 +89,7 @@ snscore(int fd, int topn)
if (read(fd, &score, sizeof(short)) == 0)
break;
if (score > 0) {
- if (noplayers > MAXPLAYERS)
+ if (noplayers >= MAXPLAYERS)
errx(2, "Too many entries in scorefile!");
players[noplayers].uids = uid;
players[noplayers].scores = score;
diff --git a/games/trek/dumpgame.c b/games/trek/dumpgame.c
index 45ada426cc3..511ebdaf7e2 100644
--- a/games/trek/dumpgame.c
+++ b/games/trek/dumpgame.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dumpgame.c,v 1.7 2003/06/03 03:01:41 millert Exp $ */
+/* $OpenBSD: dumpgame.c,v 1.8 2006/03/27 00:10:15 tedu Exp $ */
/* $NetBSD: dumpgame.c,v 1.4 1995/04/24 12:25:54 cgd Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)dumpgame.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: dumpgame.c,v 1.7 2003/06/03 03:01:41 millert Exp $";
+static char rcsid[] = "$OpenBSD: dumpgame.c,v 1.8 2006/03/27 00:10:15 tedu Exp $";
#endif
#endif /* not lint */
@@ -125,13 +125,14 @@ restartgame()
{
int fd, version;
- if ((fd = open("trek.dump", O_RDONLY)) < 0 ||
+ if ((fd = open("trek.dump", O_RDONLY)) == -1 ||
read(fd, &version, sizeof version) != sizeof version ||
version != VERSION ||
readdump(fd))
{
printf("cannot restart\n");
- close(fd);
+ if (fd != -1)
+ close(fd);
return (1);
}
diff --git a/games/trek/schedule.c b/games/trek/schedule.c
index efa5804cde4..09f53867f9f 100644
--- a/games/trek/schedule.c
+++ b/games/trek/schedule.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: schedule.c,v 1.4 2003/06/03 03:01:42 millert Exp $ */
+/* $OpenBSD: schedule.c,v 1.5 2006/03/27 00:10:15 tedu Exp $ */
/* $NetBSD: schedule.c,v 1.3 1995/04/22 10:59:23 cgd Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)schedule.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: schedule.c,v 1.4 2003/06/03 03:01:42 millert Exp $";
+static char rcsid[] = "$OpenBSD: schedule.c,v 1.5 2006/03/27 00:10:15 tedu Exp $";
#endif
#endif /* not lint */
@@ -81,7 +81,7 @@ schedule(type, offset, x, y, z)
e->x = x;
e->y = y;
e->systemname = z;
- Now.eventptr[type] = e;
+ Now.eventptr[type & E_EVENT] = e;
return (e);
}
errx(1, "Cannot schedule event %d parm %d %d %d", type, x, y, z);