mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
tags, formatting, ANSI-fication, prototypes, de-typos, and the occasional
initialization, removal of unused variable, or other minor fix. Most changes are from or inspired by NetBSD.
This commit is contained in:
parent
c59ab75f50
commit
1ed0e75d51
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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]);
|
||||
|
@ -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++)
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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--)
|
||||
|
@ -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);
|
||||
|
@ -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];
|
||||
|
@ -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 +.
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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: ");
|
||||
|
@ -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;
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 $ */
|
||||
|
||||
/*-
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 $ */
|
||||
|
||||
/*-
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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() );
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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] =
|
||||
|
@ -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] */
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
}
|
@ -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;
|
||||
|
@ -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.
|
||||
*/
|
||||
|
||||
warp(fl, c, d)
|
||||
int fl, c;
|
||||
double d;
|
||||
void
|
||||
dowarp(fl)
|
||||
int fl;
|
||||
{
|
||||
int course;
|
||||
double power;
|
||||
double dist;
|
||||
double time;
|
||||
double speed;
|
||||
double frac;
|
||||
register int percent;
|
||||
register int i;
|
||||
extern double move();
|
||||
int c;
|
||||
double d;
|
||||
|
||||
if (getcodi(&c, &d))
|
||||
return;
|
||||
warp(fl, c, d);
|
||||
}
|
||||
|
||||
void
|
||||
warp(fl, c, d)
|
||||
int fl, c;
|
||||
double d;
|
||||
{
|
||||
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));
|
||||
{
|
||||
printf("%s is docked\n", Ship.shipname);
|
||||
return;
|
||||
}
|
||||
if (damaged(WARP))
|
||||
{
|
||||
return (out(WARP));
|
||||
out(WARP);
|
||||
return;
|
||||
}
|
||||
if (fl < 0)
|
||||
{
|
||||
course = c;
|
||||
dist = d;
|
||||
}
|
||||
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++)
|
||||
|
@ -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");
|
||||
|
@ -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 ).
|
||||
|
@ -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();
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user