summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--games/arithmetic/arithmetic.612
-rw-r--r--games/arithmetic/arithmetic.c6
-rw-r--r--games/banner/banner.69
-rw-r--r--games/banner/banner.c25
-rw-r--r--games/bcd/bcd.c20
-rw-r--r--games/cribbage/cards.c17
-rw-r--r--games/cribbage/crib.c36
-rw-r--r--games/cribbage/cribbage.64
-rw-r--r--games/cribbage/instr.c16
-rw-r--r--games/cribbage/io.c53
-rw-r--r--games/cribbage/score.c37
-rw-r--r--games/cribbage/support.c25
-rw-r--r--games/factor/factor.612
-rw-r--r--games/factor/factor.c5
-rw-r--r--games/hangman/endgame.c18
-rw-r--r--games/hangman/extern.c25
-rw-r--r--games/hangman/getguess.c42
-rw-r--r--games/hangman/getword.c6
-rw-r--r--games/hangman/hangman.66
-rw-r--r--games/hangman/hangman.h70
-rw-r--r--games/hangman/main.c13
-rw-r--r--games/hangman/playgame.c6
-rw-r--r--games/hangman/prdata.c6
-rw-r--r--games/hangman/prman.c6
-rw-r--r--games/hangman/prword.c6
-rw-r--r--games/hangman/setup.c12
-rw-r--r--games/number/number.69
-rw-r--r--games/pig/pig.66
-rw-r--r--games/pig/pig.c33
-rw-r--r--games/ppt/ppt.c10
-rw-r--r--games/primes/primes.c9
-rw-r--r--games/quiz/datfiles/collectives2
-rw-r--r--games/quiz/datfiles/elements2
-rw-r--r--games/quiz/pathnames.h1
-rw-r--r--games/quiz/quiz.616
-rw-r--r--games/quiz/quiz.c65
-rw-r--r--games/quiz/quiz.h1
-rw-r--r--games/quiz/rxp.c13
-rw-r--r--games/rain/rain.612
-rw-r--r--games/rain/rain.c53
-rw-r--r--games/trek/Makefile7
-rw-r--r--games/trek/abandon.c22
-rw-r--r--games/trek/attack.c24
-rw-r--r--games/trek/autover.c7
-rw-r--r--games/trek/capture.c20
-rw-r--r--games/trek/cgetc.c10
-rw-r--r--games/trek/check_out.c9
-rw-r--r--games/trek/checkcond.c9
-rw-r--r--games/trek/compkl.c18
-rw-r--r--games/trek/computer.c58
-rw-r--r--games/trek/damage.c14
-rw-r--r--games/trek/damaged.c8
-rw-r--r--games/trek/dcrept.c10
-rw-r--r--games/trek/destruct.c24
-rw-r--r--games/trek/dock.c26
-rw-r--r--games/trek/dumpgame.c44
-rw-r--r--games/trek/dumpme.c11
-rw-r--r--games/trek/dumpssradio.c11
-rw-r--r--games/trek/events.c30
-rw-r--r--games/trek/externs.c37
-rw-r--r--games/trek/getcodi.c12
-rw-r--r--games/trek/getpar.c61
-rw-r--r--games/trek/getpar.h17
-rw-r--r--games/trek/help.c33
-rw-r--r--games/trek/impulse.c22
-rw-r--r--games/trek/initquad.c13
-rw-r--r--games/trek/kill.c33
-rw-r--r--games/trek/klmove.c11
-rw-r--r--games/trek/lose.c13
-rw-r--r--games/trek/lrscan.c13
-rw-r--r--games/trek/main.c29
-rw-r--r--games/trek/move.c26
-rw-r--r--games/trek/nova.c17
-rw-r--r--games/trek/out.c11
-rw-r--r--games/trek/phaser.c40
-rw-r--r--games/trek/play.c67
-rw-r--r--games/trek/ram.c10
-rw-r--r--games/trek/ranf.c16
-rw-r--r--games/trek/rest.c12
-rw-r--r--games/trek/schedule.c45
-rw-r--r--games/trek/score.c20
-rw-r--r--games/trek/setup.c42
-rw-r--r--games/trek/setwarp.c22
-rw-r--r--games/trek/shield.c38
-rw-r--r--games/trek/snova.c17
-rw-r--r--games/trek/srscan.c27
-rw-r--r--games/trek/systemname.c5
-rw-r--r--games/trek/torped.c48
-rw-r--r--games/trek/trek.h332
-rw-r--r--games/trek/utility.c156
-rw-r--r--games/trek/visual.c33
-rw-r--r--games/trek/warp.c77
-rw-r--r--games/trek/win.c18
-rw-r--r--games/worm/worm.66
-rw-r--r--games/worm/worm.c20
-rw-r--r--games/worms/worms.66
-rw-r--r--games/worms/worms.c10
-rw-r--r--games/wump/wump.66
-rw-r--r--games/wump/wump.c63
99 files changed, 1463 insertions, 1108 deletions
diff --git a/games/arithmetic/arithmetic.6 b/games/arithmetic/arithmetic.6
index 54da170d7ec..c86316d58f2 100644
--- a/games/arithmetic/arithmetic.6
+++ b/games/arithmetic/arithmetic.6
@@ -1,4 +1,4 @@
-.\" $NetBSD: arithmetic.6,v 1.4 1995/03/21 11:59:31 cgd Exp $
+.\" $OpenBSD: arithmetic.6,v 1.2 1998/08/19 07:39:48 pjanzen Exp $
.\"
.\" Copyright (c) 1989, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -38,12 +38,12 @@
.\"
.Dd May 31, 1993
.Dt ARITHMETIC 6
-.UC 4
+.Os BSD 4
.Sh NAME
.Nm arithmetic
.Nd quiz on simple arithmetic
.Sh SYNOPSIS
-.Nm arithmetic
+.Nm
.Op Fl o Ar +\-x/
.Op Fl r Ar range
.Sh DESCRIPTION
@@ -70,7 +70,7 @@ will be asked correspondingly more often.
If a
.Ar range
is supplied,
-.Nm arithmetic
+.Nm
selects the numbers in its problems in the following way.
For addition and multiplication, the numbers to be added or multiplied
are between 0 and
@@ -80,14 +80,14 @@ For subtraction and division, both the required result and the number to
divide by or subtract will be between 0 and
.Ar range .
(Of course,
-.Nm arithmetic
+.Nm
will not ask you to divide by 0.) The default
.I range
is 10.
.El
.Pp
When you get a problem wrong,
-.Nm arithmetic
+.Nm
will remember the numbers involved, and will tend to select those numbers
more often than others, in problems of the same sort.
Eventually it will forgive and forget.
diff --git a/games/arithmetic/arithmetic.c b/games/arithmetic/arithmetic.c
index ed82668e590..d6c809bb56d 100644
--- a/games/arithmetic/arithmetic.c
+++ b/games/arithmetic/arithmetic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arithmetic.c,v 1.6 1998/03/12 09:09:05 pjanzen Exp $ */
+/* $OpenBSD: arithmetic.c,v 1.7 1998/08/19 07:39:50 pjanzen Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -46,7 +46,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)arithmetic.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: arithmetic.c,v 1.6 1998/03/12 09:09:05 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: arithmetic.c,v 1.7 1998/08/19 07:39:50 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -132,7 +132,7 @@ main(argc, argv)
for (p = keys = optarg; *p; ++p)
if (!strchr(keylist, *p))
- errx(1,"unknown key.");
+ errx(1, "unknown key.");
nkeys = p - optarg;
break;
}
diff --git a/games/banner/banner.6 b/games/banner/banner.6
index be450b2e6bf..7787f1ac896 100644
--- a/games/banner/banner.6
+++ b/games/banner/banner.6
@@ -1,4 +1,4 @@
-.\" $OpenBSD: banner.6,v 1.3 1998/03/12 09:09:10 pjanzen Exp $
+.\" $OpenBSD: banner.6,v 1.4 1998/08/19 07:40:12 pjanzen Exp $
.\"
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -40,7 +40,7 @@
.Nm banner
.Nd print large banner on printer
.Sh SYNOPSIS
-.Nm banner
+.Nm
.Op Fl w Ar width
.Ar message ...
.Sh DESCRIPTION
@@ -54,10 +54,7 @@ is given, the output is scrunched down from a width of 132 to
suitable for a narrow terminal.
.Pp
The output should be printed on a hard-copy device, up to 132 columns wide,
-with no breaks between the pages. The volume is great enough that you
-may want
-a printer or a fast hardcopy terminal, but if you are patient, a
-decwriter or other 300 baud terminal will do.
+with no breaks between the pages.
.Sh BUGS
Several ASCII characters are not defined, notably <, >, [, ], \\,
^, _, {, }, |, and ~. Also, the characters ", ', and & are funny
diff --git a/games/banner/banner.c b/games/banner/banner.c
index 0632e61d2d6..f5f6f35ad34 100644
--- a/games/banner/banner.c
+++ b/games/banner/banner.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: banner.c,v 1.6 1998/08/19 07:40:13 pjanzen Exp $ */
/* $NetBSD: banner.c,v 1.4 1995/04/22 11:55:15 cgd Exp $ */
/*
@@ -43,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)banner.c 8.3 (Berkeley) 4/2/94";
#else
-static char rcsid[] = "$NetBSD: banner.c,v 1.4 1995/04/22 11:55:15 cgd Exp $";
+static char rcsid[] = "$OpenBSD: banner.c,v 1.6 1998/08/19 07:40:13 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -92,7 +93,7 @@ int asc_ptr[NCHARS] = {
* next element in array.
*/
char data_table[NBYTES] = {
-/* 0 1 2 3 4 5 6 7 8 9 */
+/* 0 1 2 3 4 5 6 7 8 9 */
/* 0 */ 129, 227, 130, 34, 6, 90, 19, 129, 32, 10,
/* 10 */ 74, 40, 129, 31, 12, 64, 53, 129, 30, 14,
/* 20 */ 54, 65, 129, 30, 14, 53, 67, 129, 30, 14,
@@ -1032,7 +1033,7 @@ int width = DWIDTH; /* -w option: scrunch letters to 80 columns */
int
main(argc, argv)
int argc;
- char **argv;
+ char *argv[];
{
int ch;
@@ -1040,22 +1041,22 @@ main(argc, argv)
setegid(getgid());
setgid(getgid());
- while ((ch = getopt(argc, argv, "w:td")) != -1)
- switch(ch) {
- case 'w':
- width = atoi(optarg);
- if (width <= 0)
- width = 80;
- break;
+ while ((ch = getopt(argc, argv, "w:tdh")) != -1)
+ switch (ch) {
case 'd':
debug = 1;
break;
case 't':
trace = 1;
break;
- case '?':
+ case 'w':
+ width = atoi(optarg);
+ if (width <= 0)
+ errx(1, "illegal argument for -w option");
+ break;
+ case '?': case 'h':
default:
- fprintf(stderr, "usage: banner [-w width]\n");
+ (void)fprintf(stderr, "usage: banner [-w width]\n");
exit(1);
}
argc -= optind;
diff --git a/games/bcd/bcd.c b/games/bcd/bcd.c
index 9835a921f94..f6e08871897 100644
--- a/games/bcd/bcd.c
+++ b/games/bcd/bcd.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: bcd.c,v 1.5 1998/08/19 07:40:15 pjanzen Exp $ */
/* $NetBSD: bcd.c,v 1.6 1995/04/24 12:22:23 cgd Exp $ */
/*
@@ -43,7 +44,11 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
+#if 0
static char sccsid[] = "@(#)bcd.c 8.2 (Berkeley) 3/20/94";
+#else
+static char rcsid[] = "$OpenBSD: bcd.c,v 1.5 1998/08/19 07:40:15 pjanzen Exp $";
+#endif
#endif /* not lint */
/*
@@ -77,10 +82,10 @@ static char sccsid[] = "@(#)bcd.c 8.2 (Berkeley) 3/20/94";
*/
#include <sys/types.h>
-
#include <stdio.h>
#include <string.h>
#include <ctype.h>
+#include <unistd.h>
u_short holes[256] = {
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
@@ -122,6 +127,8 @@ u_short holes[256] = {
*/
#define bit(w,i) ((w)&(1<<(i)))
+void printcard __P((char *));
+
int
main(argc, argv)
int argc;
@@ -149,12 +156,13 @@ main(argc, argv)
#define COLUMNS 48
+void
printcard(str)
- register char *str;
+ char *str;
{
static char rowchars[] = " 123456789";
- register int i, row;
- register char *p;
+ register int i, row;
+ register char *p;
/* ruthlessly remove newlines and truncate at 48 characters. */
if ((p = strchr(str, '\n')))
@@ -181,7 +189,7 @@ printcard(str)
p = str;
putchar('/');
for (i = 1; *p; i++, p++)
- if (holes[*p])
+ if (holes[(int)*p])
putchar(*p);
else
putchar(' ');
@@ -199,7 +207,7 @@ printcard(str)
for (row = 0; row <= 11; ++row) {
putchar('|');
for (i = 0, p = str; *p; i++, p++) {
- if (bit(holes[*p], 11 - row))
+ if (bit(holes[(int)*p], 11 - row))
putchar(']');
else
putchar(rowchars[row]);
diff --git a/games/cribbage/cards.c b/games/cribbage/cards.c
index a81bdf65e64..5c2540f5b86 100644
--- a/games/cribbage/cards.c
+++ b/games/cribbage/cards.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: cards.c,v 1.2 1998/08/19 07:40:17 pjanzen Exp $ */
/* $NetBSD: cards.c,v 1.3 1995/03/21 15:08:41 cgd Exp $ */
/*-
@@ -34,7 +35,11 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)cards.c 8.1 (Berkeley) 5/31/93";
+#else
+static char rcsid[] = "$OpenBSD: cards.c,v 1.2 1998/08/19 07:40:17 pjanzen Exp $";
+#endif
#endif /* not lint */
#include <curses.h>
@@ -53,7 +58,7 @@ void
makedeck(d)
CARD d[];
{
- register int i, j, k;
+ int i, j, k;
i = time(NULL);
i = ((i & 0xff) << 8) | ((i >> 8) & 0xff) | 1;
@@ -74,7 +79,7 @@ void
shuffle(d)
CARD d[];
{
- register int j, k;
+ int j, k;
CARD c;
for (j = CARDS; j > 0; --j) {
@@ -103,7 +108,7 @@ isone(a, b, n)
CARD a, b[];
int n;
{
- register int i;
+ int i;
for (i = 0; i < n; i++)
if (eq(a, b[i]))
@@ -119,7 +124,7 @@ cremove(a, d, n)
CARD a, d[];
int n;
{
- register int i, j;
+ int i, j;
for (i = j = 0; i < n; i++)
if (!eq(a, d[i]))
@@ -134,10 +139,10 @@ cremove(a, d, n)
*/
void
sorthand(h, n)
- register CARD h[];
+ CARD h[];
int n;
{
- register CARD *cp, *endp;
+ CARD *cp, *endp;
CARD c;
for (endp = &h[n]; h < endp - 1; h++)
diff --git a/games/cribbage/crib.c b/games/cribbage/crib.c
index 3cf1f74c3dd..fbe1e7f5772 100644
--- a/games/cribbage/crib.c
+++ b/games/cribbage/crib.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: crib.c,v 1.5 1998/08/19 07:40:18 pjanzen Exp $ */
/* $NetBSD: crib.c,v 1.7 1997/07/10 06:47:29 mikel Exp $ */
/*-
@@ -43,11 +44,13 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)crib.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: crib.c,v 1.7 1997/07/10 06:47:29 mikel Exp $";
+static char rcsid[] = "$OpenBSD: crib.c,v 1.5 1998/08/19 07:40:18 pjanzen Exp $";
#endif
#endif /* not lint */
+#include <sys/types.h>
#include <curses.h>
+#include <err.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
@@ -139,11 +142,8 @@ main(argc, argv)
}
setegid(getgid());
bye();
- if (!f) {
- (void) fprintf(stderr, "\ncribbage: can't open %s.\n",
- _PATH_LOG);
- exit(1);
- }
+ if (!f)
+ errx(1, "can't open %s", _PATH_LOG);
exit(0);
}
@@ -200,7 +200,7 @@ gamescore()
void
game()
{
- register int i, j;
+ int i, j;
BOOLEAN flag;
BOOLEAN compcrib;
@@ -294,7 +294,7 @@ int
playhand(mycrib)
BOOLEAN mycrib;
{
- register int deckpos;
+ int deckpos;
werase(Compwin);
wrefresh(Compwin);
@@ -326,7 +326,7 @@ int
deal(mycrib)
BOOLEAN mycrib;
{
- register int i, j;
+ int i, j;
for (i = j = 0; i < FULLHAND; i++) {
if (mycrib) {
@@ -349,7 +349,7 @@ void
discard(mycrib)
BOOLEAN mycrib;
{
- register char *prompt;
+ char *prompt;
CARD crd;
prcrib(mycrib, TRUE);
@@ -380,7 +380,7 @@ cut(mycrib, pos)
BOOLEAN mycrib;
int pos;
{
- register int i;
+ int i;
BOOLEAN win;
win = FALSE;
@@ -423,7 +423,7 @@ void
prcrib(mycrib, blank)
BOOLEAN mycrib, blank;
{
- register int y, cardx;
+ int y, cardx;
if (mycrib)
cardx = CRIB_X;
@@ -455,12 +455,13 @@ peg(mycrib)
BOOLEAN mycrib;
{
static CARD ch[CINHAND], ph[CINHAND];
- register int i, j, k;
- register int l;
- register int cnum, pnum, sum;
- register BOOLEAN myturn, mego, ugo, last, played;
+ int i, j, k;
+ int l;
+ int cnum, pnum, sum;
+ BOOLEAN myturn, mego, ugo, last, played;
CARD crd;
+ played = FALSE;
cnum = pnum = CINHAND;
for (i = 0; i < CINHAND; i++) { /* make copies of hands */
ch[i] = chand[i];
@@ -587,7 +588,7 @@ peg(mycrib)
prhand(ph, pnum, Playwin, FALSE);
prhand(ch, cnum, Compwin, TRUE);
prtable(sum);
- if (last)
+ if (last) {
if (played) {
msg(quiet ? "I get one for last" :
"I get one point for last");
@@ -601,6 +602,7 @@ peg(mycrib)
if (chkscr(&pscore, 1))
return TRUE;
}
+ }
return (FALSE);
}
diff --git a/games/cribbage/cribbage.6 b/games/cribbage/cribbage.6
index 01d88d2e8f4..dd9b3fab8f4 100644
--- a/games/cribbage/cribbage.6
+++ b/games/cribbage/cribbage.6
@@ -1,4 +1,4 @@
-.\" $OpenBSD: cribbage.6,v 1.2 1998/03/26 20:53:31 pjanzen Exp $
+.\" $OpenBSD: cribbage.6,v 1.3 1998/08/19 07:40:19 pjanzen Exp $
.\"
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -40,7 +40,7 @@
.Nm cribbage
.Nd the card game cribbage
.Sh SYNOPSIS
-.Nm /usr/games/cribbage
+.Nm
.Op Fl eqr
.Sh DESCRIPTION
.Nm Cribbage
diff --git a/games/cribbage/instr.c b/games/cribbage/instr.c
index b7351f009d5..42f232d763b 100644
--- a/games/cribbage/instr.c
+++ b/games/cribbage/instr.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: instr.c,v 1.6 1998/08/19 07:40:21 pjanzen Exp $ */
/* $NetBSD: instr.c,v 1.5 1997/07/10 06:47:30 mikel Exp $ */
/*-
@@ -37,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)instr.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: instr.c,v 1.5 1997/07/10 06:47:30 mikel Exp $";
+static char rcsid[] = "$OpenBSD: instr.c,v 1.6 1998/08/19 07:40:21 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -46,6 +47,7 @@ static char rcsid[] = "$NetBSD: instr.c,v 1.5 1997/07/10 06:47:30 mikel Exp $";
#include <sys/stat.h>
#include <curses.h>
+#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -64,11 +66,8 @@ instructions()
pid_t pid;
char *pager, *path;
- if (stat(_PATH_INSTR, &sb)) {
- (void)fprintf(stderr, "cribbage: %s: %s.\n", _PATH_INSTR,
- strerror(errno));
- exit(1);
- }
+ if (stat(_PATH_INSTR, &sb))
+ err(1, "stat %s", _PATH_INSTR);
if (!(path = getenv("PAGER")))
path = _PATH_MORE;
@@ -78,11 +77,10 @@ instructions()
switch (pid = vfork()) {
case -1:
- (void)fprintf(stderr, "cribbage: %s.\n", strerror(errno));
- exit(1);
+ err(1, "vfork");
case 0:
execlp(path, pager, _PATH_INSTR, NULL);
- (void)fprintf(stderr, "cribbage: %s.\n", strerror(errno));
+ warn("%s", "");
_exit(1);
default:
do {
diff --git a/games/cribbage/io.c b/games/cribbage/io.c
index 7e035091983..6e90d5db46d 100644
--- a/games/cribbage/io.c
+++ b/games/cribbage/io.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: io.c,v 1.4 1998/08/19 07:40:22 pjanzen Exp $ */
/* $NetBSD: io.c,v 1.9 1997/07/09 06:25:47 phil Exp $ */
/*-
@@ -173,7 +174,7 @@ prhand(h, n, win, blank)
WINDOW *win;
BOOLEAN blank;
{
- register int i;
+ int i;
werase(win);
for (i = 0; i < n; i++)
@@ -192,7 +193,7 @@ infrom(hand, n, prompt)
int n;
char *prompt;
{
- register int i, j;
+ int i, j;
CARD crd;
if (n < 1) {
@@ -246,7 +247,7 @@ int
incard(crd)
CARD *crd;
{
- register int i;
+ int i;
int rnk, sut;
char *line, *p, *p1;
BOOLEAN retval;
@@ -256,10 +257,10 @@ incard(crd)
if (!(line = getline()))
goto gotit;
p = p1 = line;
- while (*p1 != ' ' && *p1 != NULL)
+ while (*p1 != ' ' && *p1 != '\0')
++p1;
- *p1++ = NULL;
- if (*p == NULL)
+ *p1++ = '\0';
+ if (*p == '\0')
goto gotit;
/* IMPORTANT: no real card has 2 char first name */
@@ -295,17 +296,17 @@ incard(crd)
if (rnk == EMPTY)
goto gotit;
p = p1;
- while (*p1 != ' ' && *p1 != NULL)
+ while (*p1 != ' ' && *p1 != '\0')
++p1;
- *p1++ = NULL;
- if (*p == NULL)
+ *p1++ = '\0';
+ if (*p == '\0')
goto gotit;
if (!strcmp("OF", p)) {
p = p1;
- while (*p1 != ' ' && *p1 != NULL)
+ while (*p1 != ' ' && *p1 != '\0')
++p1;
- *p1++ = NULL;
- if (*p == NULL)
+ *p1++ = '\0';
+ if (*p == '\0')
goto gotit;
}
sut = EMPTY;
@@ -330,7 +331,7 @@ gotit:
int
getuchar()
{
- register int c;
+ int c;
c = readchar();
if (islower(c))
@@ -349,12 +350,12 @@ number(lo, hi, prompt)
int lo, hi;
char *prompt;
{
- register char *p;
- register int sum;
+ char *p;
+ int sum;
for (sum = 0;;) {
msg(prompt);
- if (!(p = getline()) || *p == NULL) {
+ if (!(p = getline()) || *p == '\0') {
msg(quiet ? "Not a number" :
"That doesn't look like a number");
continue;
@@ -369,7 +370,7 @@ number(lo, hi, prompt)
++p;
}
- if (*p != ' ' && *p != '\t' && *p != NULL)
+ if (*p != ' ' && *p != '\t' && *p != '\0')
sum = lo - 1;
if (sum >= lo && sum <= hi)
break;
@@ -447,8 +448,8 @@ void
endmsg()
{
static int lastline = 0;
- register int len;
- register char *mp, *omp;
+ int len;
+ char *mp, *omp;
/* All messages should start with uppercase */
mvaddch(lastline + Y_MSG_START, SCORE_X, ' ');
@@ -516,9 +517,9 @@ do_wait()
*/
void
wait_for(ch)
- register int ch;
+ int ch;
{
- register char c;
+ char c;
if (ch == '\n')
while ((c = readchar()) != '\n')
@@ -535,7 +536,7 @@ wait_for(ch)
int
readchar()
{
- register int cnt;
+ int cnt;
char c;
over:
@@ -563,9 +564,9 @@ over:
char *
getline()
{
- register char *sp;
- register int c, oy, ox;
- register WINDOW *oscr;
+ char *sp;
+ int c, oy, ox;
+ WINDOW *oscr;
oscr = stdscr;
stdscr = Msgwin;
@@ -578,7 +579,7 @@ getline()
else
if (c == erasechar()) { /* process erase character */
if (sp > linebuf) {
- register int i;
+ int i;
sp--;
for (i = strlen(unctrl(*sp)); i; i--)
diff --git a/games/cribbage/score.c b/games/cribbage/score.c
index 93f8c075efd..369b03399f7 100644
--- a/games/cribbage/score.c
+++ b/games/cribbage/score.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: score.c,v 1.2 1998/08/19 07:40:24 pjanzen Exp $ */
/* $NetBSD: score.c,v 1.3 1995/03/21 15:08:57 cgd Exp $ */
/*-
@@ -37,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: score.c,v 1.3 1995/03/21 15:08:57 cgd Exp $";
+static char rcsid[] = "$OpenBSD: score.c,v 1.2 1998/08/19 07:40:24 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -109,19 +110,19 @@ static int pairpoints, runpoints; /* Globals from pairuns. */
*/
int
scorehand(hand, starter, n, crb, do_explain)
- register CARD hand[];
+ CARD hand[];
CARD starter;
int n;
BOOLEAN crb; /* true if scoring crib */
BOOLEAN do_explain; /* true if must explain this hand */
{
- register int i, k;
- register int score;
- register BOOLEAN flag;
+ int i, k;
+ int score;
+ BOOLEAN flag;
CARD h[(CINHAND + 1)];
char buf[32];
- expl[0] = NULL; /* initialize explanation */
+ expl[0] = '\0'; /* initialize explanation */
score = 0;
flag = TRUE;
k = hand[0].suit;
@@ -137,7 +138,7 @@ scorehand(hand, starter, n, crb, do_explain)
}
if (flag && n >= CINHAND) {
- if (do_explain && expl[0] != NULL)
+ if (do_explain && expl[0] != '\0')
strcat(expl, ", ");
if (starter.suit == k) {
score += 5;
@@ -146,33 +147,35 @@ scorehand(hand, starter, n, crb, do_explain)
} else
if (!crb) {
score += 4;
- if (do_explain && expl[0] != NULL)
+ if (do_explain && expl[0] != '\0')
strcat(expl, ", Four-flush");
else
strcpy(expl, "Four-flush");
}
}
- if (do_explain && expl[0] != NULL)
+ if (do_explain && expl[0] != '\0')
strcat(expl, ", ");
h[n] = starter;
sorthand(h, n + 1); /* sort by rank */
i = 2 * fifteens(h, n + 1);
score += i;
- if (do_explain)
+ if (do_explain) {
if (i > 0) {
(void) sprintf(buf, "%d points in fifteens", i);
strcat(expl, buf);
} else
strcat(expl, "No fifteens");
+ }
i = pairuns(h, n + 1);
score += i;
- if (do_explain)
+ if (do_explain) {
if (i > 0) {
(void) sprintf(buf, ", %d points in pairs, %d in runs",
pairpoints, runpoints);
strcat(expl, buf);
} else
strcat(expl, ", No pairs/runs");
+ }
return (score);
}
@@ -182,12 +185,12 @@ scorehand(hand, starter, n, crb, do_explain)
*/
int
fifteens(hand, n)
- register CARD hand[];
+ CARD hand[];
int n;
{
- register int *sp, *np;
- register int i;
- register CARD *endp;
+ int *sp, *np;
+ int i;
+ CARD *endp;
static int sums[15], nsums[15];
np = nsums;
@@ -228,7 +231,7 @@ pairuns(h, n)
CARD h[];
int n;
{
- register int i;
+ int i;
int runlength, runmult, lastmult, curmult;
int mult1, mult2, pair1, pair2;
BOOLEAN run;
@@ -298,7 +301,7 @@ pegscore(crd, tbl, n, sum)
int n, sum;
{
BOOLEAN got[RANKS];
- register int i, j, scr;
+ int i, j, scr;
int k, lo, hi;
sum += VAL(crd.rank);
diff --git a/games/cribbage/support.c b/games/cribbage/support.c
index 53bdaf7373d..0ef6decf3ea 100644
--- a/games/cribbage/support.c
+++ b/games/cribbage/support.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: support.c,v 1.3 1998/08/19 07:40:26 pjanzen Exp $ */
/* $NetBSD: support.c,v 1.3 1995/03/21 15:08:59 cgd Exp $ */
/*-
@@ -37,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)support.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: support.c,v 1.3 1995/03/21 15:08:59 cgd Exp $";
+static char rcsid[] = "$OpenBSD: support.c,v 1.3 1998/08/19 07:40:26 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -62,7 +63,7 @@ cchose(h, n, s)
CARD h[];
int n, s;
{
- register int i, j, l;
+ int i, j, l;
if (n <= 1)
return (0);
@@ -132,8 +133,8 @@ plyrhand(hand, s)
char *s;
{
static char prompt[BUFSIZ];
- register int i, j;
- register BOOLEAN win;
+ int i, j;
+ BOOLEAN win;
prhand(hand, CINHAND, Playwin, FALSE);
(void) sprintf(prompt, "Your %s scores ", s);
@@ -167,7 +168,7 @@ comphand(h, s)
CARD h[];
char *s;
{
- register int j;
+ int j;
j = scorehand(h, turnover, CINHAND, strcmp(s, "crib") == 0, FALSE);
prhand(h, CINHAND, Compwin, FALSE);
@@ -206,11 +207,11 @@ chkscr(scr, inc)
*/
void
prpeg(score, peg, myturn)
- register int score;
+ int score;
int peg;
BOOLEAN myturn;
{
- register int y, x;
+ int y, x;
if (!myturn)
y = SCORE_Y + 2;
@@ -248,7 +249,7 @@ cdiscard(mycrib)
BOOLEAN mycrib;
{
CARD d[CARDS], h[FULLHAND], cb[2];
- register int i, j, k;
+ int i, j, k;
int nc, ns;
long sums[15];
static int undo1[15] = {0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4};
@@ -301,7 +302,7 @@ anymove(hand, n, sum)
CARD hand[];
int n, sum;
{
- register int i, j;
+ int i, j;
if (n < 1)
return (FALSE);
@@ -322,7 +323,7 @@ anysumto(hand, n, s, t)
CARD hand[];
int n, s, t;
{
- register int i;
+ int i;
for (i = 0; i < n; i++) {
if (s + VAL(hand[i].rank) == t)
@@ -339,7 +340,7 @@ numofval(h, n, v)
CARD h[];
int n, v;
{
- register int i, j;
+ int i, j;
j = 0;
for (i = 0; i < n; i++) {
@@ -357,7 +358,7 @@ makeknown(h, n)
CARD h[];
int n;
{
- register int i;
+ int i;
for (i = 0; i < n; i++)
known[knownum++] = h[i];
diff --git a/games/factor/factor.6 b/games/factor/factor.6
index d21be552a8e..3171170c31d 100644
--- a/games/factor/factor.6
+++ b/games/factor/factor.6
@@ -1,4 +1,4 @@
-.\" $NetBSD: factor.6,v 1.4 1995/03/23 08:28:05 cgd Exp $
+.\" $OpenBSD: factor.6,v 1.2 1998/08/19 07:40:27 pjanzen Exp $
.\"
.\" Copyright (c) 1989, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -50,14 +50,14 @@
.Nd
factor a number, generate primes
.Sh SYNOPSIS
-.Nm factor
+.Nm
.Op Ar number ...
.br
.Nm primes
.Op Ar start Op Ar stop
.Sh DESCRIPTION
The
-.Nm factor
+.Nm
utility will factor integers between -2147483648 and 2147483647 inclusive.
When a number is factored, it is printed, followed by a
.Dq \: ,
@@ -67,14 +67,14 @@ If a factor divides a value more than once, it will be printed
more than once.
.Pp
When
-.Nm factor
+.Nm
is invoked with one or more arguments,
each argument will be factored.
.Pp
When
-.Nm factor
+.Nm
is invoked with no arguments,
-.Nm factor
+.Nm
reads numbers, one per line, from standard input, until end of file or error.
Leading white-space and empty lines are ignored.
Numbers may be preceded by a single - or +.
diff --git a/games/factor/factor.c b/games/factor/factor.c
index 3407b3587a0..d79e19e6efd 100644
--- a/games/factor/factor.c
+++ b/games/factor/factor.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: factor.c,v 1.5 1998/08/19 07:40:28 pjanzen Exp $ */
/* $NetBSD: factor.c,v 1.5 1995/03/23 08:28:07 cgd Exp $ */
/*
@@ -46,7 +47,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)factor.c 8.3 (Berkeley) 3/30/94";
#else
-static char rcsid[] = "$NetBSD: factor.c,v 1.5 1995/03/23 08:28:07 cgd Exp $";
+static char rcsid[] = "$OpenBSD: factor.c,v 1.5 1998/08/19 07:40:28 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -69,12 +70,14 @@ static char rcsid[] = "$NetBSD: factor.c,v 1.5 1995/03/23 08:28:07 cgd Exp $";
* If no args are given, the list of numbers are read from stdin.
*/
+#include <sys/types.h>
#include <err.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
#include "primes.h"
diff --git a/games/hangman/endgame.c b/games/hangman/endgame.c
index 300c0efb83b..67f770f1dc5 100644
--- a/games/hangman/endgame.c
+++ b/games/hangman/endgame.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: endgame.c,v 1.2 1998/08/19 07:40:30 pjanzen Exp $ */
/* $NetBSD: endgame.c,v 1.3 1995/03/23 08:32:40 cgd Exp $ */
/*
@@ -37,16 +38,17 @@
#if 0
static char sccsid[] = "@(#)endgame.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: endgame.c,v 1.3 1995/03/23 08:32:40 cgd Exp $";
+static char rcsid[] = "$OpenBSD: endgame.c,v 1.2 1998/08/19 07:40:30 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "hangman.h"
+#include "hangman.h"
/*
* endgame:
* Do what's necessary at the end of the game
*/
+void
endgame()
{
register char ch;
@@ -67,7 +69,7 @@ endgame()
leaveok(stdscr, FALSE);
refresh();
if ((ch = readch()) == 'n')
- die();
+ die(0);
else if (ch == 'y')
break;
mvaddstr(MESGY + 2, MESGX, "Please type 'y' or 'n'");
@@ -79,13 +81,3 @@ endgame()
deleteln();
deleteln();
}
-
-
-
-
-
-
-
-
-
-
diff --git a/games/hangman/extern.c b/games/hangman/extern.c
index 2d5f0082873..3ee9eae6a0c 100644
--- a/games/hangman/extern.c
+++ b/games/hangman/extern.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: extern.c,v 1.2 1998/08/19 07:40:31 pjanzen Exp $ */
/* $NetBSD: extern.c,v 1.3 1995/03/23 08:32:41 cgd Exp $ */
/*
@@ -37,16 +38,15 @@
#if 0
static char sccsid[] = "@(#)extern.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: extern.c,v 1.3 1995/03/23 08:32:41 cgd Exp $";
+static char rcsid[] = "$OpenBSD: extern.c,v 1.2 1998/08/19 07:40:31 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "hangman.h"
+#include "hangman.h"
bool Guessed[26];
-char Word[BUFSIZ],
- Known[BUFSIZ],
+char Word[BUFSIZ], Known[BUFSIZ],
*Noose_pict[] = {
" ______",
" | |",
@@ -60,19 +60,18 @@ char Word[BUFSIZ],
NULL
};
-int Errors,
- Wordnum = 0;
+int Errors, Wordnum = 0;
double Average = 0.0;
ERR_POS Err_pos[MAXERRS] = {
- { 2, 10, 'O' },
- { 3, 10, '|' },
- { 4, 10, '|' },
- { 5, 9, '/' },
- { 3, 9, '/' },
- { 3, 11, '\\' },
- { 5, 11, '\\' }
+ { 2, 10, 'O' },
+ { 3, 10, '|' },
+ { 4, 10, '|' },
+ { 5, 9, '/' },
+ { 3, 9, '/' },
+ { 3, 11, '\\'},
+ { 5, 11, '\\'}
};
FILE *Dict = NULL;
diff --git a/games/hangman/getguess.c b/games/hangman/getguess.c
index cc5d7de84e2..d4175c83f14 100644
--- a/games/hangman/getguess.c
+++ b/games/hangman/getguess.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: getguess.c,v 1.3 1998/08/19 07:40:32 pjanzen Exp $ */
/* $NetBSD: getguess.c,v 1.5 1995/03/23 08:32:43 cgd Exp $ */
/*
@@ -37,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)getguess.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: getguess.c,v 1.5 1995/03/23 08:32:43 cgd Exp $";
+static char rcsid[] = "$OpenBSD: getguess.c,v 1.3 1998/08/19 07:40:32 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -48,6 +49,7 @@ static char rcsid[] = "$NetBSD: getguess.c,v 1.5 1995/03/23 08:32:43 cgd Exp $";
* getguess:
* Get another guess
*/
+void
getguess()
{
register int i;
@@ -63,15 +65,16 @@ getguess()
if (isupper(ch))
ch = tolower(ch);
if (Guessed[ch - 'a'])
- mvprintw(MESGY, MESGX, "Already guessed '%c'", ch);
+ mvprintw(MESGY, MESGX, "Already guessed '%c'",
+ ch);
else
break;
- }
- else if (ch == CTRL('D'))
- die();
- else
- mvprintw(MESGY, MESGX, "Not a valid guess: '%s'",
- unctrl(ch));
+ } else
+ if (ch == CTRL('D'))
+ die(0);
+ else
+ mvprintw(MESGY, MESGX,
+ "Not a valid guess: '%s'", unctrl(ch));
}
leaveok(stdscr, TRUE);
move(MESGY, MESGX);
@@ -92,23 +95,22 @@ getguess()
* readch;
* Read a character from the input
*/
+int
readch()
{
- register int cnt, r;
- auto char ch;
+ int cnt;
+ char ch;
cnt = 0;
for (;;) {
- if (read(0, &ch, sizeof ch) <= 0)
- {
+ if (read(0, &ch, sizeof ch) <= 0) {
if (++cnt > 100)
- die();
- }
- else if (ch == CTRL('L')) {
- wrefresh(curscr);
- mvcur(0, 0, curscr->_cury, curscr->_curx);
- }
- else
- return ch;
+ die(0);
+ } else
+ if (ch == CTRL('L')) {
+ wrefresh(curscr);
+ mvcur(0, 0, curscr->_cury, curscr->_curx);
+ } else
+ return ch;
}
}
diff --git a/games/hangman/getword.c b/games/hangman/getword.c
index e858fabeff6..b32fc0bf61d 100644
--- a/games/hangman/getword.c
+++ b/games/hangman/getword.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: getword.c,v 1.2 1998/08/19 07:40:34 pjanzen Exp $ */
/* $NetBSD: getword.c,v 1.4 1995/03/23 08:32:45 cgd Exp $ */
/*
@@ -37,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)getword.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: getword.c,v 1.4 1995/03/23 08:32:45 cgd Exp $";
+static char rcsid[] = "$OpenBSD: getword.c,v 1.2 1998/08/19 07:40:34 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -48,6 +49,7 @@ static char rcsid[] = "$NetBSD: getword.c,v 1.4 1995/03/23 08:32:45 cgd Exp $";
* getword:
* Get a valid word out of the dictionary file
*/
+void
getword()
{
register FILE *inf;
@@ -56,7 +58,7 @@ getword()
inf = Dict;
for (;;) {
- pos = (double)rand() / (RAND_MAX + 1.0) * (double)Dict_size;
+ pos = (double) random() / (RAND_MAX + 1.0) * (double) Dict_size;
fseek(inf, pos, 0);
if (fgets(Word, BUFSIZ, inf) == NULL)
continue;
diff --git a/games/hangman/hangman.6 b/games/hangman/hangman.6
index b8adbd6e0f8..98335a913a9 100644
--- a/games/hangman/hangman.6
+++ b/games/hangman/hangman.6
@@ -1,4 +1,4 @@
-.\" $NetBSD: hangman.6,v 1.5 1995/03/23 08:32:46 cgd Exp $
+.\" $OpenBSD: hangman.6,v 1.3 1998/08/19 07:40:35 pjanzen Exp $
.\"
.\" Copyright (c) 1983, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -40,10 +40,10 @@
.Nm hangman
.Nd Computer version of the game hangman
.Sh SYNOPSIS
-.Nm /usr/games/hangman
+.Nm
.Sh DESCRIPTION
In
-.Nm hangman,
+.Nm hangman ,
the computer picks a word from the on-line word list
and you must try to guess it.
The computer keeps track of which letters have been guessed
diff --git a/games/hangman/hangman.h b/games/hangman/hangman.h
index 7452b3ecd8f..22b054653eb 100644
--- a/games/hangman/hangman.h
+++ b/games/hangman/hangman.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: hangman.h,v 1.2 1998/08/19 07:40:36 pjanzen Exp $ */
/* $NetBSD: hangman.h,v 1.5 1995/04/24 12:23:44 cgd Exp $ */
/*
@@ -35,29 +36,31 @@
* @(#)hangman.h 8.1 (Berkeley) 5/31/93
*/
-# include <curses.h>
-# include <sys/types.h>
-# include <sys/stat.h>
-# include <ctype.h>
-# include <signal.h>
-# include <string.h>
-# include "pathnames.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <ctype.h>
+#include <curses.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include "pathnames.h"
-# define MINLEN 6
-# define MAXERRS 7
+#define MINLEN 6
+#define MAXERRS 7
-# define MESGY 12
-# define MESGX 0
-# define PROMPTY 11
-# define PROMPTX 0
-# define KNOWNY 10
-# define KNOWNX 1
-# define NUMBERY 4
-# define NUMBERX (COLS - 1 - 26)
-# define AVGY 5
-# define AVGX (COLS - 1 - 26)
-# define GUESSY 2
-# define GUESSX (COLS - 1 - 26)
+#define MESGY 12
+#define MESGX 0
+#define PROMPTY 11
+#define PROMPTX 0
+#define KNOWNY 10
+#define KNOWNX 1
+#define NUMBERY 4
+#define NUMBERX (COLS - 1 - 26)
+#define AVGY 5
+#define AVGX (COLS - 1 - 26)
+#define GUESSY 2
+#define GUESSX (COLS - 1 - 26)
typedef struct {
@@ -65,18 +68,27 @@ typedef struct {
char ch;
} ERR_POS;
-extern bool Guessed[];
+extern bool Guessed[];
-extern char Word[], Known[], *Noose_pict[];
+extern char Word[], Known[], *Noose_pict[];
-extern int Errors, Wordnum;
+extern int Errors, Wordnum;
-extern double Average;
+extern double Average;
-extern ERR_POS Err_pos[];
+extern ERR_POS Err_pos[];
-extern FILE *Dict;
+extern FILE *Dict;
-extern off_t Dict_size;
+extern off_t Dict_size;
-void die();
+void die __P((int));
+void endgame __P((void));
+void getguess __P((void));
+void getword __P((void));
+void playgame __P((void));
+void prdata __P((void));
+void prman __P((void));
+void prword __P((void));
+int readch __P((void));
+void setup __P((void));
diff --git a/games/hangman/main.c b/games/hangman/main.c
index 72bf7e4558d..03c6a356746 100644
--- a/games/hangman/main.c
+++ b/games/hangman/main.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: main.c,v 1.4 1998/08/19 07:40:37 pjanzen Exp $ */
/* $NetBSD: main.c,v 1.3 1995/03/23 08:32:50 cgd Exp $ */
/*
@@ -43,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: main.c,v 1.3 1995/03/23 08:32:50 cgd Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.4 1998/08/19 07:40:37 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -52,10 +53,11 @@ static char rcsid[] = "$NetBSD: main.c,v 1.3 1995/03/23 08:32:50 cgd Exp $";
/*
* This game written by Ken Arnold.
*/
-main()
+int
+main(argc, argv)
+ int argc;
+ char *argv[];
{
- void die();
-
/* revoke */
setegid(getgid());
setgid(getgid());
@@ -76,7 +78,8 @@ main()
* Die properly.
*/
void
-die()
+die(dummy)
+ int dummy;
{
mvcur(0, COLS - 1, LINES - 1, 0);
endwin();
diff --git a/games/hangman/playgame.c b/games/hangman/playgame.c
index f6eed3ac68b..df77e6c8c99 100644
--- a/games/hangman/playgame.c
+++ b/games/hangman/playgame.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: playgame.c,v 1.3 1998/08/19 07:40:40 pjanzen Exp $ */
/* $NetBSD: playgame.c,v 1.3 1995/03/23 08:32:53 cgd Exp $ */
/*-
@@ -37,16 +38,17 @@
#if 0
static char sccsid[] = "@(#)playgame.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: playgame.c,v 1.3 1995/03/23 08:32:53 cgd Exp $";
+static char rcsid[] = "$OpenBSD: playgame.c,v 1.3 1998/08/19 07:40:40 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "hangman.h"
+#include "hangman.h"
/*
* playgame:
* play a game
*/
+void
playgame()
{
register bool *bp;
diff --git a/games/hangman/prdata.c b/games/hangman/prdata.c
index adfff8f3e7e..09ed8e4c234 100644
--- a/games/hangman/prdata.c
+++ b/games/hangman/prdata.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: prdata.c,v 1.2 1998/08/19 07:40:41 pjanzen Exp $ */
/* $NetBSD: prdata.c,v 1.3 1995/03/23 08:32:54 cgd Exp $ */
/*-
@@ -37,16 +38,17 @@
#if 0
static char sccsid[] = "@(#)prdata.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: prdata.c,v 1.3 1995/03/23 08:32:54 cgd Exp $";
+static char rcsid[] = "$OpenBSD: prdata.c,v 1.2 1998/08/19 07:40:41 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "hangman.h"
+#include "hangman.h"
/*
* prdata:
* Print out the current guesses
*/
+void
prdata()
{
register bool *bp;
diff --git a/games/hangman/prman.c b/games/hangman/prman.c
index 2337b6390e3..5908d6b1a9c 100644
--- a/games/hangman/prman.c
+++ b/games/hangman/prman.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: prman.c,v 1.2 1998/08/19 07:40:42 pjanzen Exp $ */
/* $NetBSD: prman.c,v 1.3 1995/03/23 08:32:56 cgd Exp $ */
/*-
@@ -37,17 +38,18 @@
#if 0
static char sccsid[] = "@(#)prman.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: prman.c,v 1.3 1995/03/23 08:32:56 cgd Exp $";
+static char rcsid[] = "$OpenBSD: prman.c,v 1.2 1998/08/19 07:40:42 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "hangman.h"
+#include "hangman.h"
/*
* prman:
* Print out the man appropriately for the give number
* of incorrect guesses.
*/
+void
prman()
{
register int i;
diff --git a/games/hangman/prword.c b/games/hangman/prword.c
index ba2ab634d3b..99ef16f1e7d 100644
--- a/games/hangman/prword.c
+++ b/games/hangman/prword.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: prword.c,v 1.2 1998/08/19 07:40:43 pjanzen Exp $ */
/* $NetBSD: prword.c,v 1.3 1995/03/23 08:32:58 cgd Exp $ */
/*-
@@ -37,16 +38,17 @@
#if 0
static char sccsid[] = "@(#)prword.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: prword.c,v 1.3 1995/03/23 08:32:58 cgd Exp $";
+static char rcsid[] = "$OpenBSD: prword.c,v 1.2 1998/08/19 07:40:43 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "hangman.h"
+#include "hangman.h"
/*
* prword:
* Print out the current state of the word
*/
+void
prword()
{
move(KNOWNY, KNOWNX + sizeof "Word: ");
diff --git a/games/hangman/setup.c b/games/hangman/setup.c
index 73c835f9551..03730d4c02b 100644
--- a/games/hangman/setup.c
+++ b/games/hangman/setup.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: setup.c,v 1.2 1998/08/19 07:40:45 pjanzen Exp $ */
/* $NetBSD: setup.c,v 1.3 1995/03/23 08:32:59 cgd Exp $ */
/*-
@@ -37,16 +38,18 @@
#if 0
static char sccsid[] = "@(#)setup.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: setup.c,v 1.3 1995/03/23 08:32:59 cgd Exp $";
+static char rcsid[] = "$OpenBSD: setup.c,v 1.2 1998/08/19 07:40:45 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "hangman.h"
+#include <err.h>
+#include "hangman.h"
/*
* setup:
* Set up the strings on the screen.
*/
+void
setup()
{
register char **sp;
@@ -67,11 +70,10 @@ setup()
addstr(*sp);
}
- srand(time(NULL) + getpid());
+ srandom(time(NULL) + getpid());
if ((Dict = fopen(_PATH_DICT, "r")) == NULL) {
- perror(_PATH_DICT);
endwin();
- exit(1);
+ err(1, "fopen %s", _PATH_DICT);
}
fstat(fileno(Dict), &sbuf);
Dict_size = sbuf.st_size;
diff --git a/games/number/number.6 b/games/number/number.6
index 3810aaffb75..506866fd199 100644
--- a/games/number/number.6
+++ b/games/number/number.6
@@ -1,4 +1,4 @@
-.\" $OpenBSD: number.6,v 1.2 1998/03/25 08:45:24 pjanzen Exp $
+.\" $OpenBSD: number.6,v 1.3 1998/08/19 07:40:46 pjanzen Exp $
.\"
.\" Copyright (c) 1989, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
@@ -40,15 +40,16 @@
.Nm number
.Nd convert Arabic numerals to English
.Sh SYNOPSIS
-.Nm number
+.Nm
+.Op Fl l
.Op #
.Sh DESCRIPTION
The
-.Nm number
+.Nm
utility prints the English equivalent of the number to the standard
output, with each 10^3 magnitude displayed on a separate line.
If no argument is specified,
-.Nm number
+.Nm
reads lines from the standard input.
.Pp
The options are as follows:
diff --git a/games/pig/pig.6 b/games/pig/pig.6
index 9aee75a1540..aced7fe6ebf 100644
--- a/games/pig/pig.6
+++ b/games/pig/pig.6
@@ -1,4 +1,4 @@
-.\" $NetBSD: pig.6,v 1.2 1995/03/23 08:41:37 cgd Exp $
+.\" $OpenBSD: pig.6,v 1.3 1998/08/19 07:40:48 pjanzen Exp $
.\"
.\" Copyright (c) 1992 The Regents of the University of California.
.\" All rights reserved.
@@ -33,14 +33,14 @@
.\"
.\" @(#)pig.6 8.1 (Berkeley) 6/10/93
.\"
-.Dd June, 10, 1993
+.Dd June 10, 1993
.Dt PIG 6
.Os
.Sh NAME
.Nm pig
.Nd eformatray inputway asway Igpay Atinlay
.Sh SYNOPSIS
-.Nm pig
+.Nm
.Sh DESCRIPTION
Ethay
.Nm igpay
diff --git a/games/pig/pig.c b/games/pig/pig.c
index 89230a673af..e7584b90a97 100644
--- a/games/pig/pig.c
+++ b/games/pig/pig.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: pig.c,v 1.6 1998/08/19 07:40:49 pjanzen Exp $ */
/* $NetBSD: pig.c,v 1.2 1995/03/23 08:41:40 cgd Exp $ */
/*-
@@ -41,18 +42,20 @@ static char copyright[] =
#ifndef lint
#if 0
-static char sccsid[] = "@(#)pig.c 8.1 (Berkeley) 5/31/93";
+static char sccsid[] = "@(#)pig.c 8.2 (Berkeley) 5/4/95";
#else
-static char rcsid[] = "$NetBSD: pig.c,v 1.2 1995/03/23 08:41:40 cgd Exp $";
+static char rcsid[] = "$OpenBSD: pig.c,v 1.6 1998/08/19 07:40:49 pjanzen Exp $";
#endif
#endif /* not lint */
#include <sys/types.h>
#include <ctype.h>
+#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
void pigout __P((char *, int));
void usage __P((void));
@@ -62,7 +65,7 @@ main(argc, argv)
int argc;
char *argv[];
{
- register int len;
+ int len;
int ch;
char buf[1024];
@@ -81,10 +84,8 @@ main(argc, argv)
for (len = 0; (ch = getchar()) != EOF;) {
if (isalpha(ch)) {
- if (len >= sizeof(buf)) {
- (void)fprintf(stderr, "pig: ate too much!\n");
- exit(1);
- }
+ if (len >= sizeof(buf))
+ errx(1, "ate too much!");
buf[len++] = ch;
continue;
}
@@ -102,15 +103,21 @@ pigout(buf, len)
char *buf;
int len;
{
- register int ch, start;
- int olen;
+ int ch, start, i;
+ int olen, allupper, firstupper;
+
+ /* See if the word is all upper case */
+ allupper = firstupper = isupper(buf[0]);
+ for (i = 1; i < len && allupper; i++)
+ allupper = allupper && isupper(buf[i]);
/*
* If the word starts with a vowel, append "way". Don't treat 'y'
* as a vowel if it appears first.
*/
if (strchr("aeiouAEIOU", buf[0]) != NULL) {
- (void)printf("%.*sway", len, buf);
+ (void)printf("%.*s%s", len, buf,
+ allupper ? "WAY" : "way");
return;
}
@@ -118,6 +125,8 @@ pigout(buf, len)
* Copy leading consonants to the end of the word. The unit "qu"
* isn't treated as a vowel.
*/
+ if (!allupper)
+ buf[0] = tolower(buf[0]);
for (start = 0, olen = len;
!strchr("aeiouyAEIOUY", buf[start]) && start < olen;) {
ch = buf[len++] = buf[start++];
@@ -125,7 +134,9 @@ pigout(buf, len)
(buf[start] == 'u' || buf[start] == 'U'))
buf[len++] = buf[start++];
}
- (void)printf("%.*say", olen, buf + start);
+ if (firstupper)
+ buf[start] = toupper(buf[start]);
+ (void)printf("%.*s%s", olen, buf + start, allupper ? "AY" : "ay");
}
void
diff --git a/games/ppt/ppt.c b/games/ppt/ppt.c
index 7a8db30ae47..717c760914b 100644
--- a/games/ppt/ppt.c
+++ b/games/ppt/ppt.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: ppt.c,v 1.4 1998/08/19 07:40:51 pjanzen Exp $ */
/* $NetBSD: ppt.c,v 1.4 1995/03/23 08:35:40 cgd Exp $ */
/*
@@ -43,14 +44,17 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)ppt.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: ppt.c,v 1.4 1995/03/23 08:35:40 cgd Exp $";
+static char rcsid[] = "$OpenBSD: ppt.c,v 1.4 1998/08/19 07:40:51 pjanzen Exp $";
#endif
#endif /* not lint */
+#include <sys/types.h>
#include <stdio.h>
+#include <unistd.h>
-static void putppt();
+static void putppt __P((int));
+int
main(argc, argv)
int argc;
char **argv;
@@ -64,7 +68,7 @@ main(argc, argv)
(void) puts("___________");
if (argc > 1)
- while (p = *++argv)
+ while ((p = *++argv))
for (; *p; ++p)
putppt((int)*p);
else while ((c = getchar()) != EOF)
diff --git a/games/primes/primes.c b/games/primes/primes.c
index 7ab7acbc957..179489da472 100644
--- a/games/primes/primes.c
+++ b/games/primes/primes.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: primes.c,v 1.5 1998/08/19 07:40:52 pjanzen Exp $ */
/* $NetBSD: primes.c,v 1.5 1995/04/24 12:24:47 cgd Exp $ */
/*
@@ -46,7 +47,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)primes.c 8.4 (Berkeley) 3/21/94";
#else
-static char rcsid[] = "$NetBSD: primes.c,v 1.5 1995/04/24 12:24:47 cgd Exp $";
+static char rcsid[] = "$OpenBSD: primes.c,v 1.5 1998/08/19 07:40:52 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -67,6 +68,7 @@ static char rcsid[] = "$NetBSD: primes.c,v 1.5 1995/04/24 12:24:47 cgd Exp $";
* validation check: there are 664579 primes between 0 and 10^7
*/
+#include <sys/types.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
@@ -75,6 +77,7 @@ static char rcsid[] = "$NetBSD: primes.c,v 1.5 1995/04/24 12:24:47 cgd Exp $";
#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
#include "primes.h"
@@ -265,7 +268,7 @@ primes(start, stop)
for (p = &prime[0], factor = prime[0];
factor < stop && p <= pr_limit; factor = *(++p)) {
if (factor >= start) {
- printf("%u\n", factor);
+ printf("%lu\n", (unsigned long) factor);
}
}
/* return early if we are done */
@@ -328,7 +331,7 @@ primes(start, stop)
*/
for (q = table; q < tab_lim; ++q, start+=2) {
if (*q) {
- printf("%u\n", start);
+ printf("%lu\n", (unsigned long) start);
}
}
}
diff --git a/games/quiz/datfiles/collectives b/games/quiz/datfiles/collectives
index 3c4ba93466e..3b757ee9532 100644
--- a/games/quiz/datfiles/collectives
+++ b/games/quiz/datfiles/collectives
@@ -35,7 +35,7 @@ gangsters:mob
geese in flight:skein
geese on water:gaggle
goats:trip
-grapes|banannas:bunch
+grapes|bananas:bunch
hawks:cast
hens:brood
herons:siege
diff --git a/games/quiz/datfiles/elements b/games/quiz/datfiles/elements
index aba620a43d4..fb9c7eb3ffc 100644
--- a/games/quiz/datfiles/elements
+++ b/games/quiz/datfiles/elements
@@ -13,7 +13,7 @@ Mg:12:24.32:Magnesium
Al:13:26.98:Aluminum
Si:14:28.09:Silicon
P:15:30.975:Phosphorus
-S:16:32.066:Sulphur
+S:16:32.066:Sul[ph|f]ur
Cl:17:35.457:Chlorine
Ar:18:39.944:Argon
K:19:39.1:Potassium
diff --git a/games/quiz/pathnames.h b/games/quiz/pathnames.h
index 4c0f0877f12..5731ac0eb8d 100644
--- a/games/quiz/pathnames.h
+++ b/games/quiz/pathnames.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: pathnames.h,v 1.2 1998/08/19 07:40:54 pjanzen Exp $ */
/* $NetBSD: pathnames.h,v 1.4 1995/04/22 10:16:55 cgd Exp $ */
/*-
diff --git a/games/quiz/quiz.6 b/games/quiz/quiz.6
index bfc9ecfe493..ab390b53e3d 100644
--- a/games/quiz/quiz.6
+++ b/games/quiz/quiz.6
@@ -1,4 +1,4 @@
-.\" $NetBSD: quiz.6,v 1.4 1995/04/22 10:16:56 cgd Exp $
+.\" $OpenBSD: quiz.6,v 1.2 1998/08/19 07:40:56 pjanzen Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -43,17 +43,17 @@
.Nm quiz
.Nd random knowledge tests
.Sh SYNOPSIS
-.Nm quiz
+.Nm
.Op Fl t
.Op Fl i Ar file
.Op Ar question answer
.Sh DESCRIPTION
The
-.Nm quiz
+.Nm
utility tests your knowledge of random facts.
It has a database of subjects from which you can choose.
With no arguments,
-.Nm quiz
+.Nm
displays the list of available subjects.
.Pp
The options are as follows:
@@ -63,7 +63,7 @@ Use tutorial mode, in which questions are repeated later if you didn't get
them right the first time, and new questions are presented less frequently
to help you learn the older ones.
.It Fl i
-Specify an alternate index file.
+Specify an alternative index file.
.El
.Pp
Subjects are divided into categories.
@@ -77,7 +77,7 @@ untimely demise, whereas the command ``quiz killer victim'' works the
other way around.
.Pp
If you get the answer wrong,
-.Nm quiz
+.Nm
lets you try again.
To see the right answer, enter a blank line.
.Sh "Index and Data File Syntax"
@@ -88,7 +88,7 @@ meta-characters:
.sp
.Bl -tag -width "pat|pat" -compact -offset indent
.It pat|pat
-alternate patterns
+alternative patterns
.It {pat}
optional pattern
.It [pat]
@@ -109,7 +109,7 @@ characters, or at the end of a line to signify that a continuation line
follows.
.Pp
If either a question or its answer is empty,
-.Nm quiz
+.Nm
will refrain from asking it.
.Sh FILES
.Bl -tag -width /usr/share/games/quiz.db -compact
diff --git a/games/quiz/quiz.c b/games/quiz/quiz.c
index 28eb3904aac..56208d79fbb 100644
--- a/games/quiz/quiz.c
+++ b/games/quiz/quiz.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: quiz.c,v 1.6 1998/08/19 07:40:57 pjanzen Exp $ */
/* $NetBSD: quiz.c,v 1.9 1995/04/22 10:16:58 cgd Exp $ */
/*-
@@ -45,20 +46,21 @@ static char copyright[] =
#ifndef lint
#if 0
-static char sccsid[] = "@(#)quiz.c 8.2 (Berkeley) 1/3/94";
+static char sccsid[] = "@(#)quiz.c 8.3 (Berkeley) 5/4/95";
#else
-static char rcsid[] = "$NetBSD: quiz.c,v 1.9 1995/04/22 10:16:58 cgd Exp $";
+static char rcsid[] = "$OpenBSD: quiz.c,v 1.6 1998/08/19 07:40:57 pjanzen Exp $";
#endif
#endif /* not lint */
#include <sys/types.h>
#include <errno.h>
-#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <err.h>
+#include <time.h>
+#include <unistd.h>
#include "quiz.h"
#include "pathnames.h"
@@ -81,7 +83,7 @@ main(argc, argv)
int argc;
char *argv[];
{
- register int ch;
+ int ch;
char *indexfile;
/* revoke */
@@ -124,8 +126,8 @@ void
get_file(file)
char *file;
{
- register FILE *fp;
- register QE *qp;
+ FILE *fp;
+ QE *qp;
size_t len;
char *lp;
@@ -140,15 +142,18 @@ get_file(file)
qp = &qlist;
qsize = 0;
while ((lp = fgetln(fp, &len)) != NULL) {
- lp[--len] = '\0';
+ if (lp[len - 1] == '\n')
+ --len;
if (qp->q_text && qp->q_text[strlen(qp->q_text) - 1] == '\\')
qp->q_text = appdstr(qp->q_text, lp, len);
else {
if ((qp->q_next = malloc(sizeof(QE))) == NULL)
- err(1, NULL);
+ errx(1, "malloc");
qp = qp->q_next;
- if ((qp->q_text = strdup(lp)) == NULL)
- err(1, NULL);
+ if ((qp->q_text = malloc(len + 1)) == NULL)
+ errx(1, "malloc");
+ strncpy(qp->q_text, lp, len);
+ qp->q_text[len] = '\0';
qp->q_asked = qp->q_answered = FALSE;
qp->q_next = NULL;
++qsize;
@@ -160,8 +165,8 @@ get_file(file)
void
show_index()
{
- register QE *qp;
- register char *p, *s;
+ QE *qp;
+ char *p, *s;
FILE *pf;
if ((pf = popen(_PATH_PAGER, "w")) == NULL)
@@ -171,7 +176,7 @@ show_index()
for (s = next_cat(qp->q_text); s; s = next_cat(s)) {
if (!rxp_compile(s))
errx(1, "%s", rxperr);
- if (p = rxp_expand())
+ if ((p = rxp_expand()))
(void)fprintf(pf, "%s ", p);
}
(void)fprintf(pf, "\n");
@@ -187,7 +192,7 @@ void
get_cats(cat1, cat2)
char *cat1, *cat2;
{
- register QE *qp;
+ QE *qp;
int i;
char *s;
@@ -219,8 +224,8 @@ get_cats(cat1, cat2)
void
quiz()
{
- register QE *qp;
- register int i;
+ QE *qp;
+ int i;
size_t len;
u_int guesses, rights, wrongs;
int next;
@@ -272,7 +277,8 @@ quiz()
qp->q_asked = TRUE;
(void)printf("%s?\n", question);
for (;; ++guesses) {
- if ((answer = fgetln(stdin, &len)) == NULL) {
+ if ((answer = fgetln(stdin, &len)) == NULL ||
+ answer[len - 1] != '\n') {
score(rights, wrongs, guesses);
exit(0);
}
@@ -299,10 +305,11 @@ quiz()
char *
next_cat(s)
- register char * s;
+ char * s;
{
- int esc = 0;
+ int esc;
+ esc = 0;
for (;;)
switch (*s++) {
case '\0':
@@ -323,21 +330,23 @@ next_cat(s)
char *
appdstr(s, tp, len)
char *s;
- register char *tp;
+ char *tp;
size_t len;
{
- register char *mp, *sp;
- register int ch;
+ char *mp, *sp;
+ int ch;
char *m;
if ((m = malloc(strlen(s) + len + 1)) == NULL)
- err(1, NULL);
- for (mp = m, sp = s; *mp++ = *sp++;);
+ errx(1, "malloc");
+ for (mp = m, sp = s; (*mp++ = *sp++) != NULL; )
+ ;
--mp;
if (*(mp - 1) == '\\')
--mp;
- while ((ch = *mp++ = *tp++) && ch != '\n');
+ while ((ch = *mp++ = *tp++) && ch != '\n')
+ ;
*mp = '\0';
free(s);
@@ -356,11 +365,11 @@ score(r, w, g)
void
downcase(p)
- register char *p;
+ char *p;
{
- register int ch;
+ int ch;
- for (; ch = *p; ++p)
+ for (; (ch = *p) != '\0'; ++p)
if (isascii(ch) && isupper(ch))
*p = tolower(ch);
}
diff --git a/games/quiz/quiz.h b/games/quiz/quiz.h
index ff7e4ded91e..71805f7f7b5 100644
--- a/games/quiz/quiz.h
+++ b/games/quiz/quiz.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: quiz.h,v 1.2 1998/08/19 07:40:59 pjanzen Exp $ */
/* $NetBSD: quiz.h,v 1.4 1995/04/22 10:16:59 cgd Exp $ */
/*-
diff --git a/games/quiz/rxp.c b/games/quiz/rxp.c
index f835913e4cd..b3e2d5b4ac2 100644
--- a/games/quiz/rxp.c
+++ b/games/quiz/rxp.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: rxp.c,v 1.2 1998/08/19 07:41:00 pjanzen Exp $ */
/* $NetBSD: rxp.c,v 1.5 1995/04/22 10:17:00 cgd Exp $ */
/*-
@@ -41,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)rxp.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: rxp.c,v 1.5 1995/04/22 10:17:00 cgd Exp $";
+static char rcsid[] = "$OpenBSD: rxp.c,v 1.2 1998/08/19 07:41:00 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -90,14 +91,14 @@ static int rxp__match __P((char *, int, Rxp_t *, Rxp_t *, char *));
int
rxp_compile(s)
- register char * s;
+ char * s;
{
return (rxp__compile(s, TRUE));
}
static int
rxp__compile(s, first)
- register char *s;
+ char *s;
int first;
{
static Rxp_t *rp;
@@ -195,7 +196,7 @@ rxp__compile(s, first)
*/
int
rxp_match(s)
- register char * s;
+ char * s;
{
return (rxp__match(s, TRUE, NULL, NULL, NULL));
}
@@ -210,8 +211,8 @@ rxp__match(s, first, j_succ, j_fail, sp_fail)
{
static Rxp_t *rp;
static char *sp;
- register int ch;
- Rxp_t *grp_end;
+ int ch;
+ Rxp_t *grp_end = NULL;
int err;
if (first) {
diff --git a/games/rain/rain.6 b/games/rain/rain.6
index 9767a0ec6be..90e30cbab18 100644
--- a/games/rain/rain.6
+++ b/games/rain/rain.6
@@ -1,4 +1,4 @@
-.\" $OpenBSD: rain.6,v 1.5 1998/03/12 09:06:46 pjanzen Exp $
+.\" $OpenBSD: rain.6,v 1.6 1998/08/19 07:41:05 pjanzen Exp $
.\"
.\" Copyright (c) 1989, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -38,18 +38,18 @@
.Os
.Sh NAME
.Nm rain
-.Op Fl d Ar delay
.Nd animated raindrops display
.Sh SYNOPSIS
-.Nm /usr/games/rain
+.Nm
+.Op Fl d Ar delay
.Sh DESCRIPTION
-.Nm Rain Ns 's
-display is modeled after the
+.Nm Rain
+is modeled after the
.Tn VAX/VMS
program of the same name.
To obtain the proper effect, either the terminal must be set for 9600 baud
or the
-.Nm -d
+.Fl d
option must be used to specify a delay, in milliseconds, between each update. A
reasonable delay is 120; the default is 0.
.Pp
diff --git a/games/rain/rain.c b/games/rain/rain.c
index 4dde05388c6..9abe0ceb068 100644
--- a/games/rain/rain.c
+++ b/games/rain/rain.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rain.c,v 1.5 1998/03/12 09:09:22 pjanzen Exp $ */
+/* $OpenBSD: rain.c,v 1.6 1998/08/19 07:41:06 pjanzen Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)rain.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: rain.c,v 1.5 1998/03/12 09:09:22 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: rain.c,v 1.6 1998/08/19 07:41:06 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -53,19 +53,24 @@ static char rcsid[] = "$OpenBSD: rain.c,v 1.5 1998/03/12 09:09:22 pjanzen Exp $"
*/
#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <err.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
+#include <string.h>
#include <term.h>
#include <termios.h>
-#include <signal.h>
-#include <string.h>
+#include <unistd.h>
#define cursor(c, r) tputs(tgoto(CM, c, r), 1, fputchar)
static struct termios sg, old_tty;
-int fputchar __P((int));
+int fputchar __P((int));
+static void onsig __P((int));
+
+
char *LL, *TE, *VE;
int
@@ -80,11 +85,8 @@ main(argc, argv)
char *TI, *tcp, *mp, tcb[100];
long tcols, tlines;
u_int delay = 0;
- extern int optind;
- extern char *optarg;
char ch;
int xpos[5], ypos[5];
- static void onsig();
#ifdef TIOCGWINSZ
struct winsize ws;
#endif
@@ -97,10 +99,8 @@ main(argc, argv)
switch(ch) {
case 'd':
if ((delay = (u_int)strtoul(optarg,(char **)NULL,10)) < 1
- || delay > 1000) {
- (void)fprintf(stderr,"rain: invalid delay (1-1000)\n");
- exit(1);
- }
+ || delay > 1000)
+ errx(1, "invalid delay (1-1000)");
delay *= 1000; /* ms -> us */
break;
case 'h':
@@ -109,23 +109,15 @@ main(argc, argv)
exit(1);
}
- if (!(term = getenv("TERM"))) {
- fprintf(stderr, "%s: TERM: parameter not set\n", *argv);
- exit(1);
- }
- if (!(mp = malloc((u_int)1024))) {
- fprintf(stderr, "%s: out of space.\n", *argv);
- exit(1);
- }
- if (tgetent(mp, term) <= 0) {
- fprintf(stderr, "%s: %s: unknown terminal type\n", *argv, term);
- exit(1);
- }
+ if (!(term = getenv("TERM")))
+ errx(1, "TERM: parameter not set");
+ if (!(mp = malloc((u_int)1024)))
+ errx(1, "out of space");
+ if (tgetent(mp, term) <= 0)
+ errx(1, "unknown terminal type `%s'", term);
tcp = tcb;
- if (!(CM = tgetstr("cm", &tcp))) {
- fprintf(stderr, "%s: terminal not capable of cursor motion\n", *argv);
- exit(1);
- }
+ if (!(CM = tgetstr("cm", &tcp)))
+ errx(1, "terminal not capable of cursor motion");
if (!(BC = tgetstr("bc", &tcp)))
BC = "\b";
if (!(DN = tgetstr("dn", &tcp)))
@@ -251,7 +243,8 @@ main(argc, argv)
}
static void
-onsig()
+onsig(dummy)
+ int dummy;
{
tputs(VE, 1, fputchar);
tputs(LL, 1, fputchar);
diff --git a/games/trek/Makefile b/games/trek/Makefile
index f2748c55013..d4c1e917871 100644
--- a/games/trek/Makefile
+++ b/games/trek/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.2 1997/09/21 11:37:09 deraadt Exp $
+# $OpenBSD: Makefile,v 1.3 1998/08/19 07:41:08 pjanzen Exp $
PROG= trek
SRCS= abandon.c attack.c autover.c capture.c check_out.c checkcond.c \
@@ -6,9 +6,8 @@ SRCS= abandon.c attack.c autover.c capture.c check_out.c checkcond.c \
dock.c dumpgame.c dumpme.c dumpssradio.c events.c externs.c \
getcodi.c getpar.c help.c impulse.c initquad.c kill.c klmove.c \
lose.c lrscan.c main.c move.c nova.c out.c phaser.c play.c ram.c \
- ranf.c rest.c schedule.c score.c setup.c setwarp.c \
- shield.c snova.c srscan.c systemname.c torped.c utility.c \
- visual.c warp.c win.c cgetc.c
+ ranf.c rest.c schedule.c score.c setup.c setwarp.c shield.c \
+ snova.c srscan.c systemname.c torped.c visual.c warp.c win.c cgetc.c
MAN= trek.6
DPADD= ${LIBM}
LDADD= -lm
diff --git a/games/trek/abandon.c b/games/trek/abandon.c
index b33d0f084f5..48f36a88ce4 100644
--- a/games/trek/abandon.c
+++ b/games/trek/abandon.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: abandon.c,v 1.2 1998/08/19 07:41:09 pjanzen Exp $ */
/* $NetBSD: abandon.c,v 1.3 1995/04/22 10:58:24 cgd Exp $ */
/*
@@ -37,11 +38,12 @@
#if 0
static char sccsid[] = "@(#)abandon.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: abandon.c,v 1.3 1995/04/22 10:58:24 cgd Exp $";
+static char rcsid[] = "$OpenBSD: abandon.c,v 1.2 1998/08/19 07:41:09 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include "trek.h"
/*
** Abandon Ship
@@ -68,7 +70,9 @@ static char rcsid[] = "$NetBSD: abandon.c,v 1.3 1995/04/22 10:58:24 cgd Exp $";
** Uses trace flag 40
*/
-abandon()
+void
+abandon(v)
+ int v;
{
register struct quad *q;
register int i;
@@ -76,11 +80,17 @@ abandon()
register struct event *e;
if (Ship.ship == QUEENE)
- return (printf("You may not abandon ye Faire Queene\n"));
+ {
+ printf("You may not abandon ye Faire Queene\n");
+ return;
+ }
if (Ship.cond != DOCKED)
{
if (damaged(SHUTTLE))
- return (out(SHUTTLE));
+ {
+ out(SHUTTLE);
+ return;
+ }
printf("Officers escape in shuttlecraft\n");
/* decide on fate of crew */
q = &Quad[Ship.quadx][Ship.quady];
@@ -154,7 +164,7 @@ abandon()
if (Sect[Ship.sectx][Ship.secty] == EMPTY)
{
Sect[Ship.sectx][Ship.secty] = QUEENE;
- dock();
+ dock(0);
compkldist(0);
return;
}
diff --git a/games/trek/attack.c b/games/trek/attack.c
index b1b0abb64ff..0bfb0d3b92e 100644
--- a/games/trek/attack.c
+++ b/games/trek/attack.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: attack.c,v 1.2 1998/08/19 07:41:10 pjanzen Exp $ */
/* $NetBSD: attack.c,v 1.3 1995/04/22 10:58:26 cgd Exp $ */
/*
@@ -37,11 +38,13 @@
#if 0
static char sccsid[] = "@(#)attack.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: attack.c,v 1.3 1995/04/22 10:58:26 cgd Exp $";
+static char rcsid[] = "$OpenBSD: attack.c,v 1.2 1998/08/19 07:41:10 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include <math.h>
+#include "trek.h"
/*
** Klingon Attack Routine
@@ -73,15 +76,16 @@ static char rcsid[] = "$NetBSD: attack.c,v 1.3 1995/04/22 10:58:26 cgd Exp $";
** Casualties can also occur.
*/
+void
attack(resting)
-int resting; /* set if attack while resting */
+ int resting; /* set if attack while resting */
{
- register int hit, i, l;
- int maxhit, tothit, shldabsb;
- double chgfac, propor, extradm;
- double dustfac, tothe;
- int cas;
- int hitflag;
+ register int hit, i, l;
+ int maxhit, tothit, shldabsb;
+ double chgfac, propor, extradm;
+ double dustfac, tothe;
+ int cas;
+ int hitflag;
if (Move.free)
return;
@@ -189,6 +193,4 @@ int resting; /* set if attack while resting */
/* allow Klingons to move after attacking */
klmove(1);
-
- return;
}
diff --git a/games/trek/autover.c b/games/trek/autover.c
index 96a78373ac7..0935ec71640 100644
--- a/games/trek/autover.c
+++ b/games/trek/autover.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: autover.c,v 1.2 1998/08/19 07:41:12 pjanzen Exp $ */
/* $NetBSD: autover.c,v 1.3 1995/04/22 10:58:28 cgd Exp $ */
/*
@@ -37,11 +38,12 @@
#if 0
static char sccsid[] = "@(#)autover.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: autover.c,v 1.3 1995/04/22 10:58:28 cgd Exp $";
+static char rcsid[] = "$OpenBSD: autover.c,v 1.2 1998/08/19 07:41:12 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include "trek.h"
/*
** Automatic Override
@@ -61,6 +63,7 @@ static char rcsid[] = "$NetBSD: autover.c,v 1.3 1995/04/22 10:58:28 cgd Exp $";
** quadrants, since that is all that is needed.
*/
+void
autover()
{
double dist;
diff --git a/games/trek/capture.c b/games/trek/capture.c
index d4849598e53..e062fc7ccc3 100644
--- a/games/trek/capture.c
+++ b/games/trek/capture.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: capture.c,v 1.2 1998/08/19 07:41:13 pjanzen Exp $ */
/* $NetBSD: capture.c,v 1.3 1995/04/22 10:58:32 cgd Exp $ */
/*
@@ -37,11 +38,12 @@
#if 0
static char sccsid[] = "@(#)capture.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: capture.c,v 1.3 1995/04/22 10:58:32 cgd Exp $";
+static char rcsid[] = "$OpenBSD: capture.c,v 1.2 1998/08/19 07:41:13 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include "trek.h"
/*
** Ask a Klingon To Surrender
@@ -56,13 +58,13 @@ static char rcsid[] = "$NetBSD: capture.c,v 1.3 1995/04/22 10:58:32 cgd Exp $";
** is a function of that Klingon's remaining power, our power,
** etc.
*/
-
-capture()
+void
+capture(v)
+ int v;
{
register int i;
register struct kling *k;
double x;
- extern struct kling *selectklingon();
/* check for not cloaked */
if (Ship.cloaked)
@@ -71,7 +73,10 @@ capture()
return;
}
if (damaged(SSRADIO))
- return (out(SSRADIO));
+ {
+ out(SSRADIO);
+ return;
+ }
/* find out if there are any at all */
if (Etc.nkling <= 0)
{
@@ -122,7 +127,8 @@ capture()
** Cruddy, just takes one at random. Should ask the captain.
*/
-struct kling *selectklingon()
+struct kling *
+selectklingon()
{
register int i;
diff --git a/games/trek/cgetc.c b/games/trek/cgetc.c
index 5a997bd3256..9e1f10ceaf8 100644
--- a/games/trek/cgetc.c
+++ b/games/trek/cgetc.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: cgetc.c,v 1.2 1998/08/19 07:41:15 pjanzen Exp $ */
/* $NetBSD: cgetc.c,v 1.3 1995/04/22 10:58:34 cgd Exp $ */
/*
@@ -37,14 +38,15 @@
#if 0
static char sccsid[] = "@(#)cgetc.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: cgetc.c,v 1.3 1995/04/22 10:58:34 cgd Exp $";
+static char rcsid[] = "$OpenBSD: cgetc.c,v 1.2 1998/08/19 07:41:15 pjanzen Exp $";
#endif
#endif /* not lint */
-# include <stdio.h>
+#include <stdio.h>
-char cgetc(i)
-int i;
+char
+cgetc(i)
+ int i;
{
return ( getchar() );
}
diff --git a/games/trek/check_out.c b/games/trek/check_out.c
index 2ebdf45d61d..1ce3cf29902 100644
--- a/games/trek/check_out.c
+++ b/games/trek/check_out.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: check_out.c,v 1.2 1998/08/19 07:41:16 pjanzen Exp $ */
/* $NetBSD: check_out.c,v 1.3 1995/04/22 10:58:35 cgd Exp $ */
/*
@@ -37,11 +38,12 @@
#if 0
static char sccsid[] = "@(#)check_out.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: check_out.c,v 1.3 1995/04/22 10:58:35 cgd Exp $";
+static char rcsid[] = "$OpenBSD: check_out.c,v 1.2 1998/08/19 07:41:16 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include "trek.h"
/*
** CHECK IF A DEVICE IS OUT
@@ -54,8 +56,9 @@ static char rcsid[] = "$NetBSD: check_out.c,v 1.3 1995/04/22 10:58:35 cgd Exp $"
** It prints appropriate messages too.
*/
+int
check_out(device)
-int device;
+ int device;
{
register int dev;
diff --git a/games/trek/checkcond.c b/games/trek/checkcond.c
index 3c565a142fc..cc3e0e296c7 100644
--- a/games/trek/checkcond.c
+++ b/games/trek/checkcond.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: checkcond.c,v 1.2 1998/08/19 07:41:17 pjanzen Exp $ */
/* $NetBSD: checkcond.c,v 1.3 1995/04/22 10:58:37 cgd Exp $ */
/*
@@ -37,11 +38,11 @@
#if 0
static char sccsid[] = "@(#)checkcond.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: checkcond.c,v 1.3 1995/04/22 10:58:37 cgd Exp $";
+static char rcsid[] = "$OpenBSD: checkcond.c,v 1.2 1998/08/19 07:41:17 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include "trek.h"
/*
** Check for Condition After a Move
@@ -68,10 +69,9 @@ static char rcsid[] = "$NetBSD: checkcond.c,v 1.3 1995/04/22 10:58:37 cgd Exp $"
** and battle conditions.
*/
+void
checkcond()
{
- register int i, j;
-
/* see if we are still alive and well */
if (Ship.reserves < 0.0)
lose(L_NOLIFE);
@@ -106,5 +106,4 @@ checkcond()
return;
}
Ship.cond = GREEN;
- return;
}
diff --git a/games/trek/compkl.c b/games/trek/compkl.c
index 4aa0f056c5f..eac12ad0b6c 100644
--- a/games/trek/compkl.c
+++ b/games/trek/compkl.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: compkl.c,v 1.2 1998/08/19 07:41:18 pjanzen Exp $ */
/* $NetBSD: compkl.c,v 1.3 1995/04/22 10:58:38 cgd Exp $ */
/*
@@ -37,11 +38,12 @@
#if 0
static char sccsid[] = "@(#)compkl.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: compkl.c,v 1.3 1995/04/22 10:58:38 cgd Exp $";
+static char rcsid[] = "$OpenBSD: compkl.c,v 1.2 1998/08/19 07:41:18 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <math.h>
+#include "trek.h"
/*
** compute klingon distances
@@ -54,8 +56,11 @@ static char rcsid[] = "$NetBSD: compkl.c,v 1.3 1995/04/22 10:58:38 cgd Exp $";
** move.
*/
+static void sortkl __P((void));
+
+void
compkldist(f)
-int f; /* set if new quadrant */
+ int f; /* set if new quadrant */
{
register int i, dx, dy;
double d;
@@ -96,6 +101,7 @@ int f; /* set if new quadrant */
** bubble sort on ascending distance
*/
+static void
sortkl()
{
struct kling t;
@@ -109,9 +115,9 @@ sortkl()
for (i = 0; i < m; i++)
if (Etc.klingon[i].dist > Etc.klingon[i+1].dist)
{
- bmove(&Etc.klingon[i], &t, sizeof t);
- bmove(&Etc.klingon[i+1], &Etc.klingon[i], sizeof t);
- bmove(&t, &Etc.klingon[i+1], sizeof t);
+ t = Etc.klingon[i];
+ Etc.klingon[i] = Etc.klingon[i + 1];
+ Etc.klingon[i + 1] = t;
f = 1;
}
}
diff --git a/games/trek/computer.c b/games/trek/computer.c
index dbf5e614291..c036a1f592f 100644
--- a/games/trek/computer.c
+++ b/games/trek/computer.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: computer.c,v 1.2 1998/08/19 07:41:20 pjanzen Exp $ */
/* $NetBSD: computer.c,v 1.4 1995/04/24 12:25:51 cgd Exp $ */
/*
@@ -37,13 +38,15 @@
#if 0
static char sccsid[] = "@(#)computer.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: computer.c,v 1.4 1995/04/24 12:25:51 cgd Exp $";
+static char rcsid[] = "$OpenBSD: computer.c,v 1.2 1998/08/19 07:41:20 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
-# include "getpar.h"
-# include <stdio.h>
+#include <stdio.h>
+#include <math.h>
+#include "trek.h"
+#include "getpar.h"
+
/*
** On-Board Computer
**
@@ -92,23 +95,27 @@ static char rcsid[] = "$NetBSD: computer.c,v 1.4 1995/04/24 12:25:51 cgd Exp $";
struct cvntab Cputab[] =
{
- "ch", "art", (int (*)())1, 0,
- "t", "rajectory", (int (*)())2, 0,
- "c", "ourse", (int (*)())3, 0,
- "m", "ove", (int (*)())3, 1,
- "s", "core", (int (*)())4, 0,
- "p", "heff", (int (*)())5, 0,
- "w", "arpcost", (int (*)())6, 0,
- "i", "mpcost", (int (*)())7, 0,
- "d", "istresslist", (int (*)())8, 0,
- 0
+ { "ch", "art", (cmdfun)1, 0 },
+ { "t", "rajectory", (cmdfun)2, 0 },
+ { "c", "ourse", (cmdfun)3, 0 },
+ { "m", "ove", (cmdfun)3, 1 },
+ { "s", "core", (cmdfun)4, 0 },
+ { "p", "heff", (cmdfun)5, 0 },
+ { "w", "arpcost", (cmdfun)6, 0 },
+ { "i", "mpcost", (cmdfun)7, 0 },
+ { "d", "istresslist", (cmdfun)8, 0 },
+ { NULL, NULL, NULL, 0 }
};
-computer()
+static int kalc __P((int, int, int, int, double *));
+static void prkalc __P((int, double));
+
+void
+computer(v)
+ int v;
{
int ix, iy;
register int i, j;
- int numout;
int tqx, tqy;
struct cvntab *r;
int cost;
@@ -146,10 +153,12 @@ computer()
q = &Quad[i][j];
/* 1000 or 1001 is special case */
if (q->scanned >= 1000)
+ {
if (q->scanned > 1000)
printf(".1. ");
else
printf("/// ");
+ }
else
if (q->scanned < 0)
printf("... ");
@@ -311,12 +320,13 @@ computer()
** sqx,sqy/ssx,ssy to tqx,tqy/tsx,tsy.
*/
+static int
kalc(tqx, tqy, tsx, tsy, dist)
-int tqx;
-int tqy;
-int tsx;
-int tsy;
-double *dist;
+ int tqx;
+ int tqy;
+ int tsx;
+ int tsy;
+ double *dist;
{
double dx, dy;
double quadsize;
@@ -340,10 +350,10 @@ double *dist;
return (course);
}
-
+static void
prkalc(course, dist)
-int course;
-double dist;
+ int course;
+ double dist;
{
printf(": course %d dist %.3f\n", course, dist);
}
diff --git a/games/trek/damage.c b/games/trek/damage.c
index 35d05dbec87..e9981ddb0d5 100644
--- a/games/trek/damage.c
+++ b/games/trek/damage.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: damage.c,v 1.2 1998/08/19 07:41:21 pjanzen Exp $ */
/* $NetBSD: damage.c,v 1.3 1995/04/22 10:58:40 cgd Exp $ */
/*
@@ -37,11 +38,13 @@
#if 0
static char sccsid[] = "@(#)damage.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: damage.c,v 1.3 1995/04/22 10:58:40 cgd Exp $";
+static char rcsid[] = "$OpenBSD: damage.c,v 1.2 1998/08/19 07:41:21 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include <err.h>
+#include "trek.h"
/*
** Schedule Ship.damages to a Device
@@ -55,9 +58,10 @@ static char rcsid[] = "$NetBSD: damage.c,v 1.3 1995/04/22 10:58:40 cgd Exp $";
** that the dock() and undock() have to reschedule the event.
*/
+void
damage(dev1, dam)
-int dev1; /* device index */
-double dam; /* time to repair */
+ int dev1; /* device index */
+ double dam; /* time to repair */
{
register int i;
register struct event *e;
@@ -93,5 +97,5 @@ double dam; /* time to repair */
reschedule(e, e->date - Now.date + dam);
return;
}
- syserr("Cannot find old damages %d\n", dev);
+ errx(1, "Cannot find old damages %d\n", dev);
}
diff --git a/games/trek/damaged.c b/games/trek/damaged.c
index 004b2b05fd3..287264bca47 100644
--- a/games/trek/damaged.c
+++ b/games/trek/damaged.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: damaged.c,v 1.2 1998/08/19 07:41:22 pjanzen Exp $ */
/* $NetBSD: damaged.c,v 1.3 1995/04/22 10:58:41 cgd Exp $ */
/*
@@ -37,11 +38,11 @@
#if 0
static char sccsid[] = "@(#)damaged.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: damaged.c,v 1.3 1995/04/22 10:58:41 cgd Exp $";
+static char rcsid[] = "$OpenBSD: damaged.c,v 1.2 1998/08/19 07:41:22 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include "trek.h"
/* DAMAGED -- check for device damaged
**
@@ -50,8 +51,9 @@ static char rcsid[] = "$NetBSD: damaged.c,v 1.3 1995/04/22 10:58:41 cgd Exp $";
** event list for a "device fix" action on that device.
*/
+int
damaged(dev)
-int dev;
+ int dev;
{
register int d;
register struct event *e;
diff --git a/games/trek/dcrept.c b/games/trek/dcrept.c
index 0c6b55276ea..52cb3be46cb 100644
--- a/games/trek/dcrept.c
+++ b/games/trek/dcrept.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: dcrept.c,v 1.2 1998/08/19 07:41:23 pjanzen Exp $ */
/* $NetBSD: dcrept.c,v 1.3 1995/04/22 10:58:43 cgd Exp $ */
/*
@@ -37,11 +38,12 @@
#if 0
static char sccsid[] = "@(#)dcrept.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: dcrept.c,v 1.3 1995/04/22 10:58:43 cgd Exp $";
+static char rcsid[] = "$OpenBSD: dcrept.c,v 1.2 1998/08/19 07:41:23 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include "trek.h"
/*
** damage control report
@@ -55,7 +57,9 @@ static char rcsid[] = "$NetBSD: dcrept.c,v 1.3 1995/04/22 10:58:43 cgd Exp $";
** fix things if you are docked.
*/
-dcrept()
+void
+dcrept(v)
+ int v;
{
register int i, f;
double x;
diff --git a/games/trek/destruct.c b/games/trek/destruct.c
index f4bee5c2feb..132d058b322 100644
--- a/games/trek/destruct.c
+++ b/games/trek/destruct.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: destruct.c,v 1.2 1998/08/19 07:41:25 pjanzen Exp $ */
/* $NetBSD: destruct.c,v 1.3 1995/04/22 10:58:44 cgd Exp $ */
/*
@@ -37,11 +38,14 @@
#if 0
static char sccsid[] = "@(#)destruct.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: destruct.c,v 1.3 1995/04/22 10:58:44 cgd Exp $";
+static char rcsid[] = "$OpenBSD: destruct.c,v 1.2 1998/08/19 07:41:25 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include <unistd.h>
+#include "trek.h"
+#include "getpar.h"
/*
** Self Destruct Sequence
@@ -63,14 +67,19 @@ static char rcsid[] = "$NetBSD: destruct.c,v 1.3 1995/04/22 10:58:44 cgd Exp $";
** Uses trace flag 41
*/
-destruct()
+void
+destruct(v)
+ int v;
{
char checkpass[15];
register int i, j;
double zap;
if (damaged(COMPUTER))
- return (out(COMPUTER));
+ {
+ out(COMPUTER);
+ return;
+ }
printf("\n\07 --- WORKING ---\07\n");
sleep(3);
/* output the count 10 9 8 7 6 */
@@ -85,8 +94,11 @@ destruct()
skiptonl(0);
getstrpar("Enter password verification", checkpass, 14, 0);
sleep(2);
- if (!sequal(checkpass, Game.passwd))
- return (printf("Self destruct sequence aborted\n"));
+ if (strcmp(checkpass, Game.passwd) != 0)
+ {
+ printf("Self destruct sequence aborted\n");
+ return;
+ }
printf("Password verified; self destruct sequence continues:\n");
sleep(2);
/* output count 5 4 3 2 1 0 */
diff --git a/games/trek/dock.c b/games/trek/dock.c
index 7dcc1f5215e..960dac72e8c 100644
--- a/games/trek/dock.c
+++ b/games/trek/dock.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: dock.c,v 1.2 1998/08/19 07:41:26 pjanzen Exp $ */
/* $NetBSD: dock.c,v 1.3 1995/04/22 10:58:45 cgd Exp $ */
/*
@@ -37,11 +38,12 @@
#if 0
static char sccsid[] = "@(#)dock.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: dock.c,v 1.3 1995/04/22 10:58:45 cgd Exp $";
+static char rcsid[] = "$OpenBSD: dock.c,v 1.2 1998/08/19 07:41:26 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include "trek.h"
/*
** DOCK TO STARBASE
@@ -58,14 +60,19 @@ static char rcsid[] = "$NetBSD: dock.c,v 1.3 1995/04/22 10:58:45 cgd Exp $";
** are docked.
*/
-dock()
+void
+dock(v)
+ int v;
{
register int i, j;
int ok;
register struct event *e;
if (Ship.cond == DOCKED)
- return (printf("Chekov: But captain, we are already docked\n"));
+ {
+ printf("Chekov: But captain, we are already docked\n");
+ return;
+ }
/* check for ok to dock, i.e., adjacent to a starbase */
ok = 0;
for (i = Ship.sectx - 1; i <= Ship.sectx + 1 && !ok; i++)
@@ -84,7 +91,10 @@ dock()
}
}
if (!ok)
- return (printf("Chekov: But captain, we are not adjacent to a starbase.\n"));
+ {
+ printf("Chekov: But captain, we are not adjacent to a starbase.\n");
+ return;
+ }
/* restore resources */
Ship.energy = Param.energy;
@@ -114,7 +124,6 @@ dock()
continue;
reschedule(e, (e->date - Now.date) * Param.dockfac);
}
- return;
}
@@ -125,7 +134,9 @@ dock()
** is to reschedule any damages so that they will take longer.
*/
-undock()
+void
+undock(v)
+ int v;
{
register struct event *e;
register int i;
@@ -146,5 +157,4 @@ undock()
continue;
reschedule(e, (e->date - Now.date) / Param.dockfac);
}
- return;
}
diff --git a/games/trek/dumpgame.c b/games/trek/dumpgame.c
index 17e7e7a19eb..c8344f31506 100644
--- a/games/trek/dumpgame.c
+++ b/games/trek/dumpgame.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: dumpgame.c,v 1.2 1998/08/19 07:41:29 pjanzen Exp $ */
/* $NetBSD: dumpgame.c,v 1.4 1995/04/24 12:25:54 cgd Exp $ */
/*
@@ -37,11 +38,15 @@
#if 0
static char sccsid[] = "@(#)dumpgame.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: dumpgame.c,v 1.4 1995/04/24 12:25:54 cgd Exp $";
+static char rcsid[] = "$OpenBSD: dumpgame.c,v 1.2 1998/08/19 07:41:29 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include <err.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include "trek.h"
/*** THIS CONSTANT MUST CHANGE AS THE DATA SPACES CHANGE ***/
# define VERSION 2
@@ -55,18 +60,20 @@ struct dump
struct dump Dump_template[] =
{
- (char *)&Ship, sizeof (Ship),
- (char *)&Now, sizeof (Now),
- (char *)&Param, sizeof (Param),
- (char *)&Etc, sizeof (Etc),
- (char *)&Game, sizeof (Game),
- (char *)Sect, sizeof (Sect),
- (char *)Quad, sizeof (Quad),
- (char *)&Move, sizeof (Move),
- (char *)Event, sizeof (Event),
- 0
+ { (char *)&Ship, sizeof (Ship) },
+ { (char *)&Now, sizeof (Now) },
+ { (char *)&Param, sizeof (Param) },
+ { (char *)&Etc, sizeof (Etc) },
+ { (char *)&Game, sizeof (Game) },
+ { (char *)Sect, sizeof (Sect) },
+ { (char *)Quad, sizeof (Quad) },
+ { (char *)&Move, sizeof (Move) },
+ { (char *)Event, sizeof (Event) },
+ { NULL, 0 }
};
+static int readdump __P((int));
+
/*
** DUMP GAME
**
@@ -77,7 +84,9 @@ struct dump Dump_template[] =
** output change.
*/
-dumpgame()
+void
+dumpgame(v)
+ int v;
{
int version;
register int fd;
@@ -85,7 +94,10 @@ dumpgame()
register int i;
if ((fd = creat("trek.dump", 0644)) < 0)
- return (printf("cannot dump\n"));
+ {
+ warn("cannot open `trek.dump'");
+ return;
+ }
version = VERSION;
write(fd, &version, sizeof version);
@@ -112,6 +124,7 @@ dumpgame()
** Return value is zero for success, one for failure.
*/
+int
restartgame()
{
register int fd;
@@ -141,8 +154,9 @@ restartgame()
** Returns zero for success, one for failure.
*/
+static int
readdump(fd1)
-int fd1;
+ int fd1;
{
register int fd;
register struct dump *d;
diff --git a/games/trek/dumpme.c b/games/trek/dumpme.c
index dfb38f0875e..3b2dc13b11d 100644
--- a/games/trek/dumpme.c
+++ b/games/trek/dumpme.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: dumpme.c,v 1.2 1998/08/19 07:41:30 pjanzen Exp $ */
/* $NetBSD: dumpme.c,v 1.3 1995/04/22 10:58:48 cgd Exp $ */
/*
@@ -37,11 +38,12 @@
#if 0
static char sccsid[] = "@(#)dumpme.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: dumpme.c,v 1.3 1995/04/22 10:58:48 cgd Exp $";
+static char rcsid[] = "$OpenBSD: dumpme.c,v 1.2 1998/08/19 07:41:30 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include "trek.h"
/*
** Dump the starship somewhere in the galaxy
@@ -55,8 +57,9 @@ static char rcsid[] = "$NetBSD: dumpme.c,v 1.3 1995/04/22 10:58:48 cgd Exp $";
** Repair of devices must be deferred.
*/
+void
dumpme(flag)
-int flag;
+ int flag;
{
register int f;
double x;
@@ -68,7 +71,7 @@ int flag;
Ship.quady = ranf(NQUADS);
Ship.sectx = ranf(NSECTS);
Ship.secty = ranf(NSECTS);
- x += 1.5 * franf();
+ x = 1.5 * franf();
Move.time += x;
if (f)
{
diff --git a/games/trek/dumpssradio.c b/games/trek/dumpssradio.c
index c824312eff4..47022bb4137 100644
--- a/games/trek/dumpssradio.c
+++ b/games/trek/dumpssradio.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: dumpssradio.c,v 1.2 1998/08/19 07:41:31 pjanzen Exp $ */
/* $NetBSD: dumpssradio.c,v 1.3 1995/04/22 10:58:49 cgd Exp $ */
/*
@@ -37,16 +38,18 @@
#if 0
static char sccsid[] = "@(#)dumpssradio.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: dumpssradio.c,v 1.3 1995/04/22 10:58:49 cgd Exp $";
+static char rcsid[] = "$OpenBSD: dumpssradio.c,v 1.2 1998/08/19 07:41:31 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include "trek.h"
/**
** output hidden distress calls
**/
+int
dumpssradio()
{
register struct event *e;
@@ -64,7 +67,7 @@ dumpssradio()
{
unschedule(e);
printf("Starsystem %s in quadrant %d,%d is no longer distressed\n",
- systemname(e), e->x, e->y);
+ systemname(&Quad[e->x][e->y]), e->x, e->y);
continue;
}
@@ -80,7 +83,7 @@ dumpssradio()
case E_ENSLV:
case E_REPRO:
printf("Starsystem %s in quadrant %d,%d is distressed\n",
- systemname(e), e->x, e->y);
+ systemname(&Quad[e->x][e->y]), e->x, e->y);
chkrest++;
break;
diff --git a/games/trek/events.c b/games/trek/events.c
index c150e10eebb..6faaf2bce9c 100644
--- a/games/trek/events.c
+++ b/games/trek/events.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: events.c,v 1.2 1998/08/19 07:41:33 pjanzen Exp $ */
/* $NetBSD: events.c,v 1.3 1995/04/22 10:58:50 cgd Exp $ */
/*
@@ -37,11 +38,15 @@
#if 0
static char sccsid[] = "@(#)events.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: events.c,v 1.3 1995/04/22 10:58:50 cgd Exp $";
+static char rcsid[] = "$OpenBSD: events.c,v 1.2 1998/08/19 07:41:33 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include "getpar.h"
+#include "trek.h"
/*
** CAUSE TIME TO ELAPSE
@@ -51,17 +56,18 @@ static char rcsid[] = "$NetBSD: events.c,v 1.3 1995/04/22 10:58:50 cgd Exp $";
** and so on.
*/
-
+int
events(warp)
-int warp; /* set if called in a time warp */
+ int warp; /* set if called in a time warp */
{
register int i;
+ char *p;
int j;
struct kling *k;
double rtime;
double xdate;
double idate;
- struct event *ev, *xsched(), *schedule();
+ struct event *ev = NULL;
int ix, iy;
register struct quad *q;
register struct event *e;
@@ -138,7 +144,7 @@ int warp; /* set if called in a time warp */
case E_SNOVA: /* supernova */
/* cause the supernova to happen */
- snova(-1);
+ snova(-1, 0);
/* and schedule the next one */
xresched(e, E_SNOVA, 1);
break;
@@ -389,10 +395,12 @@ int warp; /* set if called in a time warp */
case E_SNAP: /* take a snapshot of the galaxy */
xresched(e, E_SNAP, 1);
- i = (int) Etc.snapshot;
- i = bmove(Quad, i, sizeof (Quad));
- i = bmove(Event, i, sizeof (Event));
- i = bmove(&Now, i, sizeof (Now));
+ p = (char *) Etc.snapshot;
+ memcpy(p, Quad, sizeof (Quad));
+ p += sizeof (Quad);
+ memcpy(p, Event, sizeof (Event));
+ p += sizeof (Event);
+ memcpy(p, &Now, sizeof (Now));
Game.snap = 1;
break;
@@ -447,7 +455,7 @@ int warp; /* set if called in a time warp */
}
/* unschedule an attack during a rest period */
- if (e = Now.eventptr[E_ATTACK])
+ if ((e = Now.eventptr[E_ATTACK]))
unschedule(e);
if (!warp)
diff --git a/games/trek/externs.c b/games/trek/externs.c
index c5a0f387e4d..731770e28c9 100644
--- a/games/trek/externs.c
+++ b/games/trek/externs.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: externs.c,v 1.2 1998/08/19 07:41:34 pjanzen Exp $ */
/* $NetBSD: externs.c,v 1.3 1995/04/22 10:58:53 cgd Exp $ */
/*
@@ -37,11 +38,11 @@
#if 0
static char sccsid[] = "@(#)externs.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: externs.c,v 1.3 1995/04/22 10:58:53 cgd Exp $";
+static char rcsid[] = "$OpenBSD: externs.c,v 1.2 1998/08/19 07:41:34 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include "trek.h"
/*
** global variable definitions
@@ -49,22 +50,22 @@ static char rcsid[] = "$NetBSD: externs.c,v 1.3 1995/04/22 10:58:53 cgd Exp $";
struct device Device[NDEV] =
{
- "warp drive", "Scotty",
- "S.R. scanners", "Scotty",
- "L.R. scanners", "Scotty",
- "phasers", "Sulu",
- "photon tubes", "Sulu",
- "impulse engines", "Scotty",
- "shield control", "Sulu",
- "computer", "Spock",
- "subspace radio", "Uhura",
- "life support", "Scotty",
- "navigation system", "Chekov",
- "cloaking device", "Scotty",
- "transporter", "Scotty",
- "shuttlecraft", "Scotty",
- "*ERR 14*", "Nobody",
- "*ERR 15*", "Nobody"
+ { "warp drive", "Scotty" },
+ { "S.R. scanners", "Scotty" },
+ { "L.R. scanners", "Scotty" },
+ { "phasers", "Sulu" },
+ { "photon tubes", "Sulu" },
+ { "impulse engines", "Scotty" },
+ { "shield control", "Sulu" },
+ { "computer", "Spock" },
+ { "subspace radio", "Uhura" },
+ { "life support", "Scotty" },
+ { "navigation system", "Chekov" },
+ { "cloaking device", "Scotty" },
+ { "transporter", "Scotty" },
+ { "shuttlecraft", "Scotty" },
+ { "*ERR 14*", "Nobody" },
+ { "*ERR 15*", "Nobody" }
};
char *Systemname[NINHAB] =
diff --git a/games/trek/getcodi.c b/games/trek/getcodi.c
index 3152addec4f..b1dc7bb3970 100644
--- a/games/trek/getcodi.c
+++ b/games/trek/getcodi.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: getcodi.c,v 1.2 1998/08/19 07:41:35 pjanzen Exp $ */
/* $NetBSD: getcodi.c,v 1.3 1995/04/22 10:58:55 cgd Exp $ */
/*
@@ -37,11 +38,12 @@
#if 0
static char sccsid[] = "@(#)getcodi.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: getcodi.c,v 1.3 1995/04/22 10:58:55 cgd Exp $";
+static char rcsid[] = "$OpenBSD: getcodi.c,v 1.2 1998/08/19 07:41:35 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "getpar.h"
+#include "getpar.h"
+#include "trek.h"
/*
** get course and distance
@@ -53,11 +55,11 @@ static char rcsid[] = "$NetBSD: getcodi.c,v 1.3 1995/04/22 10:58:55 cgd Exp $";
** (meaning to drop the request).
*/
+int
getcodi(co, di)
-int *co;
-double *di;
+ int *co;
+ double *di;
{
-
*co = getintpar("Course");
/* course must be in the interval [0, 360] */
diff --git a/games/trek/getpar.c b/games/trek/getpar.c
index 77bfa360a9c..eedc05b6570 100644
--- a/games/trek/getpar.c
+++ b/games/trek/getpar.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: getpar.c,v 1.2 1998/08/19 07:41:36 pjanzen Exp $ */
/* $NetBSD: getpar.c,v 1.4 1995/04/24 12:25:57 cgd Exp $ */
/*
@@ -37,19 +38,24 @@
#if 0
static char sccsid[] = "@(#)getpar.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: getpar.c,v 1.4 1995/04/24 12:25:57 cgd Exp $";
+static char rcsid[] = "$OpenBSD: getpar.c,v 1.2 1998/08/19 07:41:36 pjanzen Exp $";
#endif
#endif /* not lint */
-# include <stdio.h>
-# include "getpar.h"
+#include <stdio.h>
+#include <string.h>
+#include "getpar.h"
+#include "trek.h"
+
+static int testterm __P((void));
/**
** get integer parameter
**/
+int
getintpar(s)
-char *s;
+ char *s;
{
register int i;
int n;
@@ -72,8 +78,9 @@ char *s;
** get floating parameter
**/
-double getfltpar(s)
-char *s;
+double
+getfltpar(s)
+ char *s;
{
register int i;
double d;
@@ -98,18 +105,19 @@ char *s;
struct cvntab Yntab[] =
{
- "y", "es", (int (*)())1, 0,
- "n", "o", (int (*)())0, 0,
- 0
+ { "y", "es", (cmdfun)1, 1 },
+ { "n", "o", (cmdfun)0, 0 },
+ { NULL, NULL, NULL, 0 }
};
+int
getynpar(s)
-char *s;
+ char *s;
{
struct cvntab *r;
r = getcodpar(s, Yntab);
- return ((long) r->value);
+ return (r->value2);
}
@@ -117,9 +125,10 @@ char *s;
** get coded parameter
**/
-struct cvntab *getcodpar(s, tab)
-char *s;
-struct cvntab tab[];
+struct cvntab *
+getcodpar(s, tab)
+ char *s;
+ struct cvntab tab[];
{
char input[100];
register struct cvntab *r;
@@ -149,7 +158,8 @@ struct cvntab tab[];
c = 4;
for (r = tab; r->abrev; r++)
{
- concat(r->abrev, r->full, input);
+ strcpy(input, r->abrev);
+ strcat(input, r->full);
printf("%14.14s", input);
if (--c > 0)
continue;
@@ -194,11 +204,12 @@ struct cvntab tab[];
** get string parameter
**/
+void
getstrpar(s, r, l, t)
-char *s;
-char *r;
-int l;
-char *t;
+ char *s;
+ char *r;
+ int l;
+ char *t;
{
register int i;
char format[20];
@@ -227,6 +238,7 @@ char *t;
** test if newline is next valid character
**/
+int
testnl()
{
register char c;
@@ -248,8 +260,9 @@ testnl()
** scan for newline
**/
+void
skiptonl(c)
-char c;
+ char c;
{
while (c != '\n')
if (!(c = cgetc(0)))
@@ -263,9 +276,10 @@ char c;
** test for valid terminator
**/
+static int
testterm()
{
- register char c;
+ char c;
if (!(c = cgetc(0)))
return (1);
@@ -285,12 +299,13 @@ testterm()
** zero is returned.
*/
+int
readdelim(d)
-char d;
+ char d;
{
register char c;
- while (c = cgetc(0))
+ while ((c = cgetc(0)))
{
if (c == d)
return (1);
diff --git a/games/trek/getpar.h b/games/trek/getpar.h
index f7ae0d8cffa..ce8cb129198 100644
--- a/games/trek/getpar.h
+++ b/games/trek/getpar.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: getpar.h,v 1.2 1998/08/19 07:41:38 pjanzen Exp $ */
/* $NetBSD: getpar.h,v 1.3 1995/04/22 10:58:59 cgd Exp $ */
/*
@@ -35,13 +36,23 @@
* @(#)getpar.h 8.1 (Berkeley) 5/31/93
*/
+#include <sys/cdefs.h>
+
+typedef void (*cmdfun) __P((int));
+
struct cvntab /* used for getcodpar() paramater list */
{
char *abrev;
char *full;
- int (*value)();
+ cmdfun value;
int value2;
};
-extern double getfltpar();
-extern struct cvntab *getcodpar();
+int getintpar __P((char *));
+double getfltpar __P((char *));
+int getynpar __P((char *));
+struct cvntab *getcodpar __P((char *, struct cvntab[]));
+void getstrpar __P((char *, char *, int, char *));
+int testnl __P((void));
+void skiptonl __P((int));
+int readdelim __P((int));
diff --git a/games/trek/help.c b/games/trek/help.c
index f718070ee94..fba6b90a84b 100644
--- a/games/trek/help.c
+++ b/games/trek/help.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: help.c,v 1.2 1998/08/19 07:41:39 pjanzen Exp $ */
/* $NetBSD: help.c,v 1.3 1995/04/22 10:59:01 cgd Exp $ */
/*
@@ -37,11 +38,14 @@
#if 0
static char sccsid[] = "@(#)help.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: help.c,v 1.3 1995/04/22 10:59:01 cgd Exp $";
+static char rcsid[] = "$OpenBSD: help.c,v 1.2 1998/08/19 07:41:39 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include <math.h>
+#include <unistd.h>
+#include "trek.h"
/*
** call starbase for help
@@ -66,22 +70,33 @@ static char rcsid[] = "$NetBSD: help.c,v 1.3 1995/04/22 10:59:01 cgd Exp $";
char *Cntvect[3] =
{"first", "second", "third"};
-help()
+void
+help(v)
+ int v;
{
register int i;
double dist, x;
- register int dx, dy;
- int j, l;
+ register int dx = 0, dy = 0;
+ int j, l = 0;
/* check to see if calling for help is reasonable ... */
if (Ship.cond == DOCKED)
- return (printf("Uhura: But Captain, we're already docked\n"));
+ {
+ printf("Uhura: But Captain, we're already docked\n");
+ return;
+ }
/* or possible */
if (damaged(SSRADIO))
- return (out(SSRADIO));
+ {
+ out(SSRADIO);
+ return;
+ }
if (Now.bases <= 0)
- return (printf("Uhura: I'm not getting any response from starbase\n"));
+ {
+ printf("Uhura: I'm not getting any response from starbase\n");
+ return;
+ }
/* tut tut, there goes the score */
Game.helps += 1;
@@ -149,7 +164,7 @@ help()
Ship.sectx = dx;
Ship.secty = dy;
Sect[dx][dy] = Ship.ship;
- dock();
+ dock(0);
compkldist(0);
return;
}
diff --git a/games/trek/impulse.c b/games/trek/impulse.c
index c8f66e2ea34..d3a9118f1f1 100644
--- a/games/trek/impulse.c
+++ b/games/trek/impulse.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: impulse.c,v 1.2 1998/08/19 07:41:40 pjanzen Exp $ */
/* $NetBSD: impulse.c,v 1.3 1995/04/22 10:59:03 cgd Exp $ */
/*
@@ -37,28 +38,37 @@
#if 0
static char sccsid[] = "@(#)impulse.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: impulse.c,v 1.3 1995/04/22 10:59:03 cgd Exp $";
+static char rcsid[] = "$OpenBSD: impulse.c,v 1.2 1998/08/19 07:41:40 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include "trek.h"
+#include "getpar.h"
/**
** move under impulse power
**/
-impulse()
+void
+impulse(v)
+ int v;
{
int course;
register int power;
double dist, time;
register int percent;
- extern double move();
if (Ship.cond == DOCKED)
- return (printf("Scotty: Sorry captain, but we are still docked.\n"));
+ {
+ printf("Scotty: Sorry captain, but we are still docked.\n");
+ return;
+ }
if (damaged(IMPULSE))
- return (out(IMPULSE));
+ {
+ out(IMPULSE);
+ return;
+ }
if (getcodi(&course, &dist))
return;
power = 20 + 100 * dist;
diff --git a/games/trek/initquad.c b/games/trek/initquad.c
index fd40ff05186..c6246609cf9 100644
--- a/games/trek/initquad.c
+++ b/games/trek/initquad.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: initquad.c,v 1.2 1998/08/19 07:41:41 pjanzen Exp $ */
/* $NetBSD: initquad.c,v 1.3 1995/04/22 10:59:04 cgd Exp $ */
/*
@@ -37,11 +38,12 @@
#if 0
static char sccsid[] = "@(#)initquad.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: initquad.c,v 1.3 1995/04/22 10:59:04 cgd Exp $";
+static char rcsid[] = "$OpenBSD: initquad.c,v 1.2 1998/08/19 07:41:41 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include "trek.h"
/*
** Paramize Quadrant Upon Entering
@@ -60,8 +62,9 @@ static char rcsid[] = "$NetBSD: initquad.c,v 1.3 1995/04/22 10:59:04 cgd Exp $";
** to be docked, i.e., abandon() and help().
*/
+void
initquad(f)
-int f;
+ int f;
{
register int i, j;
int rx, ry;
@@ -142,8 +145,9 @@ int f;
}
+void
sector(x, y)
-int *x, *y;
+ int *x, *y;
{
register int i, j;
@@ -154,5 +158,4 @@ int *x, *y;
} while (Sect[i][j] != EMPTY);
*x = i;
*y = j;
- return;
}
diff --git a/games/trek/kill.c b/games/trek/kill.c
index 9045339e9bd..9f5515d0f46 100644
--- a/games/trek/kill.c
+++ b/games/trek/kill.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: kill.c,v 1.2 1998/08/19 07:41:43 pjanzen Exp $ */
/* $NetBSD: kill.c,v 1.3 1995/04/22 10:59:06 cgd Exp $ */
/*
@@ -37,11 +38,12 @@
#if 0
static char sccsid[] = "@(#)kill.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: kill.c,v 1.3 1995/04/22 10:59:06 cgd Exp $";
+static char rcsid[] = "$OpenBSD: kill.c,v 1.2 1998/08/19 07:41:43 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include "trek.h"
/*
** KILL KILL KILL !!!
@@ -59,10 +61,11 @@ static char rcsid[] = "$NetBSD: kill.c,v 1.3 1995/04/22 10:59:06 cgd Exp $";
** and the game is won if that was the last klingon.
*/
+void
killk(ix, iy)
-int ix, iy;
+ int ix, iy;
{
- register int i, j;
+ register int i;
printf(" *** Klingon at %d,%d destroyed ***\n", ix, iy);
@@ -81,7 +84,7 @@ int ix, iy;
/* purge him from the list */
Etc.nkling -= 1;
for (; i < Etc.nkling; i++)
- bmove(&Etc.klingon[i+1], &Etc.klingon[i], sizeof Etc.klingon[i]);
+ Etc.klingon[i] = Etc.klingon[i + 1];
break;
}
@@ -99,8 +102,9 @@ int ix, iy;
** handle a starbase's death
*/
+void
killb(qx, qy)
-int qx, qy;
+ int qx, qy;
{
register struct quad *q;
register struct xy *b;
@@ -110,23 +114,25 @@ int qx, qy;
if (q->bases <= 0)
return;
if (!damaged(SSRADIO))
+ {
/* then update starchart */
if (q->scanned < 1000)
q->scanned -= 10;
else
if (q->scanned > 1000)
q->scanned = -1;
+ }
q->bases = 0;
Now.bases -= 1;
for (b = Now.base; ; b++)
if (qx == b->x && qy == b->y)
break;
- bmove(&Now.base[Now.bases], b, sizeof *b);
+ *b = Now.base[Now.bases];
if (qx == Ship.quadx && qy == Ship.quady)
{
Sect[Etc.starbase.x][Etc.starbase.y] = EMPTY;
if (Ship.cond == DOCKED)
- undock();
+ undock(0);
printf("Starbase at %d,%d destroyed\n", Etc.starbase.x, Etc.starbase.y);
}
else
@@ -146,14 +152,14 @@ int qx, qy;
** kill an inhabited starsystem
**/
+void
kills(x, y, f)
-int x, y; /* quad coords if f == 0, else sector coords */
-int f; /* f != 0 -- this quad; f < 0 -- Enterprise's fault */
+ int x, y; /* quad coords if f == 0, else sector coords */
+ int f; /* f != 0 -- this quad; f < 0 -- Enterprise's fault */
{
register struct quad *q;
register struct event *e;
register char *name;
- char *systemname();
if (f)
{
@@ -190,9 +196,10 @@ int f; /* f != 0 -- this quad; f < 0 -- Enterprise's fault */
** "kill" a distress call
**/
+void
killd(x, y, f)
-int x, y; /* quadrant coordinates */
-int f; /* set if user is to be informed */
+ int x, y; /* quadrant coordinates */
+ int f; /* set if user is to be informed */
{
register struct event *e;
register int i;
diff --git a/games/trek/klmove.c b/games/trek/klmove.c
index 060bcc74410..955d664ee9b 100644
--- a/games/trek/klmove.c
+++ b/games/trek/klmove.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: klmove.c,v 1.2 1998/08/19 07:41:45 pjanzen Exp $ */
/* $NetBSD: klmove.c,v 1.3 1995/04/22 10:59:07 cgd Exp $ */
/*
@@ -37,11 +38,12 @@
#if 0
static char sccsid[] = "@(#)klmove.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: klmove.c,v 1.3 1995/04/22 10:59:07 cgd Exp $";
+static char rcsid[] = "$OpenBSD: klmove.c,v 1.2 1998/08/19 07:41:45 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include "trek.h"
/*
** Move Klingons Around
@@ -66,6 +68,7 @@ static char rcsid[] = "$NetBSD: klmove.c,v 1.3 1995/04/22 10:59:07 cgd Exp $";
** course around stars.
*/
+void
klmove(fl)
int fl;
{
@@ -84,7 +87,7 @@ int fl;
if (Trace)
printf("klmove: fl = %d, Etc.nkling = %d\n", fl, Etc.nkling);
# endif
- for (n = 0; n < Etc.nkling; k && n++)
+ for (n = 0; n < Etc.nkling; n++)
{
k = &Etc.klingon[n];
i = 100;
@@ -151,7 +154,7 @@ int fl;
Sect[k->x][k->y] = EMPTY;
Quad[qx][qy].klings += 1;
Etc.nkling -= 1;
- bmove(&Etc.klingon[Etc.nkling], k, sizeof *k);
+ *k = Etc.klingon[Etc.nkling];
Quad[Ship.quadx][Ship.quady].klings -= 1;
k = 0;
break;
diff --git a/games/trek/lose.c b/games/trek/lose.c
index ab9959d4435..98cf149f095 100644
--- a/games/trek/lose.c
+++ b/games/trek/lose.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: lose.c,v 1.2 1998/08/19 07:41:46 pjanzen Exp $ */
/* $NetBSD: lose.c,v 1.3 1995/04/22 10:59:08 cgd Exp $ */
/*
@@ -37,12 +38,15 @@
#if 0
static char sccsid[] = "@(#)lose.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: lose.c,v 1.3 1995/04/22 10:59:08 cgd Exp $";
+static char rcsid[] = "$OpenBSD: lose.c,v 1.2 1998/08/19 07:41:46 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
-# include <setjmp.h>
+#include <stdio.h>
+#include <setjmp.h>
+#include <unistd.h>
+#include "trek.h"
+#include "getpar.h"
/*
** PRINT OUT LOSER MESSAGES
@@ -69,8 +73,9 @@ char *Losemsg[] =
"Your last crew member died",
};
+void
lose(why)
-int why;
+ int why;
{
extern jmp_buf env;
diff --git a/games/trek/lrscan.c b/games/trek/lrscan.c
index 4d6e7d80c3c..635167c6d3c 100644
--- a/games/trek/lrscan.c
+++ b/games/trek/lrscan.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: lrscan.c,v 1.2 1998/08/19 07:41:47 pjanzen Exp $ */
/* $NetBSD: lrscan.c,v 1.3 1995/04/22 10:59:09 cgd Exp $ */
/*
@@ -37,11 +38,12 @@
#if 0
static char sccsid[] = "@(#)lrscan.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: lrscan.c,v 1.3 1995/04/22 10:59:09 cgd Exp $";
+static char rcsid[] = "$OpenBSD: lrscan.c,v 1.2 1998/08/19 07:41:47 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include "trek.h"
/*
** LONG RANGE OF SCANNERS
@@ -55,15 +57,15 @@ static char rcsid[] = "$NetBSD: lrscan.c,v 1.3 1995/04/22 10:59:09 cgd Exp $";
** for future use by the "chart" option of the computer.
*/
-lrscan()
+void
+lrscan(v)
+ int v;
{
register int i, j;
register struct quad *q;
if (check_out(LRSCAN))
- {
return;
- }
printf("Long range scan for quadrant %d,%d\n\n", Ship.quadx, Ship.quady);
/* print the header on top */
@@ -109,5 +111,4 @@ lrscan()
}
}
printf("\n -------------------\n");
- return;
}
diff --git a/games/trek/main.c b/games/trek/main.c
index d173430fe6e..cc80438a8b9 100644
--- a/games/trek/main.c
+++ b/games/trek/main.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: main.c,v 1.6 1998/08/19 07:41:49 pjanzen Exp $ */
/* $NetBSD: main.c,v 1.4 1995/04/22 10:59:10 cgd Exp $ */
/*
@@ -43,14 +44,19 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: main.c,v 1.4 1995/04/22 10:59:10 cgd Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.6 1998/08/19 07:41:49 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
-# include <stdio.h>
-# include <setjmp.h>
-# include <termios.h>
+#include <sys/types.h>
+#include <stdio.h>
+#include <setjmp.h>
+#include <termios.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <err.h>
+#include "trek.h"
+#include "getpar.h"
# define PRIO 00 /* default priority */
@@ -157,10 +163,10 @@ jmp_buf env;
int
main(argc, argv)
-int argc;
-char **argv;
+ int argc;
+ char **argv;
{
- time_t vect;
+ time_t curtime;
/* extern FILE *f_log; */
register char opencode;
int prio;
@@ -175,8 +181,8 @@ char **argv;
av = argv;
ac = argc;
av++;
- time(&vect);
- srand(vect);
+ time(&curtime);
+ srandom((long)curtime);
opencode = 'w';
prio = PRIO;
@@ -225,7 +231,7 @@ char **argv;
av++;
}
if (ac > 2)
- syserr(0, "arg count");
+ errx(1, "arg count");
/*
if (ac > 1)
f_log = fopen(av[0], opencode);
@@ -245,4 +251,5 @@ char **argv;
} while (getynpar("Another game"));
fflush(stdout);
+ return 0;
}
diff --git a/games/trek/move.c b/games/trek/move.c
index b20faf218b8..2a0ac6e1466 100644
--- a/games/trek/move.c
+++ b/games/trek/move.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: move.c,v 1.2 1998/08/19 07:41:50 pjanzen Exp $ */
/* $NetBSD: move.c,v 1.3 1995/04/22 10:59:12 cgd Exp $ */
/*
@@ -37,11 +38,13 @@
#if 0
static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: move.c,v 1.3 1995/04/22 10:59:12 cgd Exp $";
+static char rcsid[] = "$OpenBSD: move.c,v 1.2 1998/08/19 07:41:50 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include <math.h>
+#include "trek.h"
/*
** Move Under Warp or Impulse Power
@@ -78,15 +81,16 @@ static char rcsid[] = "$NetBSD: move.c,v 1.3 1995/04/22 10:59:12 cgd Exp $";
** Uses trace flag 4.
*/
-double move(ramflag, course, time, speed)
-int ramflag;
-int course;
-double time;
-double speed;
+double
+move(ramflag, course, time, speed)
+ int ramflag;
+ int course;
+ double time;
+ double speed;
{
double angle;
double x, y, dx, dy;
- register int ix, iy;
+ register int ix = 0, iy = 0;
double bigger;
int n;
register int i;
@@ -122,7 +126,7 @@ double speed;
evtime = Now.eventptr[E_LRTB]->date - Now.date;
# ifdef xTRACE
if (Trace)
- printf("E.ep = %u, ->evcode = %d, ->date = %.2f, evtime = %.2f\n",
+ printf("E.ep = %p, ->evcode = %d, ->date = %.2f, evtime = %.2f\n",
Now.eventptr[E_LRTB], Now.eventptr[E_LRTB]->evcode,
Now.eventptr[E_LRTB]->date, evtime);
# endif
@@ -184,12 +188,12 @@ double speed;
Ship.sectx = ix % NSECTS;
Ship.secty = iy % NSECTS;
if (ix < 0 || Ship.quadx >= NQUADS || iy < 0 || Ship.quady >= NQUADS)
+ {
if (!damaged(COMPUTER))
- {
dumpme(0);
- }
else
lose(L_NEGENB);
+ }
initquad(0);
n = 0;
break;
diff --git a/games/trek/nova.c b/games/trek/nova.c
index 7c02a70eb4b..1def930561e 100644
--- a/games/trek/nova.c
+++ b/games/trek/nova.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: nova.c,v 1.2 1998/08/19 07:41:51 pjanzen Exp $ */
/* $NetBSD: nova.c,v 1.3 1995/04/22 10:59:14 cgd Exp $ */
/*
@@ -37,11 +38,12 @@
#if 0
static char sccsid[] = "@(#)nova.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: nova.c,v 1.3 1995/04/22 10:59:14 cgd Exp $";
+static char rcsid[] = "$OpenBSD: nova.c,v 1.2 1998/08/19 07:41:51 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include "trek.h"
/*
** CAUSE A NOVA TO OCCUR
@@ -57,8 +59,9 @@ static char rcsid[] = "$NetBSD: nova.c,v 1.3 1995/04/22 10:59:14 cgd Exp $";
** If the zap is too much, it gets destroyed.
*/
+void
nova(x, y)
-int x, y;
+ int x, y;
{
register int i, j;
register int se;
@@ -71,7 +74,10 @@ int x, y;
return;
}
if (ranf(100) < 5)
- return (snova(x, y));
+ {
+ snova(x, y);
+ return;
+ }
printf("Spock: Star at %d,%d gone nova\n", x, y);
if (ranf(4) != 0)
@@ -120,6 +126,7 @@ int x, y;
case QUEENE:
se = 2000;
if (Ship.shldup)
+ {
if (Ship.shield >= se)
{
Ship.shield -= se;
@@ -130,6 +137,7 @@ int x, y;
se -= Ship.shield;
Ship.shield = 0;
}
+ }
Ship.energy -= se;
if (Ship.energy <= 0)
lose(L_SUICID);
@@ -143,5 +151,4 @@ int x, y;
}
}
}
- return;
}
diff --git a/games/trek/out.c b/games/trek/out.c
index ccd78cbb282..b14bb0374e5 100644
--- a/games/trek/out.c
+++ b/games/trek/out.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: out.c,v 1.2 1998/08/19 07:41:52 pjanzen Exp $ */
/* $NetBSD: out.c,v 1.3 1995/04/22 10:59:16 cgd Exp $ */
/*
@@ -37,24 +38,26 @@
#if 0
static char sccsid[] = "@(#)out.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: out.c,v 1.3 1995/04/22 10:59:16 cgd Exp $";
+static char rcsid[] = "$OpenBSD: out.c,v 1.2 1998/08/19 07:41:52 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include "trek.h"
/*
** Announce Device Out
*/
+void
out(dev)
-int dev;
+ int dev;
{
register struct device *d;
d = &Device[dev];
printf("%s reports %s ", d->person, d->name);
- if (d->name[length(d->name) - 1] == 's')
+ if (d->name[strlen(d->name) - 1] == 's')
printf("are");
else
printf("is");
diff --git a/games/trek/phaser.c b/games/trek/phaser.c
index 24b713a33da..e10b28661ef 100644
--- a/games/trek/phaser.c
+++ b/games/trek/phaser.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: phaser.c,v 1.2 1998/08/19 07:41:54 pjanzen Exp $ */
/* $NetBSD: phaser.c,v 1.4 1995/04/24 12:26:02 cgd Exp $ */
/*
@@ -37,12 +38,14 @@
#if 0
static char sccsid[] = "@(#)phaser.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: phaser.c,v 1.4 1995/04/24 12:26:02 cgd Exp $";
+static char rcsid[] = "$OpenBSD: phaser.c,v 1.2 1998/08/19 07:41:54 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
-# include "getpar.h"
+#include <stdio.h>
+#include <math.h>
+#include "trek.h"
+#include "getpar.h"
/* factors for phaser hits; see description below */
@@ -79,9 +82,9 @@ static char rcsid[] = "$NetBSD: phaser.c,v 1.4 1995/04/24 12:26:02 cgd Exp $";
struct cvntab Matab[] =
{
- "m", "anual", (int (*)())1, 0,
- "a", "utomatic", 0, 0,
- 0
+ { "m", "anual", (cmdfun)1, 0 },
+ { "a", "utomatic", (cmdfun)0, 0 },
+ { NULL, NULL, NULL, 0 }
};
struct banks
@@ -92,8 +95,9 @@ struct banks
};
-
-phaser()
+void
+phaser(v)
+ int v;
{
register int i;
int j;
@@ -110,11 +114,20 @@ phaser()
struct cvntab *ptr;
if (Ship.cond == DOCKED)
- return(printf("Phasers cannot fire through starbase shields\n"));
+ {
+ printf("Phasers cannot fire through starbase shields\n");
+ return;
+ }
if (damaged(PHASER))
- return (out(PHASER));
+ {
+ out(PHASER);
+ return;
+ }
if (Ship.shldup)
- return (printf("Sulu: Captain, we cannot fire through shields.\n"));
+ {
+ printf("Sulu: Captain, we cannot fire through shields.\n");
+ return;
+ }
if (Ship.cloaked)
{
printf("Sulu: Captain, surely you must realize that we cannot fire\n");
@@ -199,7 +212,10 @@ phaser()
{
/* automatic distribution of power */
if (Etc.nkling <= 0)
- return (printf("Sulu: But there are no Klingons in this quadrant\n"));
+ {
+ printf("Sulu: But there are no Klingons in this quadrant\n");
+ return;
+ }
printf("Phasers locked on target. ");
while (flag)
{
diff --git a/games/trek/play.c b/games/trek/play.c
index c2815437e61..4996d495a78 100644
--- a/games/trek/play.c
+++ b/games/trek/play.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: play.c,v 1.2 1998/08/19 07:41:55 pjanzen Exp $ */
/* $NetBSD: play.c,v 1.3 1995/04/22 10:59:18 cgd Exp $ */
/*
@@ -37,13 +38,14 @@
#if 0
static char sccsid[] = "@(#)play.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: play.c,v 1.3 1995/04/22 10:59:18 cgd Exp $";
+static char rcsid[] = "$OpenBSD: play.c,v 1.2 1998/08/19 07:41:55 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
-# include "getpar.h"
-# include <setjmp.h>
+#include <stdio.h>
+#include <setjmp.h>
+#include "trek.h"
+#include "getpar.h"
/*
** INSTRUCTION READ AND MAIN PLAY LOOP
@@ -55,46 +57,45 @@ static char rcsid[] = "$NetBSD: play.c,v 1.3 1995/04/22 10:59:18 cgd Exp $";
** attack if the move was not free, and checkcond() to check up
** on how we are doing after the move.
*/
-extern int abandon(), capture(), shield(), computer(), dcrept(),
- destruct(), dock(), help(), impulse(), lrscan(),
- warp(), dumpgame(), rest(), srscan(),
- myreset(), torped(), visual(), setwarp(), undock(), phaser();
struct cvntab Comtab[] =
{
- "abandon", "", abandon, 0,
- "ca", "pture", capture, 0,
- "cl", "oak", shield, -1,
- "c", "omputer", computer, 0,
- "da", "mages", dcrept, 0,
- "destruct", "", destruct, 0,
- "do", "ck", dock, 0,
- "help", "", help, 0,
- "i", "mpulse", impulse, 0,
- "l", "rscan", lrscan, 0,
- "m", "ove", warp, 0,
- "p", "hasers", phaser, 0,
- "ram", "", warp, 1,
- "dump", "", dumpgame, 0,
- "r", "est", rest, 0,
- "sh", "ield", shield, 0,
- "s", "rscan", srscan, 0,
- "st", "atus", srscan, -1,
- "terminate", "", myreset, 0,
- "t", "orpedo", torped, 0,
- "u", "ndock", undock, 0,
- "v", "isual", visual, 0,
- "w", "arp", setwarp, 0,
- 0
+ { "abandon", "", abandon, 0 },
+ { "ca", "pture", capture, 0 },
+ { "cl", "oak", shield, -1 },
+ { "c", "omputer", computer, 0 },
+ { "da", "mages", dcrept, 0 },
+ { "destruct", "", destruct, 0 },
+ { "do", "ck", dock, 0 },
+ { "help", "", help, 0 },
+ { "i", "mpulse", impulse, 0 },
+ { "l", "rscan", lrscan, 0 },
+ { "m", "ove", dowarp, 0 },
+ { "p", "hasers", phaser, 0 },
+ { "ram", "", dowarp, 1 },
+ { "dump", "", dumpgame, 0 },
+ { "r", "est", rest, 0 },
+ { "sh", "ield", shield, 0 },
+ { "s", "rscan", srscan, 0 },
+ { "st", "atus", srscan, -1 },
+ { "terminate", "", myreset, 0 },
+ { "t", "orpedo", torped, 0 },
+ { "u", "ndock", undock, 0 },
+ { "v", "isual", visual, 0 },
+ { "w", "arp", setwarp, 0 },
+ { NULL, NULL, NULL, 0 }
};
-myreset()
+void
+myreset(v)
+ int v;
{
extern jmp_buf env;
longjmp(env, 1);
}
+void
play()
{
struct cvntab *r;
diff --git a/games/trek/ram.c b/games/trek/ram.c
index 9d28e444565..9f24fe75708 100644
--- a/games/trek/ram.c
+++ b/games/trek/ram.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: ram.c,v 1.2 1998/08/19 07:41:56 pjanzen Exp $ */
/* $NetBSD: ram.c,v 1.3 1995/04/22 10:59:19 cgd Exp $ */
/*
@@ -37,11 +38,13 @@
#if 0
static char sccsid[] = "@(#)ram.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: ram.c,v 1.3 1995/04/22 10:59:19 cgd Exp $";
+static char rcsid[] = "$OpenBSD: ram.c,v 1.2 1998/08/19 07:41:56 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include <unistd.h>
+#include "trek.h"
/*
** RAM SOME OBJECT
@@ -54,8 +57,9 @@ static char rcsid[] = "$NetBSD: ram.c,v 1.3 1995/04/22 10:59:19 cgd Exp $";
** also rack up incredible damages.
*/
+void
ram(ix, iy)
-int ix, iy;
+ int ix, iy;
{
register int i;
register char c;
diff --git a/games/trek/ranf.c b/games/trek/ranf.c
index 2229ca594e0..89a4d18bc3f 100644
--- a/games/trek/ranf.c
+++ b/games/trek/ranf.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: ranf.c,v 1.2 1998/08/19 07:41:58 pjanzen Exp $ */
/* $NetBSD: ranf.c,v 1.3 1995/04/22 10:59:21 cgd Exp $ */
/*
@@ -37,27 +38,30 @@
#if 0
static char sccsid[] = "@(#)ranf.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: ranf.c,v 1.3 1995/04/22 10:59:21 cgd Exp $";
+static char rcsid[] = "$OpenBSD: ranf.c,v 1.2 1998/08/19 07:41:58 pjanzen Exp $";
#endif
#endif /* not lint */
-# include <stdio.h>
+#include <stdio.h>
+#include <stdlib.h>
+int
ranf(max)
-int max;
+ int max;
{
register int t;
if (max <= 0)
return (0);
- t = rand() >> 5;
+ t = random() >> 5;
return (t % max);
}
-double franf()
+double
+franf()
{
double t;
- t = rand() & 077777;
+ t = random() & 077777;
return (t / 32767.0);
}
diff --git a/games/trek/rest.c b/games/trek/rest.c
index 6575a325f6a..65837866283 100644
--- a/games/trek/rest.c
+++ b/games/trek/rest.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: rest.c,v 1.2 1998/08/19 07:41:59 pjanzen Exp $ */
/* $NetBSD: rest.c,v 1.3 1995/04/22 10:59:22 cgd Exp $ */
/*
@@ -37,12 +38,13 @@
#if 0
static char sccsid[] = "@(#)rest.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: rest.c,v 1.3 1995/04/22 10:59:22 cgd Exp $";
+static char rcsid[] = "$OpenBSD: rest.c,v 1.2 1998/08/19 07:41:59 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
-# include "getpar.h"
+#include <stdio.h>
+#include "trek.h"
+#include "getpar.h"
/*
** REST FOR REPAIRS
@@ -58,7 +60,9 @@ static char rcsid[] = "$NetBSD: rest.c,v 1.3 1995/04/22 10:59:22 cgd Exp $";
** rest period if anything momentous happens.
*/
-rest()
+void
+rest(v)
+ int v;
{
double t;
register int percent;
diff --git a/games/trek/schedule.c b/games/trek/schedule.c
index 41b20628b6d..a0d26da1a3b 100644
--- a/games/trek/schedule.c
+++ b/games/trek/schedule.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: schedule.c,v 1.2 1998/08/19 07:42:01 pjanzen Exp $ */
/* $NetBSD: schedule.c,v 1.3 1995/04/22 10:59:23 cgd Exp $ */
/*
@@ -37,11 +38,14 @@
#if 0
static char sccsid[] = "@(#)schedule.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: schedule.c,v 1.3 1995/04/22 10:59:23 cgd Exp $";
+static char rcsid[] = "$OpenBSD: schedule.c,v 1.2 1998/08/19 07:42:01 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include <math.h>
+#include <err.h>
+#include "trek.h"
/*
** SCHEDULE AN EVENT
@@ -53,11 +57,12 @@ static char rcsid[] = "$NetBSD: schedule.c,v 1.3 1995/04/22 10:59:23 cgd Exp $";
** The address of the slot is returned.
*/
-struct event *schedule(type, offset, x, y, z)
-int type;
-double offset;
-char x, y;
-char z;
+struct event *
+schedule(type, offset, x, y, z)
+ int type;
+ double offset;
+ char x, y;
+ char z;
{
register struct event *e;
register int i;
@@ -83,7 +88,7 @@ char z;
Now.eventptr[type] = e;
return (e);
}
- syserr("Cannot schedule event %d parm %d %d %d", type, x, y, z);
+ errx(1, "Cannot schedule event %d parm %d %d %d", type, x, y, z);
}
@@ -94,9 +99,10 @@ char z;
** time plus 'offset'.
*/
+void
reschedule(e1, offset)
-struct event *e1;
-double offset;
+ struct event *e1;
+ double offset;
{
double date;
register struct event *e;
@@ -120,8 +126,9 @@ double offset;
** The event at slot 'e' is deleted.
*/
+void
unschedule(e1)
-struct event *e1;
+ struct event *e1;
{
register struct event *e;
@@ -146,10 +153,11 @@ struct event *e1;
** figure.
*/
-struct event *xsched(ev1, factor, x, y, z)
-int ev1;
-int factor;
-int x, y, z;
+struct event *
+xsched(ev1, factor, x, y, z)
+ int ev1;
+ int factor;
+ int x, y, z;
{
register int ev;
@@ -165,10 +173,11 @@ int x, y, z;
** division factor. Look at the code to see what really happens.
*/
+void
xresched(e1, ev1, factor)
-struct event *e1;
-int ev1;
-int factor;
+ struct event *e1;
+ int ev1;
+ int factor;
{
register int ev;
register struct event *e;
diff --git a/games/trek/score.c b/games/trek/score.c
index f19f94a249a..797fc023b1b 100644
--- a/games/trek/score.c
+++ b/games/trek/score.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: score.c,v 1.2 1998/08/19 07:42:02 pjanzen Exp $ */
/* $NetBSD: score.c,v 1.3 1995/04/22 10:59:24 cgd Exp $ */
/*
@@ -37,24 +38,25 @@
#if 0
static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: score.c,v 1.3 1995/04/22 10:59:24 cgd Exp $";
+static char rcsid[] = "$OpenBSD: score.c,v 1.2 1998/08/19 07:42:02 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
-# include "getpar.h"
+#include <stdio.h>
+#include "trek.h"
+#include "getpar.h"
/*
** PRINT OUT THE CURRENT SCORE
*/
-long score()
+long
+score()
{
- register int u;
- register int t;
- long s;
- double r;
- extern struct cvntab Skitab[];
+ register int u;
+ register int t;
+ long s;
+ double r;
printf("\n*** Your score:\n");
s = t = Param.klingpwr / 4 * (u = Game.killk);
diff --git a/games/trek/setup.c b/games/trek/setup.c
index ce75202685c..9da38ac9396 100644
--- a/games/trek/setup.c
+++ b/games/trek/setup.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: setup.c,v 1.2 1998/08/19 07:42:03 pjanzen Exp $ */
/* $NetBSD: setup.c,v 1.4 1995/04/24 12:26:06 cgd Exp $ */
/*
@@ -37,12 +38,17 @@
#if 0
static char sccsid[] = "@(#)setup.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: setup.c,v 1.4 1995/04/24 12:26:06 cgd Exp $";
+static char rcsid[] = "$OpenBSD: setup.c,v 1.2 1998/08/19 07:42:03 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
-# include "getpar.h"
+#include <stdio.h>
+#include <math.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <err.h>
+#include "trek.h"
+#include "getpar.h"
/*
** INITIALIZE THE GAME
@@ -57,31 +63,31 @@ static char rcsid[] = "$NetBSD: setup.c,v 1.4 1995/04/24 12:26:06 cgd Exp $";
struct cvntab Lentab[] =
{
- "s", "hort", (int (*)())1, 0,
- "m", "edium", (int (*)())2, 0,
- "l", "ong", (int (*)())4, 0,
- "restart", "", 0, 0,
- 0
+ { "s", "hort", (cmdfun)1, 0 },
+ { "m", "edium", (cmdfun)2, 0 },
+ { "l", "ong", (cmdfun)4, 0 },
+ { "restart", "", (cmdfun)0, 0 },
+ { NULL, NULL, NULL, 0 }
};
struct cvntab Skitab[] =
{
- "n", "ovice", (int (*)())1, 0,
- "f", "air", (int (*)())2, 0,
- "g", "ood", (int (*)())3, 0,
- "e", "xpert", (int (*)())4, 0,
- "c", "ommodore", (int (*)())5, 0,
- "i", "mpossible", (int (*)())6, 0,
- 0
+ { "n", "ovice", (cmdfun)1, 0 },
+ { "f", "air", (cmdfun)2, 0 },
+ { "g", "ood", (cmdfun)3, 0 },
+ { "e", "xpert", (cmdfun)4, 0 },
+ { "c", "ommodore", (cmdfun)5, 0 },
+ { "i", "mpossible", (cmdfun)6, 0 },
+ { NULL, NULL, NULL, 0 }
};
+void
setup()
{
struct cvntab *r;
register int i, j;
double f;
int d;
- int fd;
int klump;
int ix, iy;
register struct quad *q;
@@ -103,7 +109,7 @@ setup()
Game.skill = (long) r->value;
Game.tourn = 0;
getstrpar("Enter a password", Game.passwd, 14, 0);
- if (sequal(Game.passwd, "tournament"))
+ if (strcmp(Game.passwd, "tournament") == 0)
{
getstrpar("Enter tournament code", Game.passwd, 14, 0);
Game.tourn = 1;
@@ -165,7 +171,7 @@ setup()
for (i = j = 0; i < NDEV; i++)
j += Param.damprob[i];
if (j != 1000)
- syserr("Device probabilities sum to %d", j);
+ errx(1, "Device probabilities sum to %d", j);
Param.dockfac = 0.5;
Param.regenfac = (5 - Game.skill) * 0.05;
if (Param.regenfac < 0.0)
diff --git a/games/trek/setwarp.c b/games/trek/setwarp.c
index 74939ae6cc2..f6dfa685182 100644
--- a/games/trek/setwarp.c
+++ b/games/trek/setwarp.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: setwarp.c,v 1.2 1998/08/19 07:42:05 pjanzen Exp $ */
/* $NetBSD: setwarp.c,v 1.3 1995/04/22 10:59:27 cgd Exp $ */
/*
@@ -37,12 +38,13 @@
#if 0
static char sccsid[] = "@(#)setwarp.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: setwarp.c,v 1.3 1995/04/22 10:59:27 cgd Exp $";
+static char rcsid[] = "$OpenBSD: setwarp.c,v 1.2 1998/08/19 07:42:05 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
-# include "getpar.h"
+#include <stdio.h>
+#include "trek.h"
+#include "getpar.h"
/*
** SET WARP FACTOR
@@ -51,7 +53,9 @@ static char rcsid[] = "$NetBSD: setwarp.c,v 1.3 1995/04/22 10:59:27 cgd Exp $";
** checked for consistancy.
*/
-setwarp()
+void
+setwarp(v)
+ int v;
{
double warpfac;
@@ -59,9 +63,15 @@ setwarp()
if (warpfac < 0.0)
return;
if (warpfac < 1.0)
- return (printf("Minimum warp speed is 1.0\n"));
+ {
+ printf("Minimum warp speed is 1.0\n");
+ return;
+ }
if (warpfac > 10.0)
- return (printf("Maximum speed is warp 10.0\n"));
+ {
+ printf("Maximum speed is warp 10.0\n");
+ return;
+ }
if (warpfac > 6.0)
printf("Damage to warp engines may occur above warp 6.0\n");
Ship.warp = warpfac;
diff --git a/games/trek/shield.c b/games/trek/shield.c
index a2345dc1d93..bf546858aff 100644
--- a/games/trek/shield.c
+++ b/games/trek/shield.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: shield.c,v 1.2 1998/08/19 07:42:06 pjanzen Exp $ */
/* $NetBSD: shield.c,v 1.4 1995/04/24 12:26:09 cgd Exp $ */
/*
@@ -37,12 +38,13 @@
#if 0
static char sccsid[] = "@(#)shield.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: shield.c,v 1.4 1995/04/24 12:26:09 cgd Exp $";
+static char rcsid[] = "$OpenBSD: shield.c,v 1.2 1998/08/19 07:42:06 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
-# include "getpar.h"
+#include <stdio.h>
+#include "trek.h"
+#include "getpar.h"
/*
** SHIELD AND CLOAKING DEVICE CONTROL
@@ -63,21 +65,21 @@ static char rcsid[] = "$NetBSD: shield.c,v 1.4 1995/04/24 12:26:09 cgd Exp $";
struct cvntab Udtab[] =
{
- "u", "p", (int (*)())1, 0,
- "d", "own", 0, 0,
- 0
+ { "u", "p", (cmdfun)1, 0 },
+ { "d", "own", (cmdfun)0, 0 },
+ { NULL, NULL, NULL, 0 }
};
+void
shield(f)
-int f;
+ int f;
{
- register int i;
- char c;
- struct cvntab *r;
- char s[100];
- char *device, *dev2, *dev3;
- int ind;
- char *stat;
+ register int i;
+ struct cvntab *r;
+ char s[100];
+ char *device, *dev2, *dev3;
+ int ind;
+ char *stat;
if (f > 0 && (Ship.shldup || damaged(SRSCAN)))
return;
@@ -85,7 +87,10 @@ int f;
{
/* cloaking device */
if (Ship.ship == QUEENE)
- return (printf("Ye Faire Queene does not have the cloaking device.\n"));
+ {
+ printf("Ye Faire Queene does not have the cloaking device.\n");
+ return;
+ }
device = "Cloaking device";
dev2 = "is";
ind = CLOAK;
@@ -137,13 +142,14 @@ int f;
return;
}
if (i)
+ {
if (f >= 0)
Ship.energy -= Param.shupengy;
else
Ship.cloakgood = 0;
+ }
Move.free = 0;
if (f >= 0)
Move.shldchg = 1;
*stat = i;
- return;
}
diff --git a/games/trek/snova.c b/games/trek/snova.c
index 8ab14646752..283cbf5d94e 100644
--- a/games/trek/snova.c
+++ b/games/trek/snova.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: snova.c,v 1.2 1998/08/19 07:42:07 pjanzen Exp $ */
/* $NetBSD: snova.c,v 1.3 1995/04/22 10:59:29 cgd Exp $ */
/*
@@ -37,11 +38,13 @@
#if 0
static char sccsid[] = "@(#)snova.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: snova.c,v 1.3 1995/04/22 10:59:29 cgd Exp $";
+static char rcsid[] = "$OpenBSD: snova.c,v 1.2 1998/08/19 07:42:07 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include <unistd.h>
+#include "trek.h"
/*
** CAUSE SUPERNOVA TO OCCUR
@@ -64,11 +67,12 @@ static char rcsid[] = "$NetBSD: snova.c,v 1.3 1995/04/22 10:59:29 cgd Exp $";
** override mode.
*/
+void
snova(x, y)
-int x, y;
+ int x, y;
{
int qx, qy;
- register int ix, iy;
+ register int ix, iy = 0;
int f;
int dx, dy;
int n;
@@ -146,12 +150,12 @@ int x, y;
/* Enterprise caused supernova */
Game.kills += dy;
if (q->bases)
- killb(qx, qy, -1);
+ killb(qx, qy);
Game.killk += dx;
}
else
if (q->bases)
- killb(qx, qy, 0);
+ killb(qx, qy);
killd(qx, qy, (x >= 0));
q->stars = -1;
q->klings = 0;
@@ -160,5 +164,4 @@ int x, y;
printf("Lucky devil, that supernova destroyed the last klingon\n");
win();
}
- return;
}
diff --git a/games/trek/srscan.c b/games/trek/srscan.c
index 6c287262757..2d02b00de47 100644
--- a/games/trek/srscan.c
+++ b/games/trek/srscan.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: srscan.c,v 1.2 1998/08/19 07:42:08 pjanzen Exp $ */
/* $NetBSD: srscan.c,v 1.3 1995/04/22 10:59:31 cgd Exp $ */
/*
@@ -37,12 +38,13 @@
#if 0
static char sccsid[] = "@(#)srscan.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: srscan.c,v 1.3 1995/04/22 10:59:31 cgd Exp $";
+static char rcsid[] = "$OpenBSD: srscan.c,v 1.2 1998/08/19 07:42:08 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
-# include "getpar.h"
+#include <stdio.h>
+#include "trek.h"
+#include "getpar.h"
/*
** SHORT RANGE SENSOR SCAN
@@ -67,22 +69,19 @@ char *Color[4] =
"RED"
};
+void
srscan(f)
-int f;
+ int f;
{
- register int i, j;
- register int statinfo;
- char *s;
- int percent;
- struct quad *q;
- extern struct cvntab Skitab[];
- extern struct cvntab Lentab[];
- struct cvntab *p;
+ register int i, j;
+ register int statinfo;
+ char *s;
+ int percent;
+ struct quad *q = NULL;
+ struct cvntab *p;
if (f >= 0 && check_out(SRSCAN))
- {
return;
- }
if (f)
statinfo = 1;
else
diff --git a/games/trek/systemname.c b/games/trek/systemname.c
index cb4efa49a85..a46b9c3bcca 100644
--- a/games/trek/systemname.c
+++ b/games/trek/systemname.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: systemname.c,v 1.2 1998/08/19 07:42:10 pjanzen Exp $ */
/* $NetBSD: systemname.c,v 1.3 1995/04/22 10:59:32 cgd Exp $ */
/*
@@ -37,11 +38,11 @@
#if 0
static char sccsid[] = "@(#)systemname.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: systemname.c,v 1.3 1995/04/22 10:59:32 cgd Exp $";
+static char rcsid[] = "$OpenBSD: systemname.c,v 1.2 1998/08/19 07:42:10 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include "trek.h"
/*
** RETRIEVE THE STARSYSTEM NAME
diff --git a/games/trek/torped.c b/games/trek/torped.c
index dd11fe223e5..7eec2a78001 100644
--- a/games/trek/torped.c
+++ b/games/trek/torped.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: torped.c,v 1.2 1998/08/19 07:42:11 pjanzen Exp $ */
/* $NetBSD: torped.c,v 1.3 1995/04/22 10:59:34 cgd Exp $ */
/*
@@ -37,12 +38,16 @@
#if 0
static char sccsid[] = "@(#)torped.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: torped.c,v 1.3 1995/04/22 10:59:34 cgd Exp $";
+static char rcsid[] = "$OpenBSD: torped.c,v 1.2 1998/08/19 07:42:11 pjanzen Exp $";
#endif
#endif /* not lint */
-# include <stdio.h>
-# include "trek.h"
+#include <stdio.h>
+#include <math.h>
+#include "trek.h"
+#include "getpar.h"
+
+static int randcourse __P((int));
/*
** PHOTON TORPEDO CONTROL
@@ -63,28 +68,31 @@ static char rcsid[] = "$NetBSD: torped.c,v 1.3 1995/04/22 10:59:34 cgd Exp $";
** the misfire damages your torpedo tubes.
*/
-
-torped()
+void
+torped(v)
+ int v;
{
- register int ix, iy;
- double x, y, dx, dy;
- double angle;
- int course, course2;
- register int k;
- double bigger;
- double sectsize;
- int burst;
- int n;
+ register int ix, iy;
+ double x, y, dx, dy;
+ double angle;
+ int course, course2;
+ register int k;
+ double bigger;
+ double sectsize;
+ int burst;
+ int n;
if (Ship.cloaked)
{
- return (printf("Federation regulations do not permit attack while cloaked.\n"));
+ printf("Federation regulations do not permit attack while cloaked.\n");
+ return;
}
if (check_out(TORPED))
return;
if (Ship.torped <= 0)
{
- return (printf("All photon torpedos expended\n"));
+ printf("All photon torpedos expended\n");
+ return;
}
/* get the course */
@@ -119,7 +127,10 @@ torped()
if (burst <= 0)
return;
if (burst > 15)
- return (printf("Maximum burst angle is 15 degrees\n"));
+ {
+ printf("Maximum burst angle is 15 degrees\n");
+ return;
+ }
}
sectsize = NSECTS;
n = -1;
@@ -221,8 +232,9 @@ torped()
** to the tubes, etc.
*/
+static int
randcourse(n)
-int n;
+ int n;
{
double r;
register int d;
diff --git a/games/trek/trek.h b/games/trek/trek.h
index 94dcac1bec9..08f9bea1067 100644
--- a/games/trek/trek.h
+++ b/games/trek/trek.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: trek.h,v 1.3 1998/08/19 07:42:12 pjanzen Exp $ */
/* $NetBSD: trek.h,v 1.3 1995/04/22 10:59:36 cgd Exp $ */
/*
@@ -35,6 +36,8 @@
* @(#)trek.h 8.1 (Berkeley) 5/31/93
*/
+#include <sys/cdefs.h>
+
/*
** Global Declarations
**
@@ -53,26 +56,16 @@
** actually allocate stuff in "externs.c"
*/
-/* external function definitions */
-extern double franf(); /* floating random number function */
-extern double sqrt(); /* square root */
-extern double sin(), cos(); /* trig functions */
-extern double atan2(); /* fancy arc tangent function */
-extern double log(); /* log base e */
-extern double pow(); /* power function */
-extern double fabs(); /* absolute value function */
-extern double exp(); /* exponential function */
-
/********************* GALAXY **************************/
/* galactic parameters */
-# define NSECTS 10 /* dimensions of quadrant in sectors */
-# define NQUADS 8 /* dimension of galazy in quadrants */
-# define NINHAB 32 /* number of quadrants which are inhabited */
+#define NSECTS 10 /* dimensions of quadrant in sectors */
+#define NQUADS 8 /* dimension of galazy in quadrants */
+#define NINHAB 32 /* number of quadrants which are inhabited */
struct quad /* definition for each quadrant */
{
- char bases; /* number of bases in this quadrant */
+ unsigned char bases; /* number of bases in this quadrant */
char klings; /* number of Klingons in this quadrant */
char holes; /* number of black holes in this quadrant */
int scanned; /* star chart entry (see below) */
@@ -80,8 +73,8 @@ struct quad /* definition for each quadrant */
char qsystemname; /* starsystem name (see below) */
};
-# define Q_DISTRESSED 0200
-# define Q_SYSTEM 077
+#define Q_DISTRESSED 0200
+#define Q_SYSTEM 077
/* systemname conventions:
* 1 -> NINHAB index into Systemname table for live system.
@@ -104,14 +97,14 @@ extern char *Systemname[NINHAB];
struct quad Quad[NQUADS][NQUADS];
/* defines for sector map (below) */
-# define EMPTY '.'
-# define STAR '*'
-# define BASE '#'
-# define ENTERPRISE 'E'
-# define QUEENE 'Q'
-# define KLINGON 'K'
-# define INHABIT '@'
-# define HOLE ' '
+#define EMPTY '.'
+#define STAR '*'
+#define BASE '#'
+#define ENTERPRISE 'E'
+#define QUEENE 'Q'
+#define KLINGON 'K'
+#define INHABIT '@'
+#define HOLE ' '
/* current sector map */
char Sect[NSECTS][NSECTS];
@@ -119,23 +112,23 @@ char Sect[NSECTS][NSECTS];
/************************ DEVICES ******************************/
-# define NDEV 16 /* max number of devices */
+#define NDEV 16 /* max number of devices */
/* device tokens */
-# define WARP 0 /* warp engines */
-# define SRSCAN 1 /* short range scanners */
-# define LRSCAN 2 /* long range scanners */
-# define PHASER 3 /* phaser control */
-# define TORPED 4 /* photon torpedo control */
-# define IMPULSE 5 /* impulse engines */
-# define SHIELD 6 /* shield control */
-# define COMPUTER 7 /* on board computer */
-# define SSRADIO 8 /* subspace radio */
-# define LIFESUP 9 /* life support systems */
-# define SINS 10 /* Space Inertial Navigation System */
-# define CLOAK 11 /* cloaking device */
-# define XPORTER 12 /* transporter */
-# define SHUTTLE 13 /* shuttlecraft */
+#define WARP 0 /* warp engines */
+#define SRSCAN 1 /* short range scanners */
+#define LRSCAN 2 /* long range scanners */
+#define PHASER 3 /* phaser control */
+#define TORPED 4 /* photon torpedo control */
+#define IMPULSE 5 /* impulse engines */
+#define SHIELD 6 /* shield control */
+#define COMPUTER 7 /* on board computer */
+#define SSRADIO 8 /* subspace radio */
+#define LIFESUP 9 /* life support systems */
+#define SINS 10 /* Space Inertial Navigation System */
+#define CLOAK 11 /* cloaking device */
+#define XPORTER 12 /* transporter */
+#define SHUTTLE 13 /* shuttlecraft */
/* device names */
struct device
@@ -148,29 +141,29 @@ struct device Device[NDEV];
/*************************** EVENTS ****************************/
-# define NEVENTS 12 /* number of different event types */
+#define NEVENTS 12 /* number of different event types */
-# define E_LRTB 1 /* long range tractor beam */
-# define E_KATSB 2 /* Klingon attacks starbase */
-# define E_KDESB 3 /* Klingon destroys starbase */
-# define E_ISSUE 4 /* distress call is issued */
-# define E_ENSLV 5 /* Klingons enslave a quadrant */
-# define E_REPRO 6 /* a Klingon is reproduced */
-# define E_FIXDV 7 /* fix a device */
-# define E_ATTACK 8 /* Klingon attack during rest period */
-# define E_SNAP 9 /* take a snapshot for time warp */
-# define E_SNOVA 10 /* supernova occurs */
+#define E_LRTB 1 /* long range tractor beam */
+#define E_KATSB 2 /* Klingon attacks starbase */
+#define E_KDESB 3 /* Klingon destroys starbase */
+#define E_ISSUE 4 /* distress call is issued */
+#define E_ENSLV 5 /* Klingons enslave a quadrant */
+#define E_REPRO 6 /* a Klingon is reproduced */
+#define E_FIXDV 7 /* fix a device */
+#define E_ATTACK 8 /* Klingon attack during rest period */
+#define E_SNAP 9 /* take a snapshot for time warp */
+#define E_SNOVA 10 /* supernova occurs */
-# define E_GHOST 0100 /* ghost of a distress call if ssradio out */
-# define E_HIDDEN 0200 /* event that is unreportable because ssradio out */
-# define E_EVENT 077 /* mask to get event code */
+#define E_GHOST 0100 /* ghost of a distress call if ssradio out */
+#define E_HIDDEN 0200 /* event that is unreportable because ssradio out */
+#define E_EVENT 077 /* mask to get event code */
struct event
{
- char x, y; /* coordinates */
- double date; /* trap stardate */
- char evcode; /* event type */
- char systemname; /* starsystem name */
+ unsigned char x, y; /* coordinates */
+ double date; /* trap stardate */
+ char evcode; /* event type */
+ unsigned char systemname; /* starsystem name */
};
/* systemname conventions:
* 1 -> NINHAB index into Systemname table for reported distress calls
@@ -182,7 +175,7 @@ struct event
* 0 unallocated
*/
-# define MAXEVENTS 25 /* max number of concurrently pending events */
+#define MAXEVENTS 25 /* max number of concurrently pending events */
struct event Event[MAXEVENTS]; /* dynamic event list; one entry per pending event */
@@ -190,38 +183,41 @@ struct event Event[MAXEVENTS]; /* dynamic event list; one entry per pending even
struct kling
{
- char x, y; /* coordinates */
+ unsigned char x, y; /* coordinates */
int power; /* power left */
double dist; /* distance to Enterprise */
double avgdist; /* average over this move */
char srndreq; /* set if surrender has been requested */
};
-# define MAXKLQUAD 9 /* maximum klingons per quadrant */
+#define MAXKLQUAD 9 /* maximum klingons per quadrant */
/********************** MISCELLANEOUS ***************************/
/* condition codes */
-# define GREEN 0
-# define DOCKED 1
-# define YELLOW 2
-# define RED 3
+#define GREEN 0
+#define DOCKED 1
+#define YELLOW 2
+#define RED 3
/* starbase coordinates */
-# define MAXBASES 9 /* maximum number of starbases in galaxy */
+#define MAXBASES 9 /* maximum number of starbases in galaxy */
/* distress calls */
-# define MAXDISTR 5 /* maximum concurrent distress calls */
+#define MAXDISTR 5 /* maximum concurrent distress calls */
/* phaser banks */
-# define NBANKS 6 /* number of phaser banks */
+#define NBANKS 6 /* number of phaser banks */
struct xy
{
- char x, y; /* coordinates */
+ unsigned char x, y; /* coordinates */
};
+extern struct cvntab Skitab[];
+extern struct cvntab Lentab[];
+
/*
* note that much of the stuff in the following structs CAN NOT
* be moved around!!!!
@@ -247,7 +243,7 @@ struct
int quady; /* quadrant y coord */
int sectx; /* sector x coord */
int secty; /* sector y coord */
- char cond; /* condition code */
+ unsigned char cond; /* condition code */
char sinsbad; /* Space Inertial Navigation System condition */
char *shipname; /* name of current starship */
char ship; /* current starship */
@@ -289,7 +285,7 @@ struct
/* parametric information */
struct
{
- char bases; /* number of starbases */
+ unsigned char bases; /* number of starbases */
char klings; /* number of klingons */
double date; /* stardate */
double time; /* time left */
@@ -325,7 +321,7 @@ struct
/* other information kept in a snapshot */
struct
{
- char bases; /* number of starbases */
+ unsigned char bases; /* number of starbases */
char klings; /* number of klingons */
double date; /* stardate */
double time; /* time left */
@@ -353,30 +349,184 @@ struct
*/
/* Klingon move indicies */
-# define KM_OB 0 /* Old quadrant, Before attack */
-# define KM_OA 1 /* Old quadrant, After attack */
-# define KM_EB 2 /* Enter quadrant, Before attack */
-# define KM_EA 3 /* Enter quadrant, After attack */
-# define KM_LB 4 /* Leave quadrant, Before attack */
-# define KM_LA 5 /* Leave quadrant, After attack */
+#define KM_OB 0 /* Old quadrant, Before attack */
+#define KM_OA 1 /* Old quadrant, After attack */
+#define KM_EB 2 /* Enter quadrant, Before attack */
+#define KM_EA 3 /* Enter quadrant, After attack */
+#define KM_LB 4 /* Leave quadrant, Before attack */
+#define KM_LA 5 /* Leave quadrant, After attack */
/* you lose codes */
-# define L_NOTIME 1 /* ran out of time */
-# define L_NOENGY 2 /* ran out of energy */
-# define L_DSTRYD 3 /* destroyed by a Klingon */
-# define L_NEGENB 4 /* ran into the negative energy barrier */
-# define L_SUICID 5 /* destroyed in a nova */
-# define L_SNOVA 6 /* destroyed in a supernova */
-# define L_NOLIFE 7 /* life support died (so did you) */
-# define L_NOHELP 8 /* you could not be rematerialized */
-# define L_TOOFAST 9 /* pretty stupid going at warp 10 */
-# define L_STAR 10 /* ran into a star */
-# define L_DSTRCT 11 /* self destructed */
-# define L_CAPTURED 12 /* captured by Klingons */
-# define L_NOCREW 13 /* you ran out of crew */
+#define L_NOTIME 1 /* ran out of time */
+#define L_NOENGY 2 /* ran out of energy */
+#define L_DSTRYD 3 /* destroyed by a Klingon */
+#define L_NEGENB 4 /* ran into the negative energy barrier */
+#define L_SUICID 5 /* destroyed in a nova */
+#define L_SNOVA 6 /* destroyed in a supernova */
+#define L_NOLIFE 7 /* life support died (so did you) */
+#define L_NOHELP 8 /* you could not be rematerialized */
+#define L_TOOFAST 9 /* pretty stupid going at warp 10 */
+#define L_STAR 10 /* ran into a star */
+#define L_DSTRCT 11 /* self destructed */
+#define L_CAPTURED 12 /* captured by Klingons */
+#define L_NOCREW 13 /* you ran out of crew */
/****************** COMPILE OPTIONS ***********************/
/* Trace info */
-# define xTRACE 1
+#define xTRACE 1
int Trace;
+
+/* abandon.c */
+void abandon __P((int));
+
+/* attack.c */
+void attack __P((int));
+
+/* autover.c */
+void autover __P((void));
+
+/* capture.c */
+void capture __P((int));
+struct kling *selectklingon __P((void));
+
+/* cgetc.c */
+char cgetc __P((int));
+
+/* check_out.c */
+int check_out __P((int));
+
+/* checkcond.c */
+void checkcond __P((void));
+
+/* compkl.c */
+void compkldist __P((int));
+
+/* computer.c */
+void computer __P((int));
+
+/* damage.c */
+void damage __P((int, double));
+
+/* damaged.c */
+int damaged __P((int));
+
+/* dcrept.c */
+void dcrept __P((int));
+
+/* destruct.c */
+void destruct __P((int));
+
+/* dock.c */
+void dock __P((int));
+void undock __P((int));
+
+/* dumpgame.c */
+void dumpgame __P((int));
+int restartgame __P((void));
+
+/* dumpme.c */
+void dumpme __P((int));
+
+/* dumpssradio.c */
+int dumpssradio __P((void));
+
+/* events.c */
+int events __P((int));
+
+/* externs.c */
+
+/* getcodi.c */
+int getcodi __P((int *, double *));
+
+/* help.c */
+void help __P((int));
+
+/* impulse.c */
+void impulse __P((int));
+
+/* initquad.c */
+void initquad __P((int));
+void sector __P((int *, int *));
+
+/* kill.c */
+void killk __P((int, int ));
+void killb __P((int, int ));
+void kills __P((int, int , int));
+void killd __P((int, int , int));
+
+/* klmove.c */
+void klmove __P((int));
+
+/* lose.c */
+void lose __P((int));
+
+/* lrscan.c */
+void lrscan __P((int));
+
+/* move.c */
+double move __P((int, int, double, double));
+
+/* nova.c */
+void nova __P((int, int ));
+
+/* out.c */
+void out __P((int));
+
+/* phaser.c */
+void phaser __P((int));
+
+/* play.c */
+void myreset __P((int));
+void play __P((void));
+
+/* ram.c */
+void ram __P((int, int ));
+
+/* ranf.c */
+int ranf __P((int));
+double franf __P((void));
+
+/* rest.c */
+void rest __P((int));
+
+/* schedule.c */
+struct event *schedule __P((int, double, int, int , int));
+void reschedule __P((struct event *, double));
+void unschedule __P((struct event *));
+struct event *xsched __P((int, int, int, int , int ));
+void xresched __P((struct event *, int, int));
+
+/* score.c */
+long score __P((void));
+
+/* setup.c */
+void setup __P((void));
+
+/* setwarp.c */
+void setwarp __P((int));
+
+/* shield.c */
+void shield __P((int));
+
+/* snova.c */
+void snova __P((int, int ));
+
+/* srscan.c */
+void srscan __P((int));
+
+/* systemname.c */
+char *systemname __P((struct quad *));
+
+/* torped.c */
+void torped __P((int));
+
+/* visual.c */
+void visual __P((int));
+
+/* warp.c */
+void dowarp __P((int));
+void warp __P((int, int, double));
+
+/* win.c */
+void win __P((void));
diff --git a/games/trek/utility.c b/games/trek/utility.c
deleted file mode 100644
index cfd2f0a66ac..00000000000
--- a/games/trek/utility.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/* $NetBSD: utility.c,v 1.3 1995/04/22 10:59:37 cgd Exp $ */
-
-/*
- * Copyright (c) 1980, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)utility.c 8.1 (Berkeley) 5/31/93";
-#else
-static char rcsid[] = "$NetBSD: utility.c,v 1.3 1995/04/22 10:59:37 cgd Exp $";
-#endif
-#endif /* not lint */
-
-/*
-** ASSORTED UTILITY ROUTINES
-*/
-
-/*
-** BLOCK MOVE
-**
-** Moves a block of storage of length `l' bytes from the data
-** area pointed to by `a' to the area pointed to by `b'.
-** Returns the address of the byte following the `b' field.
-** Overflow of `b' is not tested.
-*/
-
-char *bmove(a, b, l)
-char *a, *b;
-int l;
-{
- register int n;
- register char *p, *q;
-
- p = a;
- q = b;
- n = l;
- while (n--)
- *q++ = *p++;
- return (q);
-}
-
-
-/*
-** STRING EQUALITY TEST
-** null-terminated strings `a' and `b' are tested for
-** absolute equality.
-** returns one if equal, zero otherwise.
-*/
-
-sequal(a, b)
-char *a, *b;
-{
- register char *p, *q;
-
- p = a;
- q = b;
- while (*p || *q)
- if (*p++ != *q++)
- return(0);
- return(1);
-}
-
-
-/*
-** STRING CONCATENATE
-**
-** The strings `s1' and `s2' are concatenated and stored into
-** `s3'. It is ok for `s1' to equal `s3', but terrible things
-** will happen if `s2' equals `s3'. The return value is is a
-** pointer to the end of `s3' field.
-*/
-
-char *concat(s1, s2, s3)
-char *s1, *s2, *s3;
-{
- register char *p;
- register char *q;
-
- p = s3;
- q = s1;
- while (*q)
- *p++ = *q++;
- q = s2;
- while (*q)
- *p++ = *q++;
- *p = 0;
- return (p);
-}
-
-
-/*
-** FIND STRING LENGTH
-**
-** The length of string `s' (excluding the null byte which
-** terminates the string) is returned.
-*/
-
-length(s)
-char *s;
-{
- register int l;
- register char *p;
-
- l = 0;
- p = s;
- while (*p++)
- l++;
- return(l);
-}
-
-
-/*
-** SYSTEM ERROR
-*/
-
-syserr(p0, p1, p2, p3, p4, p5)
-{
- extern int errno;
-
- printf("\n\07TREK SYSERR: ");
- printf(p0, p1, p2, p3, p4, p5);
- printf("\n");
- if (errno)
- printf("\tsystem error %d\n", errno);
- exit(-1);
-}
diff --git a/games/trek/visual.c b/games/trek/visual.c
index 9bde9220676..3a8a6797200 100644
--- a/games/trek/visual.c
+++ b/games/trek/visual.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: visual.c,v 1.2 1998/08/19 07:42:15 pjanzen Exp $ */
/* $NetBSD: visual.c,v 1.3 1995/04/22 10:59:39 cgd Exp $ */
/*
@@ -37,11 +38,13 @@
#if 0
static char sccsid[] = "@(#)visual.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: visual.c,v 1.3 1995/04/22 10:59:39 cgd Exp $";
+static char rcsid[] = "$OpenBSD: visual.c,v 1.2 1998/08/19 07:42:15 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include "trek.h"
+#include "getpar.h"
/*
** VISUAL SCAN
@@ -55,20 +58,22 @@ static char rcsid[] = "$NetBSD: visual.c,v 1.3 1995/04/22 10:59:39 cgd Exp $";
/* This struct[] has the delta x, delta y for particular directions */
struct xy Visdelta[11] =
{
- -1, -1,
- -1, 0,
- -1, 1,
- 0, 1,
- 1, 1,
- 1, 0,
- 1, -1,
- 0, -1,
- -1, -1,
- -1, 0,
- -1, 1
+ { -1, -1 },
+ { -1, 0 },
+ { -1, 1 },
+ { 0, 1 },
+ { 1, 1 },
+ { 1, 0 },
+ { 1, -1 },
+ { 0, -1 },
+ { -1, -1 },
+ { -1, 0 },
+ { -1, 1 }
};
-visual()
+void
+visual(z)
+ int z;
{
register int ix, iy;
int co;
diff --git a/games/trek/warp.c b/games/trek/warp.c
index fa87589dda2..6a3637bd4c7 100644
--- a/games/trek/warp.c
+++ b/games/trek/warp.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: warp.c,v 1.2 1998/08/19 07:42:16 pjanzen Exp $ */
/* $NetBSD: warp.c,v 1.3 1995/04/22 10:59:40 cgd Exp $ */
/*
@@ -37,11 +38,16 @@
#if 0
static char sccsid[] = "@(#)warp.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: warp.c,v 1.3 1995/04/22 10:59:40 cgd Exp $";
+static char rcsid[] = "$OpenBSD: warp.c,v 1.2 1998/08/19 07:42:16 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+#include <unistd.h>
+#include "trek.h"
+#include "getpar.h"
/*
** MOVE UNDER WARP POWER
@@ -59,34 +65,46 @@ static char rcsid[] = "$NetBSD: warp.c,v 1.3 1995/04/22 10:59:40 cgd Exp $";
** case, there is code to handle time warps, etc.
*/
+void
+dowarp(fl)
+ int fl;
+{
+ int c;
+ double d;
+
+ if (getcodi(&c, &d))
+ return;
+ warp(fl, c, d);
+}
+
+void
warp(fl, c, d)
-int fl, c;
-double d;
+ int fl, c;
+ double d;
{
- int course;
- double power;
- double dist;
- double time;
- double speed;
- double frac;
- register int percent;
- register int i;
- extern double move();
+ char *p;
+ int course;
+ double power;
+ double dist;
+ double time;
+ double speed;
+ double frac;
+ register int percent;
+ register int i;
if (Ship.cond == DOCKED)
- return (printf("%s is docked\n", Ship.shipname));
- if (damaged(WARP))
{
- return (out(WARP));
+ printf("%s is docked\n", Ship.shipname);
+ return;
}
- if (fl < 0)
+ if (damaged(WARP))
{
- course = c;
- dist = d;
+ out(WARP);
+ return;
}
- else
- if (getcodi(&course, &dist))
- return;
+
+ course = c;
+ dist = d;
/* check to see that we are not using an absurd amount of power */
power = (dist + 0.05) * Ship.warp3;
@@ -140,10 +158,11 @@ double d;
sleep(4);
if (ranf(100) >= 100 * dist)
{
- return (printf("Equilibrium restored -- all systems normal\n"));
+ printf("Equilibrium restored -- all systems normal\n");
+ return;
}
- /* select a bizzare thing to happen to us */
+ /* select a bizarre thing to happen to us */
percent = ranf(100);
if (percent < 70)
{
@@ -166,10 +185,12 @@ double d;
/* s/he got lucky: a negative time portal */
time = Now.date;
- i = (int) Etc.snapshot;
- bmove(i, Quad, sizeof Quad);
- bmove(i += sizeof Quad, Event, sizeof Event);
- bmove(i += sizeof Event, &Now, sizeof Now);
+ p = (char *) Etc.snapshot;
+ memcpy(p, Quad, sizeof Quad);
+ p += sizeof Quad;
+ memcpy(p, Event, sizeof Event);
+ p += sizeof Event;
+ memcpy(p, &Now, sizeof Now);
printf("Negative time portal entered -- it is now Stardate %.2f\n",
Now.date);
for (i = 0; i < MAXEVENTS; i++)
diff --git a/games/trek/win.c b/games/trek/win.c
index 85d3dc298ed..1ee3bfeeb2f 100644
--- a/games/trek/win.c
+++ b/games/trek/win.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: win.c,v 1.2 1998/08/19 07:42:18 pjanzen Exp $ */
/* $NetBSD: win.c,v 1.3 1995/04/22 10:59:41 cgd Exp $ */
/*
@@ -37,13 +38,15 @@
#if 0
static char sccsid[] = "@(#)win.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: win.c,v 1.3 1995/04/22 10:59:41 cgd Exp $";
+static char rcsid[] = "$OpenBSD: win.c,v 1.2 1998/08/19 07:42:18 pjanzen Exp $";
#endif
#endif /* not lint */
-# include "trek.h"
-# include "getpar.h"
-# include <setjmp.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <setjmp.h>
+#include "trek.h"
+#include "getpar.h"
/*
** Signal game won
@@ -58,13 +61,12 @@ static char rcsid[] = "$NetBSD: win.c,v 1.3 1995/04/22 10:59:41 cgd Exp $";
** pretty off the wall.
*/
+void
win()
{
long s;
- extern jmp_buf env;
- extern long score();
- extern struct cvntab Skitab[];
- register struct cvntab *p;
+ register struct cvntab *p = NULL;
+ extern jmp_buf env;
sleep(1);
printf("\nCongratulations, you have saved the Federation\n");
diff --git a/games/worm/worm.6 b/games/worm/worm.6
index e328c017011..30f10c1023e 100644
--- a/games/worm/worm.6
+++ b/games/worm/worm.6
@@ -1,4 +1,4 @@
-.\" $OpenBSD: worm.6,v 1.4 1998/04/28 07:37:19 deraadt Exp $
+.\" $OpenBSD: worm.6,v 1.5 1998/08/19 07:42:20 pjanzen Exp $
.\"
.\" Copyright (c) 1989, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -40,11 +40,11 @@
.Nm worm
.Nd Play the growing worm game
.Sh SYNOPSIS
-.Nm worm
+.Nm
.Op Ar size
.Sh DESCRIPTION
In
-.Nm worm,
+.Nm worm ,
you are a little worm: your body is the "o"'s on the screen
and your head is the "@". You move with the hjkl keys (as in the game
.Xr snake 6 Ns ).
diff --git a/games/worm/worm.c b/games/worm/worm.c
index 314d4a24f47..28d9f85aa4e 100644
--- a/games/worm/worm.c
+++ b/games/worm/worm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: worm.c,v 1.5 1998/03/12 09:09:30 pjanzen Exp $ */
+/* $OpenBSD: worm.c,v 1.6 1998/08/19 07:42:21 pjanzen Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)worm.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: worm.c,v 1.5 1998/03/12 09:09:30 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: worm.c,v 1.6 1998/08/19 07:42:21 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -179,8 +179,8 @@ life()
void
display(pos, chr)
-struct body *pos;
-char chr;
+ struct body *pos;
+ char chr;
{
wmove(tv, pos->y, pos->x);
waddch(tv, chr);
@@ -188,7 +188,7 @@ char chr;
void
leave(dummy)
-int dummy;
+ int dummy;
{
endwin();
exit(0);
@@ -196,7 +196,7 @@ int dummy;
void
wake(dummy)
-int dummy;
+ int dummy;
{
signal(SIGALRM, wake);
fflush(stdout);
@@ -205,14 +205,14 @@ int dummy;
int
rnd(range)
-int range;
+ int range;
{
return random() % range;
}
void
newpos(bp)
-struct body * bp;
+ struct body * bp;
{
do {
bp->y = rnd(LINES-3)+ 2;
@@ -234,7 +234,7 @@ prize()
void
process(ch)
-char ch;
+ char ch;
{
register int x,y;
struct body *nh;
@@ -309,7 +309,7 @@ crash()
void
suspend(dummy)
-int dummy;
+ int dummy;
{
move(LINES-1, 0);
refresh();
diff --git a/games/worms/worms.6 b/games/worms/worms.6
index 41ae527af0f..4de05eb3d6b 100644
--- a/games/worms/worms.6
+++ b/games/worms/worms.6
@@ -1,4 +1,4 @@
-.\" $OpenBSD: worms.6,v 1.3 1998/03/12 09:09:32 pjanzen Exp $
+.\" $OpenBSD: worms.6,v 1.4 1998/08/19 07:42:23 pjanzen Exp $
.\"
.\" Copyright (c) 1989, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -39,14 +39,14 @@
.Nm worms
.Nd animate worms on a display terminal
.Sh SYNOPSIS
-.Nm worms
+.Nm
.Op Fl ft
.Op Fl d Ar delay
.Op Fl l Ar length
.Op Fl n Ar number
.Sh DESCRIPTION
A
-.Tn UNIX
+.Ux
version of the DEC-2136 program ``worms''.
.Pp
The options are as follows:
diff --git a/games/worms/worms.c b/games/worms/worms.c
index 58aec7d118e..72b834d2cf1 100644
--- a/games/worms/worms.c
+++ b/games/worms/worms.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: worms.c,v 1.7 1998/03/12 09:09:34 pjanzen Exp $ */
+/* $OpenBSD: worms.c,v 1.8 1998/08/19 07:42:24 pjanzen Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)worms.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: worms.c,v 1.7 1998/03/12 09:09:34 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: worms.c,v 1.8 1998/08/19 07:42:24 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -184,16 +184,15 @@ static struct worm {
} *worm;
int fputchar __P((int));
+void nomem __P(());
void onsig __P((int));
-void nomem __P(());
int
main(argc, argv)
int argc;
char *argv[];
{
- extern int optind;
- extern char *optarg, *UP;
+ extern char *UP;
register int x, y, h, n;
register struct worm *w;
register struct options *op;
@@ -203,7 +202,6 @@ main(argc, argv)
short **ref;
char *AL, *BC, *CM, *EI, *HO, *IC, *IM, *IP, *SR;
char *field, tcb[100], *mp;
- long random();
u_int delay = 0;
struct termios ti;
#ifdef TIOCGWINSZ
diff --git a/games/wump/wump.6 b/games/wump/wump.6
index cba639b9dab..c12fa075527 100644
--- a/games/wump/wump.6
+++ b/games/wump/wump.6
@@ -1,4 +1,4 @@
-.\" $OpenBSD: wump.6,v 1.2 1998/03/12 09:09:38 pjanzen Exp $
+.\" $OpenBSD: wump.6,v 1.3 1998/08/19 07:42:26 pjanzen Exp $
.\"
.\" Copyright (c) 1989, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -43,7 +43,7 @@
.Nm wump
.Nd hunt the wumpus in an underground cave
.Sh SYNOPSIS
-.Nm wump
+.Nm
.Op Fl h
.Op Fl a Ar arrows
.Op Fl b Ar bats
@@ -52,7 +52,7 @@
.Op Fl t Ar tunnels
.Sh DESCRIPTION
The game
-.Nm wump
+.Nm
is based on a fantasy game first presented in the pages of
.Em People's Computer Company
in 1973.
diff --git a/games/wump/wump.c b/games/wump/wump.c
index 6fc1def5f2d..0371ae6b1cf 100644
--- a/games/wump/wump.c
+++ b/games/wump/wump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wump.c,v 1.7 1998/03/12 09:09:43 pjanzen Exp $ */
+/* $OpenBSD: wump.c,v 1.8 1998/08/19 07:42:27 pjanzen Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -47,7 +47,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)wump.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: wump.c,v 1.7 1998/03/12 09:09:43 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: wump.c,v 1.8 1998/08/19 07:42:27 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -113,32 +113,32 @@ int arrow_num = NUMBER_OF_ARROWS; /* arrow inventory */
char answer[20]; /* user input */
-int bats_nearby __P((void));
-void cave_init __P((void));
-void clear_things_in_cave __P((void));
-void display_room_stats __P((void));
-int getans __P((const char *));
-void initialize_things_in_cave __P((void));
-void instructions __P((void));
-int int_compare __P((const void *, const void *));
-/* void jump __P((int)); */
-void kill_wump __P((void));
-int main __P((int, char **));
-int move_to __P((const char *));
-void move_wump __P((void));
-void no_arrows __P((void));
-void pit_kill __P((void));
-void pit_kill_bat __P((void));
-int pit_nearby __P((void));
-void pit_survive __P((void));
-int shoot __P((char *));
-void shoot_self __P((void));
-int take_action __P((void));
-void usage __P((void));
-void wump_kill __P((void));
-void wump_bat_kill __P((void));
-void wump_walk_kill __P((void));
-int wump_nearby __P((void));
+int bats_nearby __P((void));
+void cave_init __P((void));
+void clear_things_in_cave __P((void));
+void display_room_stats __P((void));
+int getans __P((const char *));
+void initialize_things_in_cave __P((void));
+void instructions __P((void));
+int int_compare __P((const void *, const void *));
+/* void jump __P((int)); */
+void kill_wump __P((void));
+int main __P((int, char **));
+int move_to __P((const char *));
+void move_wump __P((void));
+void no_arrows __P((void));
+void pit_kill __P((void));
+void pit_kill_bat __P((void));
+int pit_nearby __P((void));
+void pit_survive __P((void));
+int shoot __P((char *));
+void shoot_self __P((void));
+int take_action __P((void));
+void usage __P((void));
+void wump_kill __P((void));
+void wump_bat_kill __P((void));
+void wump_walk_kill __P((void));
+int wump_nearby __P((void));
int
@@ -146,7 +146,6 @@ main(argc, argv)
int argc;
char **argv;
{
- extern char *optarg;
int c;
/* revoke */
@@ -395,7 +394,7 @@ move_to(room_number)
wump_kill();
return(1);
}
- if (cave[next_room].has_a_pit)
+ if (cave[next_room].has_a_pit) {
if (random() % 12 < 2) {
pit_survive();
return(0);
@@ -406,6 +405,7 @@ move_to(room_number)
pit_kill();
return(1);
}
+ }
if (cave[next_room].has_a_bat) {
(void)printf(
@@ -441,7 +441,7 @@ shoot(room_list)
*/
arrow_location = player_loc;
for (roomcnt = 1;; ++roomcnt, room_list = NULL) {
- if (!(p = strtok(room_list, " \t\n")))
+ if (!(p = strtok(room_list, " \t\n"))) {
if (roomcnt == 1) {
(void)printf("Enter a list of rooms to shoot into:\n");
(void)fflush(stdout);
@@ -453,6 +453,7 @@ shoot(room_list)
}
} else
break;
+ }
if (roomcnt > 5) {
(void)printf(
"The arrow wavers in its flight and and can go no further than room %d!\n",