diff --git a/adventure/Makefile.bsd b/adventure/Makefile.bsd index c40da98..adc23f3 100644 --- a/adventure/Makefile.bsd +++ b/adventure/Makefile.bsd @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.7 1998/08/01 23:02:35 hubertf Exp $ +# $NetBSD: Makefile,v 1.9 2002/03/05 21:28:12 thorpej Exp $ # @(#)Makefile 8.1 (Berkeley) 6/12/93 PROG= adventure @@ -8,9 +8,9 @@ HIDEGAME=hidegame CLEANFILES+=setup data.c data.c: glorkz setup - ${.OBJDIR}/setup ${.CURDIR}/glorkz > data.c + ./setup ${.CURDIR}/glorkz > data.c setup: setup.c hdr.h - ${HOST_CC} -o setup ${.CURDIR}/setup.c + ${HOST_LINK.c} -o setup ${.CURDIR}/setup.c .include diff --git a/adventure/Makefrag b/adventure/Makefrag index a89d568..64bc7e2 100644 --- a/adventure/Makefrag +++ b/adventure/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for adventure +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. adventure_CLEANFILES := data.c adventure_DIRS := $(GAMESDIR) $(MAN6DIR) diff --git a/adventure/crc.c b/adventure/crc.c index ec32d30..2e00099 100644 --- a/adventure/crc.c +++ b/adventure/crc.c @@ -1,4 +1,4 @@ -/* $NetBSD: crc.c,v 1.6 1998/09/13 00:07:24 hubertf Exp $ */ +/* $NetBSD: crc.c,v 1.7 1999/02/10 00:29:21 hubertf Exp $ */ /*- * Copyright (c) 1993 @@ -42,7 +42,7 @@ static char sccsid[] = "@(#)crc.c 8.1 (Berkeley) 5/31/93"; static char ORIGINAL_sccsid[] = "@(#)crc.c 5.2 (Berkeley) 4/4/91"; #else -__RCSID("$NetBSD: crc.c,v 1.6 1998/09/13 00:07:24 hubertf Exp $"); +__RCSID("$NetBSD: crc.c,v 1.7 1999/02/10 00:29:21 hubertf Exp $"); #endif #endif /* not lint */ diff --git a/adventure/done.c b/adventure/done.c index 6d2856b..eb5def8 100644 --- a/adventure/done.c +++ b/adventure/done.c @@ -1,4 +1,4 @@ -/* $NetBSD: done.c,v 1.6 1998/09/13 15:21:36 hubertf Exp $ */ +/* $NetBSD: done.c,v 1.7 2000/07/03 03:57:39 matt Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -43,13 +43,14 @@ #if 0 static char sccsid[] = "@(#)done.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: done.c,v 1.6 1998/09/13 15:21:36 hubertf Exp $"); +__RCSID("$NetBSD: done.c,v 1.7 2000/07/03 03:57:39 matt Exp $"); #endif #endif /* not lint */ /* Re-coding of advent in C: termination routines */ #include +#include #include "hdr.h" #include "extern.h" diff --git a/adventure/hdr.h b/adventure/hdr.h index 4df6e15..45e5e8b 100644 --- a/adventure/hdr.h +++ b/adventure/hdr.h @@ -1,4 +1,4 @@ -/* $NetBSD: hdr.h,v 1.5 1998/08/29 20:19:56 hubertf Exp $ */ +/* $NetBSD: hdr.h,v 1.9 2001/02/05 00:20:05 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -51,15 +51,18 @@ * * The data file distributed with the fortran source is assumed to be called * "glorkz" in the directory where the program is first run. + * + * The original FORTRAN version can be found at + * . */ /* hdr.h: included by c advent files */ #include -int datfd; /* message file descriptor */ -volatile sig_atomic_t delhit; -int yea; +extern int datfd; /* message file descriptor */ +extern volatile sig_atomic_t delhit; +extern int yea; extern char data_file[]; /* Virtual data file */ #define TAB 011 @@ -67,81 +70,77 @@ extern char data_file[]; /* Virtual data file */ #define FLUSHLINE do { int flushline_ch; while ((flushline_ch = getchar()) != EOF && flushline_ch != '\n'); } while (0) #define FLUSHLF while (next()!=LF) -int loc, newloc, oldloc, oldlc2, wzdark, gaveup, kq, k, k2; -char *wd1, *wd2; /* the complete words */ -int verb, obj, spk; +extern int loc, newloc, oldloc, oldlc2, wzdark, gaveup, kq, k, k2; +extern char *wd1, *wd2; /* the complete words */ +extern int verb, obj, spk; extern int blklin; -int saved, savet, mxscor, latncy; +extern int saveday, savet, mxscor, latncy; #define SHORT 50 /* How short is a demo game? */ #define MAXSTR 20 /* max length of user's words */ #define HTSIZE 512 /* max number of vocab words */ -struct hashtab { /* hash table for vocabulary */ +extern struct hashtab { /* hash table for vocabulary */ int val; /* word type &index (ktab) */ char *atab; /* pointer to actual string */ } voc[HTSIZE]; #define SEED 1815622 /* "Encryption" seed */ struct text -#ifdef OLDSTUFF -{ - int seekadr; /* DATFILE must be < 2**16 */ -#endif /* OLDSTUFF */ { char *seekadr;/* Msg start in virtual disk */ int txtlen; /* length of msg starting here */ }; #define RTXSIZ 205 - struct text rtext[RTXSIZ]; /* random text messages */ +extern struct text rtext[RTXSIZ]; /* random text messages */ #define MAGSIZ 35 - struct text mtext[MAGSIZ]; /* magic messages */ +extern struct text mtext[MAGSIZ]; /* magic messages */ - int clsses; +extern int clsses; #define CLSMAX 12 - struct text ctext[CLSMAX]; /* classes of adventurer */ - int cval[CLSMAX]; +extern struct text ctext[CLSMAX]; /* classes of adventurer */ +extern int cval[CLSMAX]; - struct text ptext[101]; /* object descriptions */ +extern struct text ptext[101]; /* object descriptions */ #define LOCSIZ 141 /* number of locations */ - struct text ltext[LOCSIZ]; /* long loc description */ - struct text stext[LOCSIZ]; /* short loc descriptions */ +extern struct text ltext[LOCSIZ]; /* long loc description */ +extern struct text stext[LOCSIZ]; /* short loc descriptions */ - struct travlist { /* direcs & conditions of travel */ +extern struct travlist { /* direcs & conditions of travel */ struct travlist *next; /* ptr to next list entry */ int conditions; /* m in writeup (newloc / 1000) */ int tloc; /* n in writeup (newloc % 1000) */ int tverb; /* the verb that takes you there */ } *travel[LOCSIZ], *tkk; /* travel is closer to keys(...) */ - int atloc[LOCSIZ]; +extern int atloc[LOCSIZ]; - int plac[101]; /* initial object placement */ - int fixd[101], fixed[101]; /* location fixed? */ +extern int plac[101]; /* initial object placement */ +extern int fixd[101], fixed[101]; /* location fixed? */ - int actspk[35]; /* rtext msg for verb */ +extern int actspk[35]; /* rtext msg for verb */ - int cond[LOCSIZ]; /* various condition bits */ +extern int cond[LOCSIZ]; /* various condition bits */ extern int setbit[16]; /* bit defn masks 1,2,4,... */ - int hntmax; - int hints[20][5]; /* info on hints */ - int hinted[20], hintlc[20]; +extern int hntmax; +extern int hints[20][5]; /* info on hints */ +extern int hinted[20], hintlc[20]; - int place[101], prop[101], links[201]; - int abb[LOCSIZ]; +extern int place[101], prop[101], links[201]; +extern int abb[LOCSIZ]; - int maxtrs, tally, tally2; /* treasure values */ +extern int maxtrs, tally, tally2; /* treasure values */ #define FALSE 0 #define TRUE 1 - int keys, lamp, grate, cage, rod, rod2, steps, /* mnemonics */ +extern int keys, lamp, grate, cage, rod, rod2, steps, /* mnemonics */ bird, door, pillow, snake, fissur, tablet, clam, oyster, magzin, dwarf, knife, food, bottle, water, oil, plant, plant2, axe, mirror, dragon, chasm, troll, troll2, bear, messag, @@ -150,15 +149,15 @@ struct text null, entrnc, dprssn, enter, stream, pour, say, lock, throw, find, invent; - int chloc, chloc2, dseen[7], dloc[7], /* dwarf stuff */ +extern int chloc, chloc2, dseen[7], dloc[7], /* dwarf stuff */ odloc[7], dflag, daltlc; - int tk[21], stick, dtotal, attack; - int turns, lmwarn, iwest, knfloc, detail, /* various flags and +extern int tk[21], stick, dtotal, attack; +extern int turns, lmwarn, iwest, knfloc, detail, /* various flags and * counters */ abbnum, maxdie, numdie, holdng, dkill, foobar, bonus, clock1, clock2, saved, closng, panic, closed, scorng; - int demo, newloc, limit; +extern int demo, limit; #define DECR(a,b,c,d,e) decr(a+'+',b+'-',c+'#',d+'&',e+'%') diff --git a/adventure/init.c b/adventure/init.c index 143e59a..7c888a5 100644 --- a/adventure/init.c +++ b/adventure/init.c @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.10 1998/08/29 20:19:56 hubertf Exp $ */ +/* $NetBSD: init.c,v 1.13 2001/02/05 00:20:05 christos Exp $ */ /*- * Copyright (c) 1993 @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 6/2/93"; #else -__RCSID("$NetBSD: init.c,v 1.10 1998/08/29 20:19:56 hubertf Exp $"); +__RCSID("$NetBSD: init.c,v 1.13 2001/02/05 00:20:05 christos Exp $"); #endif #endif /* not lint */ @@ -64,6 +64,70 @@ int blklin = TRUE; int setbit[16] = {1, 2, 4, 010, 020, 040, 0100, 0200, 0400, 01000, 02000, 04000, 010000, 020000, 040000, 0100000}; +int datfd; /* message file descriptor */ +volatile sig_atomic_t delhit; +int yea; + +int loc, newloc, oldloc, oldlc2, wzdark, gaveup, kq, k, k2; +char *wd1, *wd2; /* the complete words */ +int verb, obj, spk; +int saveday, savet, mxscor, latncy; + +struct hashtab voc[HTSIZE]; + +struct text rtext[RTXSIZ]; /* random text messages */ + +struct text mtext[MAGSIZ]; /* magic messages */ + +int clsses; + +struct text ctext[CLSMAX]; /* classes of adventurer */ +int cval[CLSMAX]; + +struct text ptext[101]; /* object descriptions */ + +struct text ltext[LOCSIZ]; /* long loc description */ +struct text stext[LOCSIZ]; /* short loc descriptions */ + +struct travlist *travel[LOCSIZ], *tkk; /* travel is closer to keys(...) */ + +int atloc[LOCSIZ]; + +int plac[101]; /* initial object placement */ +int fixd[101], fixed[101]; /* location fixed? */ + +int actspk[35]; /* rtext msg for verb */ + +int cond[LOCSIZ]; /* various condition bits */ + +int hntmax; +int hints[20][5]; /* info on hints */ +int hinted[20], hintlc[20]; + +int place[101], prop[101], links[201]; +int abb[LOCSIZ]; + +int maxtrs, tally, tally2; /* treasure values */ + +int keys, lamp, grate, cage, rod, rod2, steps, /* mnemonics */ + bird, door, pillow, snake, fissur, tablet, clam, oyster, + magzin, dwarf, knife, food, bottle, water, oil, plant, plant2, + axe, mirror, dragon, chasm, troll, troll2, bear, messag, + vend, batter, nugget, coins, chest, eggs, tridnt, vase, + emrald, pyram, pearl, rug, chain, spices, back, look, cave, + null, entrnc, dprssn, enter, stream, pour, say, lock, throw, + find, invent; + +int chloc, chloc2, dseen[7], dloc[7], /* dwarf stuff */ + odloc[7], dflag, daltlc; + +int tk[21], stick, dtotal, attack; +int turns, lmwarn, iwest, knfloc, detail, /* various flags and + * counters */ + abbnum, maxdie, numdie, holdng, dkill, foobar, bonus, clock1, + clock2, saved, closng, panic, closed, scorng; + +int demo, limit; void init() /* everything for 1st time run */ @@ -217,7 +281,7 @@ linkdata() void trapdel(n) /* come here if he hits a del */ - int n __attribute__((unused)); + int n __attribute__((__unused__)); { delhit = 1; /* main checks, treats as QUIT */ signal(SIGINT, trapdel);/* catch subsequent DELs */ diff --git a/adventure/io.c b/adventure/io.c index df9bc8b..e3c80e8 100644 --- a/adventure/io.c +++ b/adventure/io.c @@ -1,4 +1,4 @@ -/* $NetBSD: io.c,v 1.10 1998/09/14 09:29:08 hubertf Exp $ */ +/* $NetBSD: io.c,v 1.12 2000/01/09 17:17:19 jsm Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: io.c,v 1.10 1998/09/14 09:29:08 hubertf Exp $"); +__RCSID("$NetBSD: io.c,v 1.12 2000/01/09 17:17:19 jsm Exp $"); #endif #endif /* not lint */ @@ -361,7 +361,7 @@ rtrav() if (locc != oldloc) { /* getting a new entry */ t = travel[locc] = (struct travlist *) malloc(sizeof(struct travlist)); if ( t == NULL) - errx(1, "Out of memory!"); + err(1, NULL); /* printf("New travel list for %d\n",locc); */ entries = 0; oldloc = locc; @@ -384,7 +384,7 @@ rtrav() if (entries++) { t = t->next = (struct travlist *) malloc(sizeof(struct travlist)); if (t == NULL) - errx(1, "Out of memory!"); + err(1, NULL); } t->tverb = rnum(); /* get verb from the file */ t->tloc = n; /* table entry mod 1000 */ @@ -559,7 +559,7 @@ pspeak(m, skip) /* read, decrypt an print a ptext message */ msg = &ptext[m]; if ((tbuf = (char *) malloc(msg->txtlen + 1)) == NULL) - errx(1, "Out of memory!"); + err(1, NULL); memcpy(tbuf, msg->seekadr, msg->txtlen + 1); /* Room to null */ s = tbuf; diff --git a/adventure/main.c b/adventure/main.c index 5289232..56393c6 100644 --- a/adventure/main.c +++ b/adventure/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.12 1998/09/14 09:29:08 hubertf Exp $ */ +/* $NetBSD: main.c,v 1.16 2000/07/03 03:57:39 matt Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -48,7 +48,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\n\ #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/2/93"; #else -__RCSID("$NetBSD: main.c,v 1.12 1998/09/14 09:29:08 hubertf Exp $"); +__RCSID("$NetBSD: main.c,v 1.16 2000/07/03 03:57:39 matt Exp $"); #endif #endif /* not lint */ @@ -58,6 +58,7 @@ __RCSID("$NetBSD: main.c,v 1.12 1998/09/14 09:29:08 hubertf Exp $"); #include #include #include +#include #include #include "hdr.h" #include "extern.h" @@ -73,7 +74,7 @@ main(argc, argv) int rval, ll; struct text *kk; - /* revoke setgid privileges */ + /* revoke setgid privileges from dm */ setregid(getgid(), getgid()); init(); /* Initialize everything */ @@ -451,7 +452,7 @@ l4080: printf(" %d minutes before continuing.", latncy); if (!yes(200, 54, 54)) goto l2012; - datime(&saved, &savet); + datime(&saveday, &savet); ciao(); /* Do we quit? */ continue; /* Maybe not */ case 31: /* hours=8310 */ diff --git a/adventure/save.c b/adventure/save.c index c2dc921..71b9e78 100644 --- a/adventure/save.c +++ b/adventure/save.c @@ -1,4 +1,4 @@ -/* $NetBSD: save.c,v 1.5 1998/09/13 00:07:24 hubertf Exp $ */ +/* $NetBSD: save.c,v 1.7 1999/07/17 20:02:48 hubertf Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -43,10 +43,11 @@ #if 0 static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: save.c,v 1.5 1998/09/13 00:07:24 hubertf Exp $"); +__RCSID("$NetBSD: save.c,v 1.7 1999/07/17 20:02:48 hubertf Exp $"); #endif #endif /* not lint */ +#include #include #include #include "hdr.h" @@ -95,7 +96,7 @@ struct savestruct save_array[] = {&oldlc2, sizeof(oldlc2)}, {&oldloc, sizeof(oldloc)}, {&panic, sizeof(panic)}, - {&saved, sizeof(saved)}, + {&saveday, sizeof(saveday)}, {&savet, sizeof(savet)}, {&scorng, sizeof(scorng)}, {&spk, sizeof(spk)}, @@ -152,7 +153,10 @@ save(outfile) /* Two passes on data: first to get checksum, *s = (*s ^ random()) & 0xFF; /* Lightly encrypt */ fwrite(p->address, p->width, 1, out); } - fclose(out); + if (fclose(out) != 0) { + warn("writing %s", outfile); + return 1; + } return 0; } diff --git a/adventure/setup.c b/adventure/setup.c index a191af8..d71f965 100644 --- a/adventure/setup.c +++ b/adventure/setup.c @@ -1,4 +1,4 @@ -/* $NetBSD: setup.c,v 1.5 1998/09/13 15:23:40 hubertf Exp $ */ +/* $NetBSD: setup.c,v 1.9 2001/08/29 18:22:56 jsm Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -36,17 +36,14 @@ * SUCH DAMAGE. */ -#include #ifndef lint -__COPYRIGHT("@(#) Copyright (c) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"); -#endif /* not lint */ +static const char copyright[] __attribute__((__unused__)) = "@(#) Copyright (c) 1991, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; -#ifndef lint #if 0 static char sccsid[] = "@(#)setup.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: setup.c,v 1.5 1998/09/13 15:23:40 hubertf Exp $"); +static const char rcsid[] __attribute__((__unused__)) = "$NetBSD: setup.c,v 1.9 2001/08/29 18:22:56 jsm Exp $"; #endif #endif /* not lint */ @@ -64,18 +61,19 @@ __RCSID("$NetBSD: setup.c,v 1.5 1998/09/13 15:23:40 hubertf Exp $"); #define SIG2 " * Sterday, 6 Thrimidge S.R. 1993, 15:24" #include +#include +#include #include -#include #include "hdr.h" /* SEED lives in there; keep them coordinated. */ -#define USAGE "Usage: setup file > data.c (file is typically glorkz)" +#define USAGE "Usage: setup file > data.c (file is typically glorkz)\n" #define YES 1 #define NO 0 #define LINE 10 /* How many values do we get on a line? */ -int main __P((int, char *[])); +int main(int, char *[]); int main(argc, argv) @@ -85,11 +83,16 @@ main(argc, argv) FILE *infile; int c, count, linestart; - if (argc != 2) - errx(1, USAGE); + if (argc != 2) { + fprintf(stderr, USAGE); + exit(1); + } - if ((infile = fopen(argv[1], "r")) == NULL) - err(1, "Can't read file %s", argv[1]); + if ((infile = fopen(argv[1], "r")) == NULL) { + fprintf(stderr, "Can't read file %s: %s\n", argv[1], + strerror(errno)); + exit(1); + } puts("/*\n * data.c: created by setup from the ascii data file."); puts(SIG1); puts(SIG2); @@ -121,5 +124,10 @@ main(argc, argv) } puts("\n\t0\n};"); fclose(infile); + fflush(stdout); + if (ferror(stdout)) { + perror("error writing standard output"); + exit(1); + } exit(0); } diff --git a/adventure/subr.c b/adventure/subr.c index 1c878be..6a05a3e 100644 --- a/adventure/subr.c +++ b/adventure/subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: subr.c,v 1.8 1998/09/14 09:29:08 hubertf Exp $ */ +/* $NetBSD: subr.c,v 1.9 2000/07/03 03:57:39 matt Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -43,13 +43,14 @@ #if 0 static char sccsid[] = "@(#)subr.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: subr.c,v 1.8 1998/09/14 09:29:08 hubertf Exp $"); +__RCSID("$NetBSD: subr.c,v 1.9 2000/07/03 03:57:39 matt Exp $"); #endif #endif /* not lint */ /* Re-coding of advent in C: subroutines from main */ #include +#include #include "hdr.h" #include "extern.h" diff --git a/adventure/vocab.c b/adventure/vocab.c index 5acc8b9..f1e4d50 100644 --- a/adventure/vocab.c +++ b/adventure/vocab.c @@ -1,4 +1,4 @@ -/* $NetBSD: vocab.c,v 1.9 1998/09/14 09:29:09 hubertf Exp $ */ +/* $NetBSD: vocab.c,v 1.10 2000/01/09 17:17:19 jsm Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)vocab.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: vocab.c,v 1.9 1998/09/14 09:29:09 hubertf Exp $"); +__RCSID("$NetBSD: vocab.c,v 1.10 2000/01/09 17:17:19 jsm Exp $"); #endif #endif /* not lint */ @@ -165,7 +165,7 @@ vocab(word, type, value) /* look up or store a word */ h->val = value; h->atab = malloc(length(word)); if (h->atab == NULL) - errx(1, "Out of memory!"); + err(1, NULL); for (s = word, t = h->atab; *s;) *t++ = *s++ ^ '='; *t = 0 ^ '='; diff --git a/adventure/wizard.c b/adventure/wizard.c index ee6761a..aed2a56 100644 --- a/adventure/wizard.c +++ b/adventure/wizard.c @@ -1,4 +1,4 @@ -/* $NetBSD: wizard.c,v 1.8 1998/08/24 22:07:37 hubertf Exp $ */ +/* $NetBSD: wizard.c,v 1.10 1999/07/16 01:38:20 hubertf Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)wizard.c 8.1 (Berkeley) 6/2/93"; #else -__RCSID("$NetBSD: wizard.c,v 1.8 1998/08/24 22:07:37 hubertf Exp $"); +__RCSID("$NetBSD: wizard.c,v 1.10 1999/07/16 01:38:20 hubertf Exp $"); #endif #endif /* not lint */ @@ -91,7 +91,7 @@ Start() int d, t, delay; datime(&d, &t); - delay = (d - saved) * 1440 + (t - savet); /* good for about a + delay = (d - saveday) * 1440 + (t - savet); /* good for about a * month */ if (delay >= latncy) { @@ -137,7 +137,7 @@ ciao() printf("What would you like to call the saved version?\n"); /* XXX - should use fgetln to avoid arbitrary limit */ - for (c = fname;; c++) { + for (c = fname; c < fname + sizeof fname - 1; c++) { int ch; ch = getchar(); if (ch == '\n' || ch == EOF) diff --git a/arithmetic/Makefrag b/arithmetic/Makefrag index 7560c17..54a77aa 100644 --- a/arithmetic/Makefrag +++ b/arithmetic/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for arithmetic +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. arithmetic_DIRS := $(GAMESDIR) $(MAN6DIR) diff --git a/arithmetic/arithmetic.6 b/arithmetic/arithmetic.6 index 46475b0..4040d67 100644 --- a/arithmetic/arithmetic.6 +++ b/arithmetic/arithmetic.6 @@ -1,4 +1,4 @@ -.\" $NetBSD: arithmetic.6,v 1.6 1998/04/28 07:19:28 fair Exp $ +.\" $NetBSD: arithmetic.6,v 1.9 2002/09/26 18:31:58 wiz Exp $ .\" .\" Copyright (c) 1989, 1993 .\" The Regents of the University of California. All rights reserved. @@ -38,7 +38,7 @@ .\" .Dd May 31, 1993 .Dt ARITHMETIC 6 -.Os BSD 4 +.Os .Sh NAME .Nm arithmetic .Nd quiz on simple arithmetic @@ -54,7 +54,7 @@ After every 20 problems, it prints the score so far and the time taken. You can quit at any time by typing the interrupt or end-of-file character. .Pp The options are as follows: -.Bl -tag -width indent +.Bl -tag -width indent .It Fl o By default, .Nm @@ -81,7 +81,8 @@ divide by or subtract will be between 0 and .Ar range . (Of course, .Nm -will not ask you to divide by 0.) The default +will not ask you to divide by 0.) +The default .I range is 10. .El diff --git a/arithmetic/arithmetic.c b/arithmetic/arithmetic.c index 8914421..13add74 100644 --- a/arithmetic/arithmetic.c +++ b/arithmetic/arithmetic.c @@ -1,4 +1,4 @@ -/* $NetBSD: arithmetic.c,v 1.12 1998/09/14 09:13:46 hubertf Exp $ */ +/* $NetBSD: arithmetic.c,v 1.18 2002/03/31 04:07:22 hubertf Exp $ */ /* * Copyright (c) 1989, 1993 @@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\ #if 0 static char sccsid[] = "@(#)arithmetic.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: arithmetic.c,v 1.12 1998/09/14 09:13:46 hubertf Exp $"); +__RCSID("$NetBSD: arithmetic.c,v 1.18 2002/03/31 04:07:22 hubertf Exp $"); #endif #endif /* not lint */ @@ -94,7 +94,7 @@ int main __P((int, char *[])); int opnum __P((int)); void penalise __P((int, int, int)); int problem __P((void)); -void showstats __P((void)); +void showstats __P((int)); void usage __P((void)) __attribute__((__noreturn__)); const char keylist[] = "+-x/"; @@ -106,6 +106,8 @@ int nright, nwrong; time_t qtime; #define NQUESTS 20 +extern char *__progname; /* from crt0.o */ + /* * Select keys from +-x/ to be asked addition, subtraction, multiplication, * and division problems. More than one key may be given. The default is @@ -118,8 +120,6 @@ main(argc, argv) int argc; char **argv; { - extern char *optarg; - extern int optind; int ch, cnt; /* Revoke setgid privileges */ @@ -157,7 +157,7 @@ main(argc, argv) for (cnt = NQUESTS; cnt--;) if (problem() == EOF) exit(0); - showstats(); + showstats(0); } /* NOTREACHED */ } @@ -165,15 +165,16 @@ main(argc, argv) /* Handle interrupt character. Print score and exit. */ void intr(dummy) - int dummy __attribute__((unused)); + int dummy __attribute__((__unused__)); { - showstats(); + showstats(1); exit(0); } /* Print score. Original `arithmetic' had a delay after printing it. */ void -showstats() +showstats(bool_sigint) + int bool_sigint; { if (nright + nwrong > 0) { (void)printf("\n\nRights %d; Wrongs %d; Score %d%%", @@ -182,6 +183,10 @@ showstats() (void)printf("\nTotal time %ld seconds; %.1f seconds per problem\n\n", (long)qtime, (float)qtime / nright); } + if(!bool_sigint) { + (void)printf("Press RETURN to continue...\n"); + while(!getchar()) ; + } (void)printf("\n"); } @@ -388,9 +393,7 @@ opnum(op) void usage() { - extern char *__progname; /* from crt0.o */ - - (void)fprintf(stderr, "usage: %s [-o +-x/] [-r range]\n", + (void)fprintf(stderr, "Usage: %s [-o +-x/] [-r range]\n", __progname); exit(1); } diff --git a/backgammon/Makefile.bsd b/backgammon/Makefile.bsd index caaf1f3..adf2824 100644 --- a/backgammon/Makefile.bsd +++ b/backgammon/Makefile.bsd @@ -1,8 +1,6 @@ -# $NetBSD: Makefile,v 1.5 1997/10/16 05:24:23 lukem Exp $ +# $NetBSD: Makefile,v 1.6 2001/01/09 03:13:39 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 -SUBDIR= common_source backgammon teachgammon - -all-backgammon all-teachgammon: all-common_source +SUBDIR= common_source .WAIT backgammon teachgammon .include diff --git a/backgammon/Makefile.inc.bsd b/backgammon/Makefile.inc.bsd index 94aed0c..427d624 100644 --- a/backgammon/Makefile.inc.bsd +++ b/backgammon/Makefile.inc.bsd @@ -1,8 +1,8 @@ -# $NetBSD: Makefile.inc,v 1.5 1998/02/02 14:14:55 christos Exp $ +# $NetBSD: Makefile.inc,v 1.6 2000/12/30 17:51:26 sommerfeld Exp $ -LIBCOMMON != cd ${.CURDIR}/../common_source;\ - printf "xxx: .MAKE\n\t@echo \$${.OBJDIR}\n" | ${MAKE} -s -f- +.include +LIBCOMMON != cd ${.CURDIR}/../common_source; ${PRINTOBJDIR} CPPFLAGS+=-DV7 -I${.CURDIR}/../common_source DPADD+= ${LIBCOMMON}/libcommon.a ${LIBTERMCAP} LDADD+= -L${LIBCOMMON} -lcommon -ltermcap diff --git a/backgammon/Makefrag b/backgammon/Makefrag index 4d965b3..a9b4d02 100644 --- a/backgammon/Makefrag +++ b/backgammon/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for backgammon +# +# Copyright (c) 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. backgammon_all: diff --git a/backgammon/common_source/Makefile.bsd b/backgammon/common_source/Makefile.bsd index 2a4059b..1d91ed7 100644 --- a/backgammon/common_source/Makefile.bsd +++ b/backgammon/common_source/Makefile.bsd @@ -1,13 +1,12 @@ -# $NetBSD: Makefile,v 1.3 1997/10/11 20:24:06 mycroft Exp $ +# $NetBSD: Makefile,v 1.7 2002/09/18 06:16:39 lukem Exp $ -LIB= common -SRCS= allow.c board.c check.c fancy.c init.c odds.c one.c save.c subs.c \ - table.c +NOLINKLIB= # defined +NOLINT= # defined +NOPIC= # defined +NOPROFILE= # defined -NOPROFILE= noprofile -NOPIC= nopic - -# only needed during build -libinstall:: +LIB= common +SRCS= allow.c board.c check.c fancy.c init.c odds.c \ + one.c save.c subs.c table.c .include diff --git a/backgammon/common_source/Makefrag b/backgammon/common_source/Makefrag index 56689f5..3932beb 100644 --- a/backgammon/common_source/Makefrag +++ b/backgammon/common_source/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for backgammon/common_source +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. backgammon_common_source_EXEC_PATH := $(GAMESDIR)/backgammon backgammon_common_source_TEACH_PATH := $(GAMESDIR)/teachgammon diff --git a/backgammon/common_source/back.h b/backgammon/common_source/back.h index 5e4f098..e17b81a 100644 --- a/backgammon/common_source/back.h +++ b/backgammon/common_source/back.h @@ -1,4 +1,4 @@ -/* $NetBSD: back.h,v 1.9 1998/09/13 15:31:07 hubertf Exp $ */ +/* $NetBSD: back.h,v 1.12 1999/10/04 23:26:59 lukem Exp $ */ /* * Copyright (c) 1980, 1993 @@ -146,7 +146,7 @@ void cline __P((void)); int count __P((void)); void curmove __P((int, int)); int dotable __P((char, int)); -void errexit __P((const char *)); +void errexit __P((const char *)) __attribute__((__noreturn__)); void fancyc __P((int)); void fboard __P((void)); void fixcol __P((int, int, int, int, int)); @@ -168,7 +168,7 @@ int movokay __P((int)); void newline __P((void)); void newpos __P((void)); void nexturn __P((void)); -void norec __P((const char *)); +void norec __P((const char *)) __attribute__((__noreturn__)); void odds __P((int, int, int)); void proll __P((void)); int quit __P((void)); diff --git a/backgammon/common_source/board.c b/backgammon/common_source/board.c index c348c8d..56cffb2 100644 --- a/backgammon/common_source/board.c +++ b/backgammon/common_source/board.c @@ -1,4 +1,4 @@ -/* $NetBSD: board.c,v 1.5 1997/10/10 08:59:43 lukem Exp $ */ +/* $NetBSD: board.c,v 1.6 1999/02/10 12:29:47 hubertf Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)board.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: board.c,v 1.5 1997/10/10 08:59:43 lukem Exp $"); +__RCSID("$NetBSD: board.c,v 1.6 1999/02/10 12:29:47 hubertf Exp $"); #endif #endif /* not lint */ diff --git a/backgammon/common_source/fancy.c b/backgammon/common_source/fancy.c index ed94f98..78f50a1 100644 --- a/backgammon/common_source/fancy.c +++ b/backgammon/common_source/fancy.c @@ -1,4 +1,4 @@ -/* $NetBSD: fancy.c,v 1.7 1998/09/13 15:19:35 hubertf Exp $ */ +/* $NetBSD: fancy.c,v 1.10 1999/07/26 18:39:06 hubertf Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,14 +38,14 @@ #if 0 static char sccsid[] = "@(#)fancy.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: fancy.c,v 1.7 1998/09/13 15:19:35 hubertf Exp $"); +__RCSID("$NetBSD: fancy.c,v 1.10 1999/07/26 18:39:06 hubertf Exp $"); #endif #endif /* not lint */ #include "back.h" -char PC; /* padding character */ -char *BC; /* backspace sequence */ +extern char PC; /* padding character */ +extern char *BC; /* backspace sequence */ char *CD; /* clear to end of screen sequence */ char *CE; /* clear to end of line sequence */ char *CL; /* clear screen sequence */ @@ -54,7 +54,7 @@ char *HO; /* home cursor sequence */ char *MC; /* column cursor movement map */ char *ML; /* row cursor movement map */ char *ND; /* forward cursor sequence */ -char *UP; /* up cursor sequence */ +extern char *UP; /* up cursor sequence */ int lHO; /* length of HO */ int lBC; /* length of BC */ diff --git a/backgammon/common_source/init.c b/backgammon/common_source/init.c index 79dc535..dc06d6e 100644 --- a/backgammon/common_source/init.c +++ b/backgammon/common_source/init.c @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.6 1997/10/14 00:53:31 lukem Exp $ */ +/* $NetBSD: init.c,v 1.7 1999/02/10 12:29:48 hubertf Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: init.c,v 1.6 1997/10/14 00:53:31 lukem Exp $"); +__RCSID("$NetBSD: init.c,v 1.7 1999/02/10 12:29:48 hubertf Exp $"); #endif #endif /* not lint */ @@ -67,7 +67,7 @@ int tflag = 0; /* cursor addressing flag */ int iroll = 0; /* special flag for inputting rolls */ int rfl = 0; -const char *const color[] = {"White", "Red", "white", "red"}; +const char *const color[] = {"White", "Red", "white", "red"}; const char *const *Colorptr; diff --git a/backgammon/common_source/save.c b/backgammon/common_source/save.c index ddb54ce..2f4a810 100644 --- a/backgammon/common_source/save.c +++ b/backgammon/common_source/save.c @@ -1,4 +1,4 @@ -/* $NetBSD: save.c,v 1.7 1998/09/13 15:41:34 hubertf Exp $ */ +/* $NetBSD: save.c,v 1.9 1999/07/28 02:07:39 hubertf Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: save.c,v 1.7 1998/09/13 15:41:34 hubertf Exp $"); +__RCSID("$NetBSD: save.c,v 1.9 1999/07/28 02:07:39 hubertf Exp $"); #endif #endif /* not lint */ @@ -111,7 +111,7 @@ save(n) close(fdesc); if (yorn(0)) { unlink(fname); - fdesc = creat(fname, 0700); + fdesc = creat(fname, 0600); break; } else { cflag = 1; diff --git a/backgammon/common_source/subs.c b/backgammon/common_source/subs.c index e43842c..48d0550 100644 --- a/backgammon/common_source/subs.c +++ b/backgammon/common_source/subs.c @@ -1,4 +1,4 @@ -/* $NetBSD: subs.c,v 1.8 1998/09/13 15:19:35 hubertf Exp $ */ +/* $NetBSD: subs.c,v 1.13 1999/10/04 23:26:59 lukem Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)subs.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: subs.c,v 1.8 1998/09/13 15:19:35 hubertf Exp $"); +__RCSID("$NetBSD: subs.c,v 1.13 1999/10/04 23:26:59 lukem Exp $"); #endif #endif /* not lint */ @@ -84,7 +84,7 @@ addbuf(c) buffnum = 0; } outbuff[buffnum] = c; - return 0; + return (0); } void @@ -325,7 +325,7 @@ getarg(arg) * the game is being recovered */ s = *arg; - while (s[0] != NULL && s[0][0] == '-') { + while (*s && s[0][0] == '-') { switch (s[0][1]) { /* don't ask if rules or instructions needed */ @@ -447,7 +447,7 @@ fixtty(t) void getout(dummy) - int dummy __attribute__((unused)); + int dummy __attribute__((__unused__)); { /* go to bottom of screen */ if (tflag) { diff --git a/backgammon/common_source/table.c b/backgammon/common_source/table.c index f032e93..5f545e5 100644 --- a/backgammon/common_source/table.c +++ b/backgammon/common_source/table.c @@ -1,4 +1,4 @@ -/* $NetBSD: table.c,v 1.5 1997/10/10 08:59:49 lukem Exp $ */ +/* $NetBSD: table.c,v 1.6 1999/02/10 12:29:48 hubertf Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: table.c,v 1.5 1997/10/10 08:59:49 lukem Exp $"); +__RCSID("$NetBSD: table.c,v 1.6 1999/02/10 12:29:48 hubertf Exp $"); #endif #endif /* not lint */ diff --git a/backgammon/teachgammon/Makefile.bsd b/backgammon/teachgammon/Makefile.bsd index cd53994..af8662e 100644 --- a/backgammon/teachgammon/Makefile.bsd +++ b/backgammon/teachgammon/Makefile.bsd @@ -1,8 +1,9 @@ -# $NetBSD: Makefile,v 1.8 1997/10/10 08:59:50 lukem Exp $ +# $NetBSD: Makefile,v 1.11 2002/09/18 06:16:39 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 -PROG= teachgammon -SRCS= data.c teach.c ttext1.c ttext2.c tutor.c -NOMAN= noman +NOMAN= # defined + +PROG= teachgammon +SRCS= data.c teach.c ttext1.c ttext2.c tutor.c .include diff --git a/backgammon/teachgammon/Makefrag b/backgammon/teachgammon/Makefrag index 3822772..398e40a 100644 --- a/backgammon/teachgammon/Makefrag +++ b/backgammon/teachgammon/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for backgammon/teachgammon +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. backgammon_teachgammon_DEFS := -DV7 backgammon_teachgammon_DIRS := $(GAMESDIR) $(MAN6DIR) diff --git a/backgammon/teachgammon/data.c b/backgammon/teachgammon/data.c index 64bba14..8af936d 100644 --- a/backgammon/teachgammon/data.c +++ b/backgammon/teachgammon/data.c @@ -1,4 +1,4 @@ -/* $NetBSD: data.c,v 1.4 1997/10/10 08:59:51 lukem Exp $ */ +/* $NetBSD: data.c,v 1.5 1999/02/10 12:29:48 hubertf Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)data.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: data.c,v 1.4 1997/10/10 08:59:51 lukem Exp $"); +__RCSID("$NetBSD: data.c,v 1.5 1999/02/10 12:29:48 hubertf Exp $"); #endif #endif /* not lint */ diff --git a/backgammon/teachgammon/teach.c b/backgammon/teachgammon/teach.c index 326c233..d3520ea 100644 --- a/backgammon/teachgammon/teach.c +++ b/backgammon/teachgammon/teach.c @@ -1,4 +1,4 @@ -/* $NetBSD: teach.c,v 1.6 1998/08/29 22:53:04 hubertf Exp $ */ +/* $NetBSD: teach.c,v 1.13 2001/04/06 11:13:52 wiz Exp $ */ /* * Copyright (c) 1980, 1993 @@ -43,17 +43,13 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ #if 0 static char sccsid[] = "@(#)teach.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: teach.c,v 1.6 1998/08/29 22:53:04 hubertf Exp $"); +__RCSID("$NetBSD: teach.c,v 1.13 2001/04/06 11:13:52 wiz Exp $"); #endif #endif /* not lint */ #include "back.h" #include "tutor.h" -#ifndef NCURSES_VERSION -extern speed_t ospeed; /* tty output speed for termlib */ -#endif - const char *const helpm[] = { "\nEnter a space or newline to roll, or", " b to display the board", @@ -69,7 +65,7 @@ const char *const contin[] = { int main(argc, argv) - int argc __attribute__((unused)); + int argc __attribute__((__unused__)); char *argv[]; { int i; @@ -160,7 +156,7 @@ leave() else writec('\n'); fixtty(&old); - execl(EXEC, "backgammon", args, "-n", 0); + execl(EXEC, "backgammon", "-n", args[1]?args:0, 0); writel("Help! Backgammon program is missing\007!!\n"); - exit(-1); + exit(1); } diff --git a/backgammon/teachgammon/ttext1.c b/backgammon/teachgammon/ttext1.c index 5d35ca5..2091e0d 100644 --- a/backgammon/teachgammon/ttext1.c +++ b/backgammon/teachgammon/ttext1.c @@ -1,4 +1,4 @@ -/* $NetBSD: ttext1.c,v 1.4 1997/10/10 08:59:53 lukem Exp $ */ +/* $NetBSD: ttext1.c,v 1.6 1999/07/25 00:06:13 hubertf Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,15 +38,15 @@ #if 0 static char sccsid[] = "@(#)ttext1.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: ttext1.c,v 1.4 1997/10/10 08:59:53 lukem Exp $"); +__RCSID("$NetBSD: ttext1.c,v 1.6 1999/07/25 00:06:13 hubertf Exp $"); #endif #endif /* not lint */ #include "back.h" #include "tutor.h" -const char *opts = " QIMRHEDSPT"; -const char *prompt = "-->"; +const char *const opts = " QIMRHEDSPT"; +const char *const prompt = "-->"; const char *const list[] = { "\n\n\tI\tIntroduction to Backgammon", diff --git a/backgammon/teachgammon/ttext2.c b/backgammon/teachgammon/ttext2.c index 35f4eaa..51ab8b0 100644 --- a/backgammon/teachgammon/ttext2.c +++ b/backgammon/teachgammon/ttext2.c @@ -1,4 +1,4 @@ -/* $NetBSD: ttext2.c,v 1.5 1997/10/10 08:59:53 lukem Exp $ */ +/* $NetBSD: ttext2.c,v 1.6 1999/02/10 12:29:48 hubertf Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)ttext2.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: ttext2.c,v 1.5 1997/10/10 08:59:53 lukem Exp $"); +__RCSID("$NetBSD: ttext2.c,v 1.6 1999/02/10 12:29:48 hubertf Exp $"); #endif #endif /* not lint */ diff --git a/backgammon/teachgammon/tutor.c b/backgammon/teachgammon/tutor.c index 7891cb0..c1a122d 100644 --- a/backgammon/teachgammon/tutor.c +++ b/backgammon/teachgammon/tutor.c @@ -1,4 +1,4 @@ -/* $NetBSD: tutor.c,v 1.4 1997/10/10 08:59:54 lukem Exp $ */ +/* $NetBSD: tutor.c,v 1.5 1999/02/10 12:29:48 hubertf Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)tutor.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: tutor.c,v 1.4 1997/10/10 08:59:54 lukem Exp $"); +__RCSID("$NetBSD: tutor.c,v 1.5 1999/02/10 12:29:48 hubertf Exp $"); #endif #endif /* not lint */ diff --git a/backgammon/teachgammon/tutor.h b/backgammon/teachgammon/tutor.h index 0bdcb0e..e3ba2f7 100644 --- a/backgammon/teachgammon/tutor.h +++ b/backgammon/teachgammon/tutor.h @@ -1,4 +1,4 @@ -/* $NetBSD: tutor.h,v 1.5 1998/09/13 15:27:26 hubertf Exp $ */ +/* $NetBSD: tutor.h,v 1.6 1999/02/10 12:29:48 hubertf Exp $ */ /* * Copyright (c) 1980, 1993 @@ -58,9 +58,9 @@ extern const char *const lastch[]; extern const char *const list[]; extern int maxmoves; extern const char *const moves[]; -extern const char *opts; +extern const char *const opts; extern const char *const prog[]; -extern const char *prompt; +extern const char *const prompt; extern const char *const removepiece[]; extern const char *const stragy[]; extern const struct situatn test[]; diff --git a/banner/Makefrag b/banner/Makefrag index 1a49a27..abf57f0 100644 --- a/banner/Makefrag +++ b/banner/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for banner +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. banner_DIRS := $(GAMESDIR) $(MAN6DIR) diff --git a/banner/banner.6 b/banner/banner.6 index 892d8d3..0f46ca4 100644 --- a/banner/banner.6 +++ b/banner/banner.6 @@ -1,4 +1,4 @@ -.\" $NetBSD: banner.6,v 1.9 1997/10/10 09:48:47 lukem Exp $ +.\" $NetBSD: banner.6,v 1.12 2002/09/26 18:31:59 wiz Exp $ .\" .\" Copyright (c) 1980, 1993, 1995 .\" The Regents of the University of California. All rights reserved. @@ -37,7 +37,7 @@ .Dt BANNER 6 .Os .Sh NAME -.Nm banner +.Nm banner .Nd print large banner on printer .Sh SYNOPSIS .Nm @@ -57,8 +57,8 @@ suitable for a narrow terminal. The output should be printed on paper of the appropriate width, with no breaks between the pages. .Sh BUGS -Several ASCII characters are not defined, notably <, >, [, ], \\, -^, _, {, }, |, and ~. Also, the characters ", ', and & are funny +Several ASCII characters are not defined, notably \*[Lt], \*[Gt], [, ], \\, +^, _, {, }, |, and ~. Also, the characters ", ', and \*[Am] are funny looking (but in a useful way.) .Pp The @@ -67,4 +67,4 @@ option is implemented by skipping some rows and columns. The smaller it gets, the grainier the output. Sometimes it runs letters together. .Sh AUTHOR -Mark Horton +.An Mark Horton diff --git a/banner/banner.c b/banner/banner.c index c7f1abe..0b812cd 100644 --- a/banner/banner.c +++ b/banner/banner.c @@ -1,4 +1,4 @@ -/* $NetBSD: banner.c,v 1.8 1998/09/14 09:30:57 hubertf Exp $ */ +/* $NetBSD: banner.c,v 1.10 1999/07/19 19:07:17 hubertf Exp $ */ /* * Copyright (c) 1980, 1993, 1994 @@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993, 1994\n\ #if 0 static char sccsid[] = "@(#)banner.c 8.4 (Berkeley) 4/29/95"; #else -__RCSID("$NetBSD: banner.c,v 1.8 1998/09/14 09:30:57 hubertf Exp $"); +__RCSID("$NetBSD: banner.c,v 1.10 1999/07/19 19:07:17 hubertf Exp $"); #endif #endif /* not lint */ diff --git a/battlestar/Makefile.bsd b/battlestar/Makefile.bsd index 33c6bc4..424f29a 100644 --- a/battlestar/Makefile.bsd +++ b/battlestar/Makefile.bsd @@ -1,8 +1,9 @@ -# $NetBSD: Makefile,v 1.8 1998/02/18 22:37:30 jtc Exp $ +# $NetBSD: Makefile,v 1.9 2001/10/19 03:06:09 tv Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 PROG= battlestar -SRCS= battlestar.c com1.c com2.c com3.c com4.c com5.c com6.c com7.c \ +SRCS= battlestar.c command1.c command2.c command3.c command4.c \ + command5.c command6.c command7.c \ init.c cypher.c getcom.c parse.c room.c save.c fly.c misc.c \ globals.c dayfile.c nightfile.c dayobjs.c nightobjs.c words.c MAN= battlestar.6 diff --git a/battlestar/Makefrag b/battlestar/Makefrag index 292f722..cdbc08d 100644 --- a/battlestar/Makefrag +++ b/battlestar/Makefrag @@ -1,5 +1,32 @@ # Makefrag - makefile fragment for battlestar +# +# Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. +battlestar_DEFS := $(FGETLN_DEFS) battlestar_DIRS := $(GAMESDIR) $(MAN6DIR) battlestar_all: battlestar/battlestar battlestar/battlestar.6 diff --git a/battlestar/battlestar.6 b/battlestar/battlestar.6 index 1a8d545..b8ecf08 100644 --- a/battlestar/battlestar.6 +++ b/battlestar/battlestar.6 @@ -1,4 +1,4 @@ -.\" $NetBSD: battlestar.6,v 1.6 1998/09/10 21:50:35 frueauf Exp $ +.\" $NetBSD: battlestar.6,v 1.12 2002/09/26 18:31:59 wiz Exp $ .\" .\" Copyright (c) 1983, 1993 .\" The Regents of the University of California. All rights reserved. @@ -33,7 +33,7 @@ .\" .\" @(#)battlestar.6 8.1 (Berkeley) 5/31/93 .\" -.Dd May 31, 1993 +.Dd September 7, 2000 .Dt BATTLESTAR 6 .Os .Sh NAME @@ -42,17 +42,15 @@ .Sh SYNOPSIS .Nm .Op Fl r -.Op saved-file +.Op Ar saved-file .Sh DESCRIPTION .Nm -is an adventure game in the classic style. However, it's slightly less -of a -puzzle and more a game of exploration. There are a few magical words -in the game, but on the whole, simple English +is an adventure game in the classic style. +However, it's slightly less of a puzzle and more a game of exploration. +There are a few magical words in the game, but on the whole, simple English should suffice to make one's desires understandable to the parser. .Sh THE SETTING -In the days before the darkness came, when battlestars ruled the -heavens... +In the days before the darkness came, when battlestars ruled the heavens... .Bd -literal -offset indent Three He made and gave them to His daughters, Beautiful nymphs, the goddesses of the waters. @@ -61,19 +59,18 @@ Two to wash the lands and churn the waves asunder, Three to rule the world and purge the skies with thunder. .Ed .Pp -In those times great wizards were known and their powers were beyond -belief. They could take any object from thin air, and, uttering the -word +In those times great wizards were known and their powers were beyond belief. +They could take any object from thin air, and, uttering the word .Sq su could disappear. .Pp In those times men were known for their lust of gold and desire to -wear fine weapons. Swords and coats of mail were fashioned that could -withstand a laser blast. +wear fine weapons. +Swords and coats of mail were fashioned that could withstand a laser blast. .Pp -But when the darkness fell, the rightful reigns were toppled. Swords -and helms and heads of state went rolling across the grass. The entire -fleet of battlestars was reduced to a single ship. +But when the darkness fell, the rightful reigns were toppled. +Swords and helms and heads of state went rolling across the grass. +The entire fleet of battlestars was reduced to a single ship. .Sh SAMPLE COMMANDS .Bd -literal -offset indent take --- take an object @@ -85,19 +82,19 @@ draw --- carry an object you are wearing puton --- take an object and wear it take off -- draw an object and drop it -throw +throw \*[Lt]object\*[Gt] \*[Lt]direction\*[Gt] -! +! \*[Lt]shell esc\*[Gt] .Ed .Sh IMPLIED OBJECTS .Bd -literal -offset indent ->-: take watermelon +\*[Gt]-: take watermelon watermelon: Taken. ->-: eat +\*[Gt]-: eat watermelon: Eaten. ->-: take knife and sword and apple, drop all +\*[Gt]-: take knife and sword and apple, drop all knife: Taken. broadsword: @@ -110,31 +107,49 @@ broadsword: Dropped. apple: Dropped. ->-: get +\*[Gt]-: get knife: Taken. .Ed .Pp Notice that the "shadow" of the next word stays around if you -want to take advantage of it. That is, saying "take knife" and then -"drop" +want to take advantage of it. +That is, saying "take knife" and then "drop" will drop the knife you just took. -.Sh SCORE & INVEN -The two commands "score" and "inven" will print out your current status -in the game. +.Sh SCORE \*[Am] INVEN +The two commands +.Dq score +and +.Dq inven +will print out your current status in the game. .Sh SAVING A GAME -The command "save" will save your game in a file, by default called -".Bstar" in your home directory. You -can recover a saved game by using the +The command +.Dq save +will save your game in a file called +.Pa .Bstar +in your home directory by default. +You can recover a saved game by using the .Fl r option when you start up the game, or by giving the name of the saved file as an argument. +Save files will be saved to and restored from your home directory unless a +path is specified - i.e., +.Dq Li battlestar -r savedgame +will look for +.Pa savedgame +in your home directory, but +.Dq Li battlestar -r ./savedgame +will look in the current directory. +.Dq Li battlestar -r +will look for the default file, +.Pa .Bstar +in your home directory. .Sh DIRECTIONS The compass directions N, S, E, and W can be used if you have a compass. If you don't have a compass, you'll have to say R, L, A, or B, which stand for Right, Left, Ahead, and Back. Directions printed in room descriptions are -always printed in R, L, A, & B relative directions. +always printed in R, L, A, and B relative directions. .Sh HISTORY I wrote Battlestar in 1979 in order to experiment with the niceties of the C Language. @@ -142,8 +157,8 @@ Most interesting things that happen in the game are hardwired into the code, so don't send me any hate mail about it! Instead, enjoy art for art's sake! .Sh AUTHOR -David Riggle -.Sh INSPIRATION & ASSISTANCE +.An David Riggle +.Sh INSPIRATION \*[Am] ASSISTANCE .Bl -item -compact .It Chris Guthrie @@ -153,8 +168,8 @@ Peter Da Silva Kevin Brown .It Edward Wang -.It -Ken Arnold & Company +.It +Ken Arnold \*[Am] Company .El .Sh BUGS Countless. diff --git a/battlestar/battlestar.c b/battlestar/battlestar.c index 310abec..a7f57ab 100644 --- a/battlestar/battlestar.c +++ b/battlestar/battlestar.c @@ -1,4 +1,4 @@ -/* $NetBSD: battlestar.c,v 1.6 1997/10/11 02:06:55 lukem Exp $ */ +/* $NetBSD: battlestar.c,v 1.12 2000/09/21 17:44:34 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\ #if 0 static char sccsid[] = "@(#)battlestar.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: battlestar.c,v 1.6 1997/10/11 02:06:55 lukem Exp $"); +__RCSID("$NetBSD: battlestar.c,v 1.12 2000/09/21 17:44:34 jsm Exp $"); #endif #endif /* not lint */ @@ -70,12 +70,16 @@ main(argc, argv) open_score_file(); setregid(getgid(), getgid()); - initialize((argc < 2) ? NULL : (strcmp(argv[1], "-r") ? argv[1] - : (argv[2] ? argv[2] - : DEFAULT_SAVE_FILE))); + if (argc < 2) + initialize(NULL); + else if (strcmp(argv[1], "-r") == 0) + initialize((argc > 2) ? argv[2] : DEFAULT_SAVE_FILE); + else + initialize(argv[1]); start: news(); - beenthere[position]++; + if (beenthere[position] <= ROOMDESC) + beenthere[position]++; if (notes[LAUNCHED]) crash(); /* decrements fuel & crash */ if (matchlight) { @@ -92,7 +96,7 @@ start: run: next = getcom(mainbuf, sizeof mainbuf, ">-: ", "Please type in something."); - for (wordcount = 0; next && wordcount < 20; wordcount++) + for (wordcount = 0; next && wordcount < NWORD - 1; wordcount++) next = getword(next, words[wordcount], -1); parse(); switch (cypher()) { @@ -101,6 +105,6 @@ run: case 0: goto start; default: - exit(1); /* Shouldn't happen */ + errx(1, "bad return from cypher(): please submit a bug report"); } } diff --git a/battlestar/cypher.c b/battlestar/cypher.c index 5ebcd0e..caf4139 100644 --- a/battlestar/cypher.c +++ b/battlestar/cypher.c @@ -1,4 +1,4 @@ -/* $NetBSD: cypher.c,v 1.7 1998/08/24 00:25:32 hubertf Exp $ */ +/* $NetBSD: cypher.c,v 1.21 2000/09/25 19:37:58 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)cypher.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: cypher.c,v 1.7 1998/08/24 00:25:32 hubertf Exp $"); +__RCSID("$NetBSD: cypher.c,v 1.21 2000/09/25 19:37:58 jsm Exp $"); #endif #endif /* not lint */ @@ -51,64 +51,82 @@ cypher() int junk; int lflag = -1; char buffer[10]; - char *filename; + char *filename, *rfilename; size_t filename_len; - while (wordtype[wordnumber] == ADJS) - wordnumber++; while (wordnumber <= wordcount) { + if (wordtype[wordnumber] != VERB && + !(wordtype[wordnumber] == OBJECT && wordvalue[wordnumber] == KNIFE)) { + printf("%s: How's that?\n", + (wordnumber == wordcount) ? words[0] : words[wordnumber]); + return (-1); + } + switch (wordvalue[wordnumber]) { + case AUXVERB: + /* + * Take the following word as the verb (e.g. + * "make love", "climb up"). + */ + wordnumber++; + continue; + case UP: if (location[position].access || wiz || tempwiz) { if (!location[position].access) puts("Zap! A gust of wind lifts you up."); - if (!move(location[position].up, AHEAD)) + if (!moveplayer(location[position].up, AHEAD)) return (-1); } else { - puts("There is no way up"); + puts("There is no way up."); return (-1); } lflag = 0; break; case DOWN: - if (!move(location[position].down, AHEAD)) + if (!moveplayer(location[position].down, AHEAD)) return (-1); lflag = 0; break; case LEFT: - if (!move(left, LEFT)) + if (!moveplayer(left, LEFT)) return (-1); lflag = 0; break; case RIGHT: - if (!move(right, RIGHT)) + if (!moveplayer(right, RIGHT)) return (-1); lflag = 0; break; case AHEAD: - if (!move(ahead, AHEAD)) + if (!moveplayer(ahead, AHEAD)) return (-1); lflag = 0; break; case BACK: - if (!move(back, BACK)) + if (!moveplayer(back, BACK)) return (-1); lflag = 0; break; case SHOOT: if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { + int things; + things = 0; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(location[position].objects, n) && objsht[n]) { + things++; wordvalue[wordnumber + 1] = n; wordnumber = shoot(); } + if (!things) + puts("Nothing to shoot at!"); wordnumber++; wordnumber++; } else @@ -117,8 +135,11 @@ cypher() case TAKE: if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { + int things; + things = 0; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(location[position].objects, n) && objsht[n]) { + things++; wordvalue[wordnumber + 1] = n; /* Some objects (type NOUNS) * have special treatment in @@ -138,6 +159,7 @@ cypher() switch(n) { case BATHGOD: wordvalue[wordnumber + 1] = NORMGOD; + /* FALLTHROUGH */ case NORMGOD: case AMULET: case MEDALION: @@ -154,120 +176,160 @@ cypher() } wordnumber++; wordnumber++; + if (!things) + puts("Nothing to take!"); } else take(location[position].objects); break; case DROP: - if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { + int things; + things = 0; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(inven, n)) { + things++; wordvalue[wordnumber + 1] = n; wordnumber = drop("Dropped"); } wordnumber++; wordnumber++; + if (!things) + puts("Nothing to drop!"); } else drop("Dropped"); break; - case KICK: case THROW: if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { + int things, wv; + things = 0; + wv = wordvalue[wordnumber]; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(inven, n) || (testbit(location[position].objects, n) && objsht[n])) { + things++; wordvalue[wordnumber + 1] = n; wordnumber = throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown"); } wordnumber += 2; + if (!things) + printf("Nothing to %s!\n", wv == KICK ? "kick" : "throw"); } else throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown"); break; case TAKEOFF: if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { + int things; + things = 0; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(wear, n)) { + things++; wordvalue[wordnumber + 1] = n; wordnumber = takeoff(); } wordnumber += 2; + if (!things) + puts("Nothing to take off!"); } else takeoff(); break; - case DRAW: - if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { + int things; + things = 0; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(wear, n)) { + things++; wordvalue[wordnumber + 1] = n; wordnumber = draw(); } wordnumber += 2; + if (!things) + puts("Nothing to draw!"); } else draw(); break; - case PUTON: - if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { + int things; + things = 0; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(location[position].objects, n) && objsht[n]) { + things++; wordvalue[wordnumber + 1] = n; wordnumber = puton(); } wordnumber += 2; + if (!things) + puts("Nothing to put on!"); } else puton(); break; case WEARIT: - if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { + int things; + things = 0; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(inven, n)) { + things++; wordvalue[wordnumber + 1] = n; wordnumber = wearit(); } wordnumber += 2; + if (!things) + puts("Nothing to wear!"); } else wearit(); break; - case EAT: - if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { + int things; + things = 0; for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(inven, n)) { + things++; wordvalue[wordnumber + 1] = n; wordnumber = eat(); } wordnumber += 2; + if (!things) + puts("Nothing to eat!"); } else eat(); break; - case PUT: put(); break; - case INVEN: if (ucard(inven)) { puts("You are holding:\n"); for (n = 0; n < NUMOFOBJECTS; n++) if (testbit(inven, n)) printf("\t%s\n", objsht[n]); - printf("\n= %d kilogram%s (%d%%)\n", carrying, (carrying == 1 ? "." : "s."), (WEIGHT ? carrying * 100 / WEIGHT : -1)); - printf("Your arms are %d%% full.\n", encumber * 100 / CUMBER); + if (WEIGHT == 0) + printf("\n= %d kilogram%s (can't lift any weight%s)\n", + carrying, + (carrying == 1 ? "." : "s."), + (carrying ? " or move with what you have" : "")); + else + printf("\n= %d kilogram%s (%d%%)\n", + carrying, + (carrying == 1 ? "." : "s."), + carrying * 100 / WEIGHT); + if (CUMBER == 0) + printf("Your arms can't pick anything up.\n"); + else + printf("Your arms are %d%% full.\n", + encumber * 100 / CUMBER); } else puts("You aren't carrying anything."); @@ -286,12 +348,30 @@ cypher() printf("\nYou can still carry up to %d kilogram%s\n", WEIGHT, (WEIGHT == 1 ? "." : "s.")); } else puts("\nYou are in perfect health."); + wordnumber++; break; case USE: lflag = use(); break; + case OPEN: + if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { + int things; + things = 0; + for (n = 0; n < NUMOFOBJECTS; n++) + if (testbit(inven, n)) { + things++; + wordvalue[wordnumber + 1] = n; + dooropen(); + } + wordnumber += 2; + if (!things) + puts("Nothing to open!"); + } else + dooropen(); + break; + case LOOK: if (!notes[CANTSEE] || testbit(inven, LAMPON) || testbit(location[position].objects, LAMPON) @@ -369,18 +449,31 @@ cypher() break; case SAVE: - printf("\nSave file name (default %s) ", + printf("\nSave file name (default %s): ", DEFAULT_SAVE_FILE); filename = fgetln(stdin, &filename_len); if (filename_len == 0 || (filename_len == 1 && filename[0] == '\n')) - save(DEFAULT_SAVE_FILE, - strlen(DEFAULT_SAVE_FILE)); + rfilename = save_file_name(DEFAULT_SAVE_FILE, + strlen(DEFAULT_SAVE_FILE)); else { if (filename[filename_len - 1] == '\n') filename_len--; - save(filename, filename_len); + rfilename = save_file_name(filename, + filename_len); } + save(rfilename); + free(rfilename); + break; + + case VERBOSE: + verbose = 1; + printf("[Maximum verbosity]\n"); + break; + + case BRIEF: + verbose = 0; + printf("[Standard verbosity]\n"); break; case FOLLOW: @@ -461,7 +554,6 @@ cypher() return (-1); break; - } if (wordnumber < wordcount && *words[wordnumber++] == ',') continue; diff --git a/battlestar/dayfile.c b/battlestar/dayfile.c index d641eb4..29c9726 100644 --- a/battlestar/dayfile.c +++ b/battlestar/dayfile.c @@ -1,4 +1,4 @@ -/* $NetBSD: dayfile.c,v 1.7 1998/07/25 10:58:03 hubertf Exp $ */ +/* $NetBSD: dayfile.c,v 1.11 2000/09/18 06:14:31 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,122 +38,144 @@ #if 0 static char sccsid[] = "@(#)dayfile.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: dayfile.c,v 1.7 1998/07/25 10:58:03 hubertf Exp $"); +__RCSID("$NetBSD: dayfile.c,v 1.11 2000/09/18 06:14:31 jsm Exp $"); #endif #endif /* not lint */ #include "extern.h" struct room dayfile[] = { - {0}, + {0, {0}, 0, {0} }, + /* 1 */ {"You are in the main hangar.", {5, 2, 9, 3, 3, 1, 0, 0}, "This is a huge bay where many fighters and cargo craft lie. Alarms are \n\ sounding and fighter pilots are running to their ships. Above is a gallery\n\ overlooking the bay. The scream of turbo engines is coming from +. The rest\n\ -of the hangar is +. There is an exit +.*\n"}, +of the hangar is +. There is an exit +.*\n", {0} }, + /* 2 */ {"This is the landing bay.", {1, 0, 10, 0, 0, 0, 0, 0}, "Ships are landing here, some heavily damaged. Enemy fighters continually\n\ -strafe this vulnerable port. The main hangar is +, *\n\ -There is an exit +.*\n"}, +strafe this vulnerable port. The main hangar is +. *\n\ +There is an exit +.*\n", {0} }, + /* 3 */ {"You are in the gallery.", {4, 0, 0, 0, 0, 0, 1, 0}, "From here a view of the entire landing bay reveals that our battlestar\n\ is near destruction. Fires are spreading out of control and laser blasts\n\ -lick at the shadows. The control room is +. ***\n"}, +lick at the shadows. The control room is +. ***\n", {0} }, + /* 4 */ {"You are in the control room.", {0, 3, 0, 0, 0, 0, 5, 0}, "Several frantic technicians are flipping switches wildly but otherwise\n\ this room seems fairly deserted. A weapons locker has been left open.\n\ -A staircase leads down. * There is a way -. ** \n"}, +A staircase leads down. * There is a way -. ** \n", {0} }, + /* 5 */ {"This is the launch room.", {6, 1, 7, 0, 4, 1, 0, 0}, "From the launch tubes here fighters blast off into space. Only one is left,\n\ and it is guarded by two fierce men. A staircase leads up from here.\n\ There is a cluttered workbench +. From the main hangar come sounds of great\n\ -explosions. The main hangar is +. The viper launch tubes are to the -.*\n"}, +explosions. The main hangar is +. The viper launch tubes are -.*\n", {0} }, + /* 6 */ {"You are at the workbench.", {0, 5, 7, 0, 0, 0, 0, 0}, "Strange and unwieldy tools are arranged here including a lunch box \n\ and pneumatic wrenches and turbo sprocket rockets.*\n\ -The launch room is +. The remaining viper is +.*\n"}, +The launch room is +. The remaining viper is +.*\n", {0} }, + /* 7 */ {"You are in the viper launch tube.", {0, 5, 0, 5, 32, 0, 0, 0}, - "The two guards are eyeing you warily! ****\n"}, + "The two guards are eyeing you warily! ****\n", {0} }, + /* 8 */ {"This is a walk in closet.", {22, 0, 0, 0, 0, 0, 0, 0}, "A wardrobe of immense magnitude greets the eye. Furs and robes of kings\n\ hang on rack after rack. Silken gowns, capes woven with spun gold, and \n\ -delicate synthetic fabrics are stowed here. The bedroom is +.***\n"}, +delicate synthetic fabrics are stowed here. The bedroom is +.***\n", {0} }, + /* 9 */ {"You are in a wide hallway leading to the main hangar.", {0, 0, 11, 1, 0, 0, 0, 0}, "The walls and ceiling here have been blasted through in several places.\n\ It looks as if quite a battle has been fought for possession of the landing bay\n\ Gaping corpses litter the floor.** The hallway continues +.\n\ -The main hangar is +.\n"}, +The main hangar is +.\n", {0} }, + /* 10 */ {"You are in a wide hallway leading to the landing bay.", {0, 0, 12, 2, 0, 0, 0, 0}, "Most of the men and supplies needed in the main hangar come through this\n\ corridor, but the wounded are forced to use it too. It very dank and\n\ crowded here, and the floor is slippery with blood.**\n\ -The hallway continues -. The landing bay is +.\n"}, +The hallway continues -. The landing bay is +.\n", {0} }, + /* 11 */ {"The hallway is very congested with rubble here.", {0, 0, 0, 9, 13, 1, 0, 0}, "It is too choked with broken steel girders and other debris to continue\n\ on much farther. Above, the ceiling has caved in and it is possible to \n\ climb up. There is not much chance to go -, -, or -.\n\ -But the hallway seems clearer +.\n"}, +But the hallway seems clearer +.\n", {0} }, + /* 12 */ {"A wide hallway and a more narrow walkway meet here.", {14, 15, 0, 10, 0, 0, 0, 0}, "The intersection is crowded with the many wounded who have come up\n\ the wide hallway and continued +. The walkway is less crowded +.\n\ -The wide hallway goes *-.\n"}, +The wide hallway goes *-.\n", {0} }, + /* 13 */ {"You are in what was once an elegant stateroom.", {16, 0, 0, 0, 0, 0, 11, 0}, "Whoever lived in this stateroom, he and his female companion\n\ were mercilessly slain in their sleep. Clothes, trinkets and personal\n\ belongings are scattered all across the floor. Through a hole in the\n\ -collapsed floor I can see a hallway below. A door is +.***\n"}, +collapsed floor I can see a hallway below. A door is +.***\n", {0} }, + /* 14 */ {"You're at the entrance to the sick bay.", {17, 12, 18, 0, 0, 0, 0, 0}, "The wounded are entering the sick bay in loudly moaning files.\n\ The walkway continues - and +. A doctor is motioning for you to \n\ -come to the -. *\n"}, +come to the -. *\n", {0} }, + /* 15 */ {"You're in the walkway.", {12, 19, 0, 0, 0, 0, 0, 0}, "Most of the men and supplies were coming from the armory. The walkway\n\ -continues -. The armory is +.**\n"}, +continues -. The armory is +.**\n", {0} }, + /* 16 */ {"These are the executive suites of the battlestar.", {20, 13, 21, 22, 23, 1, 24, 0}, "Luxurious staterooms carpeted with crushed velvet and adorned with beaten\n\ gold open onto this parlor. A wide staircase with ivory banisters leads\n\ -up or down. This parlor leads into a hallway +. The bridal suite is +.\n\ -Other rooms lie - and +.\n"}, +up or down. This parlor leads into a hallway +. The bridal suite is\n\ ++. Other rooms lie - and +.\n", {0} }, + /* 17 */ {"You're in a long dimly lit hallway.", {0, 14, 25, 0, 0, 0, 0, 0}, "This part of the walkway is deserted. There is a dead end +. The\n\ -entrance to the sickbay is +. The walkway turns sharply -.*\n"}, +entrance to the sickbay is +. The walkway turns sharply -.*\n", {0} }, + /* 18 */ {"This is the sick bay.", {0, 0, 0, 14, 0, 0, 0, 0}, "Sinister nurses with long needles and pitiful aim probe the depths of suffering\n\ here. Only the mortally wounded receive medical attention on a battlestar,\n\ but afterwards they are thrown into the incinerators along with the rest.**\n\ -Nothing but death and suffering +. The walkway is +.\n"}, +Nothing but death and suffering +. The walkway is +.\n", {0} }, + /* 19 */ {"You're in the armory.", {15, 26, 0, 0, 0, 0, 0, 0}, "An armed guard is stationed here 365 sectars a yarn to protect the magazine.\n\ -The walkway is +. The magazine is +.**\n"}, +The walkway is +. The magazine is +.**\n", {0} }, + /* 20 */ {"The hallway ends here at the presidential suite.", {27, 16, 0, 0, 0, 0, 0, 0}, "The door to this suite is made from solid magnesium, and the entryway is\n\ inlaid with diamonds and fire opals. The door is ajar +. The hallway\n\ -goes -.**\n"}, +goes -.**\n", {0} }, + /* 21 */ {"This is the maid's utility room.", {0, 0, 0, 16, 0, 0, 0, 0}, "What a gruesome sight! The maid has been brutally drowned in a bucket of\n\ Pine Sol and repeatedly stabbed in the back with a knife.***\n\ -The hallway is +.\n"}, +The hallway is +.\n", {0} }, + /* 22 */ {"This is a luxurious stateroom.", {0, 8, 16, 0, 0, 0, 0, 0}, "The floor is carpeted with a soft animal fur and the great wooden furniture\n\ @@ -161,1052 +183,1305 @@ is inlaid with strips of platinum and gold. Electronic equipment built\n\ into the walls and ceiling is flashing wildly. The floor shudders and\n\ the sounds of dull explosions rumble though the room. From a window in\n\ the wall + comes a view of darkest space. There is a small adjoining\n\ -room +, and a doorway +.*\n"}, +room +, and a doorway +.*\n", {0} }, + /* 23 */ {"You are at the entrance to the dining hall.", {0, 0, 28, 0, 0, 0, 16, 0}, "A wide staircase with ebony banisters leads down here.**\n\ -The dining hall is to the -.*\n"}, +The dining hall is -.*\n", {0} }, + /* 24 */ {"This was once the first class lounge.", {0, 0, 29, 0, 16, 1, 0, 0}, "There is much rubble and destruction here that was not apparent elsewhere.\n\ The walls and ceilings have broken in in some places. A staircase with\n\ red coral banisters leads up. It is impossible to go - or -.\n\ -It seems a little clearer +.*\n"}, +It seems a little clearer +.*\n", {0} }, + /* 25 */ {"You are in a narrow stairwell.", {0, 17, 0, 0, 30, 1, 0, 0}, "These dusty and decrepit stairs lead up. There is no way -. The\n\ -hallway turns sharply -.**\n"}, +hallway turns sharply -.**\n", {0} }, + /* 26 */ {"You are in the magazine.", {19, 0, 0, 0, 0, 0, 0, 0}, "Rows and rows of neatly stacked ammunition for laser pistols and grenade\n\ -launchers are here. The armory is +.***\n"}, +launchers are here. The armory is +.***\n", {0} }, + /* 27 */ {"You're in the presidential suite.", {0, 20, 0, 0, 0, 0, 0, 0}, "Apparently the president has been assassinated. A scorched figure lies\n\ face downward on the carpet clutching his chest.*\n\ -The hallway leads -.**\n"}, +The hallway leads -.**\n", {0} }, + /* 28 */ {"You are in the dining hall.", {0, 30, 31, 23, 0, 0, 0, 0}, "This was the scene of a mass suicide. Hundreds of ambassadors and assorted\n\ dignitaries sit slumped over their breakfast cereal. I suppose the news\n\ of the cylon attack killed them. There is a strange chill in this room. I\n\ -would not linger here. * The kitchen is +. Entrances + and +.\n"}, +would not linger here. * The kitchen is +. Entrances + and +.\n", {0} }, + /* 29 */ {"The debris is very thick here.", {0, 11, 0, 24, 0, 0, 0, 0}, "Broken furniture, fallen girders, and other rubble block the way.\n\ There is not much chance to continue -, -, or -.\n\ -It would be best to go -.\n"}, +It would be best to go -.\n", {0} }, + /* 30 */ {"You are in the kitchen.", {28, 0, 0, 0, 0, 0, 0, 0}, "This room is full of shining stainless steel and burnished bronze cookware. An \n\ assortment of tropical fruits and vegetables as well as fine meats and cheeses \n\ lies on a sterling platter. The chef, unfortunately, has been skewered like a \n\ -side of beef. The dining room is +. ** There is a locked door +.\n"}, +side of beef. The dining room is +. ** There is a locked door +.\n", {0} }, + /* 31 */ {"You are in an arched entry leading to the dining room.", {0, 0, 0, 28, 0, 0, 0, 0}, "The door leading out is bolted shut from the outside and is very strong.***\n\ -The dining room is +.\n"}, +The dining room is +.\n", {0} }, + /* 32 */ {"You are in space.", {33, 34, 35, 36, 37, 1, 33, 1}, - "****\n"}, + "****\n", {0} }, + /* 33 */ {"You are in space.", {38, 32, 39, 40, 41, 1, 42, 1}, - "****\n"}, + "****\n", {0} }, + /* 34 */ {"You are in space.", {32, 44, 45, 46, 47, 1, 48, 1}, - "****\n"}, + "****\n", {0} }, + /* 35 */ {"You are in space.", {40, 45, 49, 32, 50, 1, 51, 1}, - "****\n"}, + "****\n", {0} }, + /* 36 */ {"You are in space.", {41, 46, 32, 52, 53, 1, 54, 1}, - "****\n"}, + "****\n", {0} }, + /* 37 */ {"You are in space.", {42, 47, 50, 53, 55, 1, 32, 1}, - "****\n"}, + "****\n", {0} }, + /* 38 */ {"You are in space.", {43, 48, 51, 54, 32, 1, 56, 1}, - "****\n"}, + "****\n", {0} }, + /* 39 */ {"You are in space.", {57, 33, 40, 41, 42, 1, 43, 1}, - "****\n"}, + "****\n", {0} }, + /* 40 */ {"You are in space.", {39, 35, 57, 33, 58, 1, 59, 1}, - "****\n"}, + "****\n", {0} }, + /* 41 */ {"You are in space.", {39, 36, 33, 59, 60, 1, 61, 1}, - "****\n"}, + "****\n", {0} }, + /* 42 */ {"You are in space.", {39, 37, 58, 60, 62, 1, 33, 1}, - "****\n"}, + "****\n", {0} }, + /* 43 */ {"You are in space.", {39, 38, 59, 61, 33, 1, 63, 1}, - "****\n"}, + "****\n", {0} }, + /* 44 */ {"You are in space.", {34, 64, 45, 46, 47, 1, 48, 1}, - "****\n"}, + "****\n", {0} }, + /* 45 */ {"You are in space.", {35, 44, 49, 34, 50, 1, 51, 1}, - "****\n"}, + "****\n", {0} }, + /* 46 */ {"You are in space.", {36, 44, 34, 52, 53, 1, 54, 1}, - "****\n"}, + "****\n", {0} }, + /* 47 */ {"You are in space.", {37, 44, 50, 53, 55, 1, 34, 1}, - "****\n"}, + "****\n", {0} }, + /* 48 */ {"You are in space.", {38, 44, 51, 54, 34, 1, 56, 1}, - "****\n"}, + "****\n", {0} }, + /* 49 */ {"You are in space.", {49, 49, 52, 35, 49, 1, 49, 1}, - "****\n"}, + "****\n", {0} }, + /* 50 */ {"You are in space.", {58, 47, 49, 37, 55, 1, 35, 1}, - "****\n"}, + "****\n", {0} }, + /* 51 */ {"You are in space.", {59, 48, 49, 38, 35, 1, 56, 1}, - "****\n"}, + "****\n", {0} }, + /* 52 */ {"You are in space.", {52, 52, 36, 49, 52, 1, 52, 1}, - "****\n"}, + "****\n", {0} }, + /* 53 */ {"You are in space.", {60, 46, 37, 52, 55, 1, 36, 1}, - "****\n"}, + "****\n", {0} }, + /* 54 */ {"You are in space.", {61, 48, 38, 52, 36, 1, 56, 1}, - "****\n"}, + "****\n", {0} }, + /* 55 */ {"You are in space.", {62, 55, 55, 55, 56, 1, 37, 1}, - "****\n"}, + "****\n", {0} }, + /* 56 */ {"You are in space.", {56, 56, 56, 56, 38, 1, 55, 1}, - "****\n"}, + "****\n", {0} }, + /* 57 */ {"You are in space.", {65, 39, 57, 57, 57, 1, 57, 1}, - "****\n"}, + "****\n", {0} }, + /* 58 */ {"You are in space.", {39, 50, 49, 42, 62, 1, 40, 1}, - "****\n"}, + "****\n", {0} }, + /* 59 */ {"You are in space.", {39, 51, 49, 43, 40, 1, 63, 1}, - "****\n"}, + "****\n", {0} }, + /* 60 */ {"You are in space.", {39, 53, 43, 59, 62, 1, 41, 1}, - "****\n"}, + "****\n", {0} }, + /* 61 */ {"You are in space.", {39, 54, 43, 59, 41, 1, 56, 1}, - "****\n"}, + "****\n", {0} }, + /* 62 */ {"You are in space.", {39, 55, 62, 62, 56, 1, 42, 1}, - "****\n"}, + "****\n", {0} }, + /* 63 */ {"You are in space.", {39, 56, 35, 36, 43, 1, 55, 1}, - "****\n"}, + "****\n", {0} }, + /* 64 */ {"You are in space.", {44, 66, 66, 66, 66, 1, 66, 1}, - "****\n"}, + "****\n", {0} }, + /* 65 */ {"You are in space.", {67, 57, 67, 67, 67, 1, 67, 1}, - "****\n"}, + "****\n", {0} }, + /* 66 */ {"You are in space.", {64, 68, 68, 68, 68, 1, 68, 1}, - "****\n"}, + "****\n", {0} }, + /* 67 */ {"You are orbiting a small blue planet.", {67, 67, 67, 67, 65, 1, 69, 1}, - "****\n"}, + "****\n", {0} }, + /* 68 */ {"You are orbiting a tropical planet.", {68, 68, 68, 68, 66, 1, 70, 1}, - "****\n"}, + "****\n", {0} }, + /* 69 */ {"You are flying through a dense fog.", {69, 69, 69, 69, 69, 1, 69, 1}, "A cold grey sea of mist is swirling around the windshield and water droplets\n\ are spewing from the wingtips. Ominous shadows loom in the darkness and it\n\ feels as if a trap is closing around us. I have lost all sense of direction.\n\ -****\n"}, +****\n", {0} }, + /* 70 */ {"You are approaching an island.", {71, 72, 73, 74, 68, 1, 0, 1}, "Coconut palms, sword ferns, orchids, and other lush vegetation drape this\n\ jagged island carved seemingly from pure emerald and set in a turquoise\n\ -sea. The land rises sharply +. There is a nice beach* +.*\n"}, +sea. The land rises sharply +. There is a nice beach* +.*\n", {0} }, + /* 71 */ {"You are flying over a mountainous region.", {75, 73, 76, 77, 68, 1, 0, 1}, "Below is a magnificent canyon with deep gorges, high pinnacles and\n\ waterfalls plummeting hundreds of feet into mist. Everything in sight\n\ -is carpeted with a tropical green.* The ocean is +.**\n"}, +is carpeted with a tropical green.* The ocean is +.**\n", {0} }, + /* 72 */ {"You are flying over the ocean.", {74, 78, 78, 78, 68, 1, 0, 1}, "You bank over the water and your wingtips dip low to the green waves. The\n\ sea is very shallow here and the white coral beds beneath us teem with \n\ -colorful fish.****\n"}, +colorful fish.****\n", {0} }, + /* 73 */ {"You are flying over the beach.", {71, 72, 79, 74, 68, 1, 80, 1}, "A warm gentle surf caresses the white coral beach here. The land rises\n\ -sharply +.* The beach is lost in low cliffs and rocks +.*\n"}, +sharply +.* The beach is lost in low cliffs and rocks +.*\n", {0} }, + /* 74 */ {"You are flying over a large lagoon.", {81, 72, 73, 82, 68, 1, 0, 1}, "Encircled by a coral reef, the palms and ferns in this sheltered spot\n\ have grown down to the water's very brink which winds tortuously inland.\n\ -There looks like a small village +.***\n"}, +There looks like a small village +.***\n", {0} }, + /* 75 */ {"You are flying over a gently sloping plane.", {83, 71, 84, 85, 68, 1, 0, 1}, "This is where several alluvial fans and ancient lava flows have run\n\ together forming a fertile plane choked with vegetation. It would be\n\ -impossible to land safely here.* The terrain is more rugged +.**\n"}, +impossible to land safely here.* The terrain is more rugged +.**\n", {0} }, + /* 76 */ {"You are flying through a gorge.", {0, 0, 86, 71, 68, 1, 102, 1}, "This narrow, steep sided canyon is lined with waving ferns. The floor is of\n\ light gravel with many freshets pouring from the walls and running along it.\n\ -The gorge leads to the sea** +, and to a tumultuous origin +.\n"}, +The gorge leads to the sea** +, and to a tumultuous origin +.\n", {0} }, + /* 77 */ {"You are flying over a plantation.", {85, 81, 71, 88, 68, 1, 89, 1}, "Rows of palms, papayas, mangoes, kiwi, as well as smaller fields of sugar\n\ cane and pineapple are growing here. It might be possible to land here, but\n\ I wouldn't advise it.* There looks like two small settlements + \n\ -and *+.\n"}, +and *+.\n", {0} }, + /* 78 */ {"You are over the ocean.", {72, 78, 79, 74, 68, 1, 0, 1}, - "The deep green swells foam and roll into the shore **+*.\n"}, + "The deep green swells foam and roll into the shore **+*.\n", {0} }, + /* 79 */ {"You are flying along the coast.", {86, 72, 90, 73, 68, 1, 91, 1}, "The coastline here is very rocky with little or no sand. The surf in some\n\ places is violent and explodes in a shower of sparkling spray.\n\ -There is a winding road below which closely follows the shore. ****\n"}, +There is a winding road below which closely follows the shore. ****\n", {0} }, + /* 80 */ {"This is a beautiful coral beach.", {106, 0, 107, 108, 73, 0, 0, 0}, "Fine silver sand kissed lightly by warm tropical waters stretches at least\n\ -30 meters here from the ocean to under gently swaying palms +.***\n"}, +30 meters here from the ocean to under gently swaying palms +.***\n", {0} }, + /* 81 */ {"You are flying over a small fishing village.", {77, 74, 71, 82, 68, 1, 92, 1}, "A few thatched huts a short distance from the water and row of more modern\n\ bungalows on either side of a dirt road are all that is here. The road\n\ -continues on ***+.\n"}, +continues on ***+.\n", {0} }, + /* 82 */ {"You are flying over a clearing.", {88, 72, 74, 87, 68, 1, 93, 1}, "There is a dock here (big enough for a seaplane) leading to a grassy\n\ meadow and a road. Some people are having a party down there. Below is\n\ -a good landing site. ****\n"}, +a good landing site. ****\n", {0} }, + /* 83 */ {"You are flying over the shore.", {94, 75, 95, 96, 68, 1, 0, 1}, "Rocky lava flows or coarse sandy beaches are all that is here except for\n\ -sparse herbs and weeds.****\n"}, +sparse herbs and weeds.****\n", {0} }, + /* 84 */ {"You are flying in a wide valley.", {95, 97, 86, 75, 68, 1, 98, 1}, "This is a shallow valley yet the floor is obscured by a thick mist.\n\ -The valley opens to the sea +. The mist grows thicker +.**\n"}, +The valley opens to the sea +. The mist grows thicker +.**\n", {0} }, + /* 85 */ {"You are flying near the shore.", {96, 77, 75, 99, 68, 1, 0, 1}, "Very tall palm trees growing in neatly planted rows march off from the \n\ water here towards the hills and down to the flat lands *+.*\n\ -There is a nice beach +.\n"}, +There is a nice beach +.\n", {0} }, + /* 86 */ {"You are flying around the very tip of the island.", {95, 79, 90, 84, 68, 1, 0, 1}, "There is no beach here for sheer cliffs rise several hundred feet\n\ to a tree covered summit. Far below, the blue sea gnaws voraciously at\n\ -the roots of these cliffs. The island bends around +** and +.\n"}, +the roots of these cliffs. The island bends around +** and +.\n", {0} }, + /* 87 */ {"You are flying along the coastline.", {99, 82, 88, 100, 68, 1, 101, 1}, "There is a narrow strip of sand here lined with ferns and shrubs, but very\n\ few trees. The beach is barley wide enough to land on. The beach continues\n\ -on -.* There are some buildings +.*\n"}, +on -.* There are some buildings +.*\n", {0} }, + /* 88 */ {"You are flying over several cottages and buildings", {99, 82, 77, 87, 68, 1, 103, 1}, "The grounds here are landscaped with palm trees, ferns, orchids, and beds of\n\ flowering plumeria and antheriums. Directly below is a small ornate white\n\ house with a belltower, a lush green lawn, and a spurting fountain.\n\ -Small dirt roads go + and +.**\n"}, +Small dirt roads go + and +.**\n", {0} }, + /* 89 */ {"You are in a field of sugar cane.", {109, 110, 111, 112, 77, 0, 0, 0}, "These strong, thick canes give little shelter but many cuts and scrapes.\n\ -There are some large trees ***+.\n"}, +There are some large trees ***+.\n", {0} }, + /* 90 */ {"You are flying over the ocean.", {95, 78, 90, 86, 68, 1, 0, 1}, "The water is a placid turquoise and so clear that fish and sharks\n\ -many fathoms below are clearly visible.****\n"}, +many fathoms below are clearly visible.****\n", {0} }, + /* 91 */ {"You are on the coast road.", {113, 114, 115, 116, 79, 0, 0, 0}, "The road winds close to the shore here and the sound of crashing surf is\n\ -deafening.* The water is +. The road continues - and -.\n"}, +deafening.* The water is +. The road continues - and -.\n", {0} }, + /* 92 */ {"You are on the main street of the village.", {117, 118, 119, 120, 81, 0, 0, 0}, "Thatched roofs and outrigger canoes, palm trees and vacation bungalows, and\n\ comely natives in a tropical paradise all make this a fantasy come true.\n\ -There is an open bungalow +.* The road continues - and -.\n"}, +There is an open bungalow +.* The road continues - and -.\n", {0} }, + /* 93 */ {"You are at the sea plane dock.", {121, 122, 123, 124, 82, 0, 0, 0}, "Native girls with skin of gold, clad only in fragrant leis and lavalavas,\n\ -line the dockside to greet you. A couple of ukulele plucking islanders and a\n\ +line the dockside to greet you. A couple of ukulele=plucking islanders and a\n\ keyboard player are adding appropriate music. A road crosses the clearing \n\ -+*. There are some tables set up +.*\n"}, ++*. There are some tables set up +.*\n", {0} }, + /* 94 */ {"You are flying over the ocean.", {94, 83, 95, 96, 68, 1, 0, 1}, "Sea weeds and kelp surge in the waves off shore here. The ocean becomes \n\ -much deeper +.***\n"}, +much deeper +.***\n", {0} }, + /* 95 */ {"You are flying along the coast.", {94, 84, 86, 83, 68, 1, 0, 1}, "The land is very low here with a river running into the sea +. There\n\ -is a wide valley opening up +. The very tip of the island is +.*\n"}, +is a wide valley opening up +. The very tip of the island is +.*\n", {0} }, + /* 96 */ {"You are flying along the coast.", {94, 85, 83, 99, 68, 1, 0, 1}, "There are some secluded sandy stretches of beach here, but too many rocky\n\ -outcroppings of lava to land. There is a nicer beach ***+.\n"}, +outcroppings of lava to land. There is a nicer beach ***+.\n", {0} }, + /* 97 */ {"You are lost in a sea of fog.", {97, 104, 97, 97, 97, 1, 0, 1}, "What have you gotten us into?\n\ -I can't see a thing! ****\n"}, +I can't see a thing! ****\n", {0} }, + /* 98 */ {"You are on a gravel wash.", {125, 126, 127, 128, 84, 0, 0, 0}, "The sound of cascading water is the background for a diluted chorus of \n\ gurgling, splashing, and enchantingly delicate singing. Great billows\n\ -of steam are rising *+.**\n"}, +of steam are rising *+.**\n", {0} }, + /* 99 */ {"You are flying over a wide beach.", {96, 88, 85, 87, 68, 1, 105, 1}, "Unlike the leeward beaches, few coconut palms grow here but a well groomed\n\ lawn and garden with traipsing stone walks leads down to the sand.*\n\ -There are some buildings +. Some trees are growing +.*\n"}, +There are some buildings +. Some trees are growing +.*\n", {0} }, + /* 100 */ {"You are flying over the ocean.", {100, 100, 87, 100, 68, 1, 0, 1}, "The sea is a perfectly clear blue with a white sandy bottom. No coral\n\ grows underwater here, but the force of the waves is broken by the steep\n\ -incline.****\n"}, +incline.****\n", {0} }, + /* 101 */ {"You are on a narrow strip of sand.", {129, 130, 131, 0, 87, 0, 0, 0}, "Rather coarse sand makes this beach very steep and only a few meters wide.\n\ -A fresh ocean breeze is rustling the ferns **+.*\n"}, +A fresh ocean breeze is rustling the ferns **+.*\n", {0} }, + /* 102 */ {"This is Fern Canyon.", {0, 0, 132, 133, 76, 0, 0, 0}, "Delicate waving ferns flourish here, suckled by warm water dripping from \n\ every fissure and crevice in the solid rock walls.\n\ -The canyon winds **-, and -.\n"}, +The canyon winds **-, and -.\n", {0} }, + /* 103 */ {"This is the front lawn.", {134, 135, 136, 137, 88, 0, 0, 0}, "There is a small fountain here where the driveway meets the lawn.\n\ Across the driveway, +, is an ornate white house with and elegant \n\ woodworking. The bargeboards are carved with fylfots, the ancient \n\ symbols of luck. Even a bell tower has been built here.* There is a \n\ -road + which turns into the driveway.*\n"}, +road + which turns into the driveway.*\n", {0} }, + /* 104 */ {"You have just crossed the crest of a mountain.", {97, 79, 86, 71, 68, 1, 0, 1}, "The fog vanished mysteriously as we flew over the crest.*\n\ -Far + I can see the ocean.**\n"}, +Far + I can see the ocean.**\n", {0} }, + /* 105 */ {"You are on a sandy beach.", {138, 139, 140, 0, 99, 0, 0, 0}, "This is the only good beach on the weather side of the island. Fine coral\n\ sand, a fresh sea breeze, and dramatic surf add to its appeal.**\n\ -Stone steps lead to the gardens +.*\n"}, +Stone steps lead to the gardens +.*\n", {0} }, + /* 106 */ {"You are among palm trees near the shore.", {141, 80, 142, 143, 73, 0, 0, 0}, "Arching coconut palms laden with fruit provide a canopy for the glistening\n\ white sand and sparse grasses growing here. The forest grows denser +.\n\ -The ocean is +.**\n"}, +The ocean is +.**\n", {0} }, + /* 107 */ {"You are walking along the beach.", {144, 0, 145, 80, 73, 0, 0, 0}, "The warm tropical waters nuzzle your ankles as you walk. Above is a fiercely\n\ blue sky. The slope of the sand is so gentle that two hundred meters\n\ -offshore the water is only knee deep.** There are some rocks +.*\n"}, +offshore the water is only knee deep.** There are some rocks +.*\n", {0} }, + /* 108 */ {"You are walking along the beach.", {146, 0, 80, 147, 73, 0, 0, 0}, "Many beautiful shells have been washed up here including bright yellow \n\ -cowries, chocolate colored murex, orange conchs, striped tritons and the\n\ -deadly cone shells.****\n"}, +cowries, chocolate colored murex, orange conches, striped tritons and the\n\ +deadly cone shells.****\n", {0} }, + /* 109 */ {"You are in a papaya grove.", {148, 89, 149, 150, 77, 0, 0, 0}, "Green slender trees no taller than three meters bulge with their\n\ -orange succulent fruit. There are some tall trees +.***\n"}, +orange succulent fruit. There are some tall trees +.***\n", {0} }, + /* 110 */ {"You are in a field of pineapple.", {89, 151, 152, 153, 77, 0, 0, 0}, "The sharp dagger like pineapple leaves can pierce the flesh and hold fast\n\ -a skewered victim with tiny barbs.* The field ends +.**\n"}, +a skewered victim with tiny barbs.* The field ends +.**\n", {0} }, + /* 111 */ {"You are in a field of kiwi plants.", {149, 154, 155, 89, 77, 0, 0, 0}, "Round hairy fruit hang from staked vines here. There are some trees +\n\ -and +. The field ends in a dirt road +.*\n"}, +and +. The field ends in a dirt road +.*\n", {0} }, + /* 112 */ {"You are in a large grove of coconuts.", {150, 153, 89, 156, 77, 0, 0, 0}, "These trees are much taller than any growing near the shore plus the fat,\n\ juicy coconuts have been selectively cultivated. The grove continues\n\ -+, +, *and +.\n"}, ++, +, *and +.\n", {0} }, + /* 113 */ {"You are in the woods.", {157, 91, 158, 116, 79, 0, 0, 0}, "Tropical undergrowth makes the going rough here. Sword ferns give no strong\n\ foot hold and the dangling vines would gladly throttle one. Strange cackling\n\ -noises are coming from somewhere +.***\n"}, +noises are coming from somewhere +.***\n", {0} }, + /* 114 */ {"You are at the shore.", {91, 0, 159, 145, 79, 0, 0, 0}, "Explosions of surf jetting out of underwater tunnels here make it\n\ impossible to climb down to a small cave entrance below. Only at rare\n\ -minus tides would it be possible to enter.*** The beach is better +.\n"}, +minus tides would it be possible to enter.*** The beach is better +.\n", {0} }, + /* 115 */ {"You are on the coast road.", {158, 161, 162, 91, 79, 0, 0, 0}, "The road is beginning to turn inland.* I can hear the surf +. The road\n\ -continues +.*\n"}, +continues +.*\n", {0} }, + /* 116 */ {"The road winds deeper into the trees.", {163, 142, 91, 164, 79, 0, 0, 0}, "Only narrow sunbeams filter through the foliage above. The moist rich earth\n\ has nurtured a myriad of trees, shrubs, and flowers to grow here. The\n\ -road continues - and *- from here.*\n"}, +road continues - and *- from here.*\n", {0} }, + /* 117 */ {"This is the front porch of the bungalow.", {165, 92, 0, 0, 81, 0, 0, 0}, "These wooden steps and porch are very bucolic. A little woven mat on the \n\ doorstep reads \"Don't Tread on Me\". The open front door is +.\n\ -A stone walk leads to the main street +.**\n"}, +A stone walk leads to the main street +.**\n", {0} }, + /* 118 */ {"You are on a path leading to the lagoon.", {92, 166, 167, 168, 81, 0, 0, 0}, "This path trampled fern, grass, sapling, and anything else that got in its\n\ -way.* The water is +.**\n"}, +way.* The water is +.**\n", {0} }, + /* 119 */ {"This is a dirt road.", {169, 118, 170, 92, 81, 0, 0, 0}, - "**The road continues on - here for some distance. A village is +.\n"}, + "**The road continues on - here for some distance. A village is +.\n", {0} }, + /* 120 */ {"You are on a dirt road.", {171, 118, 92, 172, 81, 0, 0, 0}, - "**There is a small village +. The road continues +.\n"}, + "**There is a small village +. The road continues +.\n", {0} }, + /* 121 */ {"You are on a dirt road.", {173, 93, 174, 175, 82, 0, 0, 0}, "The light tan soil of the road contrasts artistically with the lush green\n\ -vegetation and seering blue sky.* There is a clearing and many people +.\n\ -The road continues - and -.\n"}, +vegetation and searing blue sky.* There is a clearing and many people +.\n\ +The road continues - and -.\n", {0} }, + /* 122 */ {"You are at the seaplane dock.", {93, 0, 176, 177, 82, 0, 0, 0}, "Several muscular, bronze skinned men greet you warmly as you pass under\n\ a thatched shelter above the dock here. Polynesian hospitality.\n\ -There is a clearing +.* A trail runs around the lagoon + and +.\n"}, +There is a clearing +.* A trail runs around the lagoon + and +.\n", {0} }, + /* 123 */ {"There are some tables on the lawn here.", {121, 122, 123, 93, 82, 0, 0, 0}, "Hors d'oeuvres, canapes, mixed drinks, and various narcotic drugs along with\n\ cartons of Di Gel fill the tables to overflowing. Several other guests are\n\ -conversing and talking excitedly****.\n"}, +conversing and talking excitedly****.\n", {0} }, + /* 124 */ {"You are nosing around in the bushes.", {124, 124, 93, 124, 82, 0, 0, 0}, "There is little here but some old beer cans. You are making fools out of\n\ -us in front of the other guests.** It would be best to go -.*\n"}, +us in front of the other guests.** It would be best to go -.*\n", {0} }, + /* 125 */ {"You are walking in a dry stream bed.", {178, 98, 179, 0, 84, 0, 0, 0}, "The large cobblestones are difficult to walk on. No sunlight reaches\n\ below a white canopy of fog seemingly generated from *+. A dirt path \n\ -along the wash is +. A high bank is impossible to climb +.\n"}, +along the wash is +. A high bank is impossible to climb +.\n", {0} }, + /* 126 */ {"You are at the thermal pools.", {98, 0, 180, 181, 84, 0, 0, 0}, "Several steaming fumaroles and spluttering geysers drenched by icy mountain\n\ waters from a nearby waterfall heat half a dozen natural pools to a\n\ delicious 42 degrees. Enchantingly beautiful singing seems to flow from the\n\ water itself as it tumbles down the falls.*** There is a mossy entrance\n\ -to a cave +.\n"}, +to a cave +.\n", {0} }, + /* 127 */ {"You are in the woods.", {127, 180, 182, 98, 84, 0, 0, 0}, "Coniferous trees girded by wild huckleberries, elderberries, salmonberries\n\ and thimbleberries enjoy a less tropical climate here in the high mountains.\n\ -*The sound of rushing water is coming from +.**\n"}, +*The sound of rushing water is coming from +.**\n", {0} }, + /* 128 */ {"You are on a dirt trail.", {179, 181, 98, 0, 84, 0, 0, 0}, "The trail seems to start here and head -.** High cliffs border the \n\ -trail +.\n"}, +trail +.\n", {0} }, + /* 129 */ {"You are walking along the beach.", {183, 101, 184, 0, 87, 0, 0, 0}, "A rather unnerving surf explodes onto the beach here and dashes itself into\n\ -spray on the steep incline. The beach continues + and +.**\n"}, +spray on the steep incline. The beach continues + and +.**\n", {0} }, + /* 130 */ {"You are walking along the beach.", {101, 185, 186, 0, 87, 0, 0, 0}, - "This is not a very nice beach. The coarse sand hurts my feet.****\n"}, + "This is not a very nice beach. The coarse sand hurts my feet.****\n", {0} }, + /* 131 */ {"You are walking through some ferns.", {184, 186, 187, 101, 87, 0, 0, 0}, "This is a wide field growing only ferns and small shrubs.** The \n\ -ocean is *+.\n"}, +ocean is *+.\n", {0} }, + /* 132 */ {"You are in a narrow canyon.", {0, 0, 188, 102, 76, 0, 0, 0}, "The steep sides here squeeze a little freshet through a gauntlet like\n\ -series of riffles and pools.****\n"}, +series of riffles and pools.****\n", {0} }, + /* 133 */ {"The canyon is much wider here.", {0, 0, 102, 189, 76, 0, 0, 0}, "The sheer rock walls rise 10 meters to the forest above. A slender \n\ waterfall careens away from the face of the rock high above and showers\n\ the gravel floor with sparkling raindrops.** The canyon continues -\n\ -and -.\n"}, +and -.\n", {0} }, + /* 134 */ {"You are on the front porch of the cottage.", {190, 103, 0, 0, 0, 0, 0, 0}, "Several giggling native girls came running down the steps as you approached\n\ and headed on down the road. On the fern rimmed porch is a small table with\n\ matching white wrought iron chairs cushioned with red velvet. The front\n\ -door leads -. The lawn and fountain are +.**\n"}, +door leads -. The lawn and fountain are +.**\n", {0} }, + /* 135 */ {"You are in a palm grove.", {103, 191, 192, 105, 88, 0, 0, 0}, - "****\n"}, + "****\n", {0} }, + /* 136 */ {"You are on a dirt road.", {193, 192, 245, 103, 88, 0, 0, 0}, "There is a large village +. The road cleaves a coconut plantation +.\n\ -A small dirt road goes -, and a drive way peals off +.\n"}, +A small dirt road goes -, and a driveway peels off +.\n", {0} }, + /* 137 */ {"You are in a field of small shrubs.", {184, 186, 103, 187, 88, 0, 0, 0}, "**Pine and other coniferous saplings have been planted here. The rich brown\n\ soil is well tilled and watered. Across a large lawn, there is a small\n\ -cottage +. I can feel a delicious sea breeze blowing from +.\n"}, +cottage +. I can feel a delicious sea breeze blowing from +.\n", {0} }, + /* 138 */ {"The beach is pretty rocky here.", {194, 105, 195, 0, 96, 0, 0, 0}, "Dangerous surf and lava outcroppings make this a treacherous strand.\n\ -The beach is nicer* +.**\n"}, +The beach is nicer* +.**\n", {0} }, + /* 139 */ {"The beach is almost 10 meters wide here.", {105, 183, 196, 0, 99, 0, 0, 0}, "The sand has become more coarse and the beach steeper.* It gets \n\ -worse +.**\n"}, +worse +.**\n", {0} }, + /* 140 */ {"You are in the gardens.", {195, 196, 197, 105, 99, 0, 0, 0}, "Lush green lawns studded with palms and benches stretch as far as the eye\n\ -can see.** A path leads -. Stone steps lead down to the beach +.\n"}, +can see.** A path leads -. Stone steps lead down to the beach +.\n", {0} }, + /* 141 */ {"You are on the coast road.", {198, 106, 163, 199, 73, 0, 0, 0}, "The forest is dense on either side and conceals the road from anyone\n\ -approaching it.** The road continues - and -.\n"}, +approaching it.** The road continues - and -.\n", {0} }, + /* 142 */ {"You are in the forest.", {116, 107, 91, 106, 73, 0, 0, 0}, - "There are trees and ferns all around.****\n"}, + "There are trees and ferns all around.****\n", {0} }, + /* 143 */ {"You are in the forest.", {199, 108, 106, 146, 73, 0, 0, 0}, - "There are trees and ferns all around.****\n"}, + "There are trees and ferns all around.****\n", {0} }, + /* 144 */ {"You are in a copse.", {142, 107, 145, 80, 0, 0, 0, 0}, "This is a secret hidden thicket only noticeable from the beach. Someone\n\ -has been digging here recently.****\n"}, +has been digging here recently.****\n", {0} }, + /* 145 */ {"You are at the tide pools.", {91, 0, 114, 107, 79, 0, 0, 0}, "These rocks and pools are the home for many sea anemones and crustaceans.\n\ -**The surf is very rough +. There is a nice beach +.\n"}, +**The surf is very rough +. There is a nice beach +.\n", {0} }, + /* 146 */ {"You are in the forest.", {199, 108, 143, 0, 73, 0, 0, 0}, "This is a shallow depression sheltered from the wind by a thick growth of \n\ thorny shrubs. It looks like someone has camped here. There is a fire pit\n\ with some dry sticks and grass nearby.* The beach is +.* The thorny\n\ -shrubs block the way -.\n"}, +shrubs block the way -.\n", {0} }, + /* 147 */ {"You are at the mouth of the lagoon.", {200, 0, 108, 201, 74, 0, 0, 0}, "The beach ends here where the coral reef rises to form a wide lagoon\n\ bending inland. A path winds around the lagoon to the -.*\n\ -The beach continues on -. Only water lies +.\n"}, +The beach continues on -. Only water lies +.\n", {0} }, + /* 148 */ {"You are in a breadfruit grove.", {202, 109, 203, 204, 77, 0, 0, 0}, "The tall trees bend leisurely in the breeze, holding many round breadfruits\n\ close to their large serrated leaves. There are coconut palms +,\n\ -*+, and +.\n"}, +*+, and +.\n", {0} }, + /* 149 */ {"You are in a grove of mango trees.", {203, 111, 205, 109, 77, 0, 0, 0}, "The juicy yellow red fruits are nearly ripe on the trees here. There are\n\ -some coconut palms +. There are some vines +. There is a road +.*\n"}, +some coconut palms +. There are some vines +. There is a road +.*\n", {0} }, + /* 150 */ {"You are in a grove of coconut palms.", {204, 112, 109, 206, 77, 0, 0, 0}, - "All I can see around us are palm trees.****\n"}, + "All I can see around us are palm trees.****\n", {0} }, + /* 151 */ {"You are in a coconut grove.", {110, 207, 208, 209, 77, 0, 0, 0}, - "There are countless trees here.****\n"}, + "There are countless trees here.****\n", {0} }, + /* 152 */ {"You are in a field of pineapple.", {154, 208, 210, 110, 77, 0, 0, 0}, "The sharp leaves are cutting me to ribbons. There is a road **+.\n\ -More pineapple +.\n"}, +More pineapple +.\n", {0} }, + /* 153 */ {"You are in a coconut grove.", {112, 209, 110, 211, 77, 0, 0, 0}, - "There is a field of pineapple **+.*\n"}, + "There is a field of pineapple **+.*\n", {0} }, + /* 154 */ {"You are on the edge of a kiwi and pineapple field.", {111, 152, 155, 110, 77, 0, 0, 0}, - "An irrigation ditch separates the two fields here. There is a road **+.*\n"}, + "An irrigation ditch separates the two fields here. There is a road **+.*\n", {0} }, + /* 155 */ {"This is a dirt road.", {205, 210, 212, 111, 77, 0, 0, 0}, - "The road runs - and - here.**\n"}, + "The road runs - and - here.**\n", {0} }, + /* 156 */ {"You are in a palm grove.", {206, 211, 112, 213, 77, 0, 0, 0}, - "There are palm trees all around us.****\n"}, + "There are palm trees all around us.****\n", {0} }, + /* 157 */ {"You are on the edge of a small clearing.", {157, 113, 157, 157, 79, 0, 0, 0}, "The ground is rather marshy here and darting in and out of the many tussocks\n\ -is a flock of wild chicken like fowl.****\n"}, +is a flock of wild chicken like fowl.****\n", {0} }, + /* 158 */ {"You are in the woods.", {158, 115, 215, 113, 79, 0, 0, 0}, - "You have walked a long way and found only trees. ****\n"}, + "You have walked a long way and found only trees. ****\n", {0} }, + /* 159 */ {"You are walking along the shore.", {115, 0, 214, 114, 86, 0, 0, 0}, "You are now about 10 meters above the surf on a gently rising cliffside.**\n\ -The land rises +. There is a beach far +.\n"}, +The land rises +. There is a beach far +.\n", {0} }, + /* 160 */ {"You are just inside the entrance to the sea cave.", {246, 114, 0, 0, 114, 1, 0, 0}, "The sound of water dripping in darkness and the roar of the ocean just outside\n\ create a very unwelcoming atmosphere inside this cave. Only on rare occasions\n\ such as this is it possible to enter the forbidden catacombs... The cave\n\ -continues -.***\n"}, +continues -.***\n", {0} }, + /* 161 */ {"You are in a secret nook beside the road.", {115, 159, 162, 91, 79, 0, 0, 0}, "Hidden from all but the most stalwart snoopers are some old clothes, empty\n\ beer cans and a trash baggie full of used Huggies and ordure. Lets get\n\ -back to the road +.***\n"}, +back to the road +.***\n", {0} }, + /* 162 */ {"You are on the coast road.", {215, 214, 0, 115, 86, 0, 0, 0}, "The road turns abruptly - here, avoiding the cliffs near the shore\n\ -+ and +.*\n"}, ++ and +.*\n", {0} }, + /* 163 */ {"You are on a dirt road.", {216, 116, 113, 141, 79, 0, 0, 0}, "The roadside is choked with broad leaved plants fighting for every breath of\n\ sunshine. The palm trees are taller than at the shore yet bend over the road \n\ -forming a canopy. The road continues *- and *-.\n"}, +forming a canopy. The road continues *- and *-.\n", {0} }, + /* 164 */ {"You have discovered a hidden thicket near the road.", {163, 142, 116, 106, 73, 0, 0, 0}, "Stuffed into a little bundle here is a bloody silken robe and many beer cans.\n\ *Some droplets of blood and a major spill sparkle farther +.\n\ -The road is +.*\n"}, +The road is +.*\n", {0} }, + /* 165 */ {"You are in the living room.", {0, 117, 217, 218, 0, 0, 0, 0}, "A decorative entry with fresh flowers and wall to wall carpeting leads into\n\ -the living room here where a couch and two chairs converse with an end table.\n\ -*The exit is +.* The bedroom is +.\n"}, +the living room here where a couch and two chairs converge with an end table.\n\ +*The exit is +.* The bedroom is +.\n", {0} }, + /* 166 */ {"You are at the lagoon.", {118, 0, 167, 168, 81, 0, 0, 0}, "There are several outrigger canoes pulled up on a small beach here and a\n\ catch of colorful fish is drying in the sun. There are paths leading \n\ -off -*, -, and -.\n"}, +off -*, -, and -.\n", {0} }, + /* 167 */ {"You are at the lagoon.", {118, 0, 170, 166, 81, 0, 0, 0}, - "This is a grassy little spot near the water. A sightly native girl is frolicing\n\ -in the water close to shore here.** The path continues - and -. \n"}, + "This is a grassy little spot near the water. A sightly native girl is frolicking\n\ +in the water close to shore here.** The path continues - and -. \n", {0} }, + /* 168 */ {"You are at the lagoon.", {118, 0, 166, 172, 81, 0, 0, 0}, "The path meanders through tussocks of grass, ferns, and thorny bushes here\n\ -and continues on **- and -.\n"}, +and continues on **- and -.\n", {0} }, + /* 169 */ {"You are in the woods.", {219, 119, 220, 92, 81, 0, 0, 0}, - "There are plenty of ferns and thorny bushes here! ****\n"}, + "There are plenty of ferns and thorny bushes here! ****\n", {0} }, + /* 170 */ {"You are on a dirt road.", {220, 167, 199, 119, 74, 0, 0, 0}, "The road winds rather close to a large lagoon here and many sedges and tall\n\ -grasses line the shoulder *+. The road continues - and -.\n"}, +grasses line the shoulder *+. The road continues - and -.\n", {0} }, + /* 171 */ {"You are in the woods beside the road.", {221, 120, 92, 222, 81, 0, 0, 0}, - "The forest grows darker +. The road is +.**\n"}, + "The forest grows darker +. The road is +.**\n", {0} }, + /* 172 */ {"The road crosses the lagoon here.", {222, 0, 120, 174, 81, 0, 0, 0}, "Coursing through the trees, the road at this point bridges a watery finger\n\ -of the lagoon.* The water is +. The road continues - and -.\n"}, +of the lagoon.* The water is +. The road continues - and -.\n", {0} }, + /* 173 */ {"You are in a coconut palm grove.", {223, 121, 224, 225, 82, 0, 0, 0}, "The tall palms are planted about 30 feet apart with a hardy deep green grass\n\ filling the spaces in between. There are tire tracks through the grass. The\n\ -grove continues -. There is a road +.**\n"}, +grove continues -. There is a road +.**\n", {0} }, + /* 174 */ {"You are walking along a dirt road.", {224, 176, 172, 121, 82, 0, 0, 0}, - "You are nearing the lagoon.** The road continues - and -.\n"}, + "You are nearing the lagoon.** The road continues - and -.\n", {0} }, + /* 175 */ {"You are on a dirt road.", {225, 177, 121, 226, 82, 0, 0, 0}, "The road turns abruptly - here, entering a grove of palm trees.* The road\n\ -also continues - toward the lagoon.*\n"}, +also continues - toward the lagoon.*\n", {0} }, + /* 176 */ {"You are on a trail running around the lagoon.", {172, 0, 0, 122, 82, 0, 0, 0}, "The dark waters brush the trail here and the path crosses a bridge +.\n\ -There is deep water + and +. The trail continues -.\n"}, +There is deep water + and +. The trail continues -.\n", {0} }, + /* 177 */ {"This is the mouth of the lagoon.", {175, 0, 122, 227, 82, 0, 0, 0}, "The coral reef wraps around a natural bay here to create a wide lagoon which\n\ winds tortuously inland.** A trail goes around the lagoon +. The beach\n\ -is +.\n"}, +is +.\n", {0} }, + /* 178 */ {"You are in a dry stream bed.", {0, 125, 0, 0, 84, 0, 0, 0}, "The dry wash drains over a tall precipice here into a turbid morass below. The\n\ most noisome stench imaginable is wafting up to defile our nostrils. Above,\n\ the lurid sun glows brown through a strange mist.* The only direction \n\ -I'm going is -.**\n"}, +I'm going is -.**\n", {0} }, + /* 179 */ {"You are on a dirt path along the wash.", {0, 128, 125, 228, 84, 0, 0, 0}, - "This path looks more like a deer trail. It scampers away ***+.\n"}, + "This path looks more like a deer trail. It scampers away ***+.\n", {0} }, + /* 180 */ {"The thermal pools flow into a stream here.", {127, 0, 229, 126, 84, 0, 0, 0}, "The gurgling hot waters pour over boulders into a swiftly flowing\n\ -stream **+. The pools are +.\n"}, +stream **+. The pools are +.\n", {0} }, + /* 181 */ {"You are at the entrance to a cave.", {128, 230, 126, 0, 84, 0, 0, 0}, "A tall narrow fissure in the rock cliffs here has become a well traveled\n\ passage way. A hoof beaten dirt path leads directly into it. A curl of\n\ steam is trailing from a corner of the fissure's gaping mouth. The path\n\ -leads - and -. The pools are +.*\n"}, +leads - and -. The pools are +.*\n", {0} }, + /* 182 */ {"You are in the woods.", {182, 229, 182, 127, 84, 0, 0, 0}, "Wild berry bushes plump with fruit and thorns tangle your every effort to\n\ -proceed.* The sound of rushing water is +.**\n"}, +proceed.* The sound of rushing water is +.**\n", {0} }, + /* 183 */ {"You are walking along the beach.", {139, 129, 184, 0, 99, 0, 0, 0}, "Some dunes here progress inland and make it impossible to get very far in that\n\ -direction. The beach continues - and -.* The ocean is +.\n"}, +direction. The beach continues - and -.* The ocean is +.\n", {0} }, + /* 184 */ {"You are in the dunes.", {183, 101, 184, 129, 87, 0, 0, 0}, "The endless rolling and pitching sand dunes are enough to make one very queasy!\n\ -The only way I'm going is ***+.\n"}, +The only way I'm going is ***+.\n", {0} }, + /* 185 */ {"This is a lousy beach.", {130, 0, 0, 0, 87, 0, 0, 0}, "Volcanic and viciously sharp bitted grains of sand here bite like cold steel\n\ into my tender feet. I refuse to continue on. Let's get out of here. The\n\ -beach is better +.***\n"}, +beach is better +.***\n", {0} }, + /* 186 */ {"You are in a field of sparse ferns.", {131, 185, 187, 130, 87, 0, 0, 0}, "The lava rock outcroppings here will support few plants. There is more \n\ -vegetation +. There is a nice beach +.* The ocean is +.\n"}, +vegetation +. There is a nice beach +.* The ocean is +.\n", {0} }, + /* 187 */ {"You are in the woods.", {131, 131, 137, 131, 87, 0, 0, 0}, "Young trees and tall shrubs grow densely together at this distance from the \n\ -shore.** The trees grow thicker +.*\n"}, +shore.** The trees grow thicker +.*\n", {0} }, + /* 188 */ {"The canyon is no wider than a foot here.", {0, 0, 0, 132, 0, 0, 0, 0}, "The freshet is gushing through the narrow trough, but the canyon has grown\n\ -too narrow to follow it any farther.*** I guess we'll have to go -.\n"}, +too narrow to follow it any farther.*** I guess we'll have to go -.\n", {0} }, + /* 189 */ {"You are in a narrow part of the canyon.", {0, 0, 133, 232, 76, 0, 0, 0}, "The two sheer sides are no more than a few meters apart here. There is a stone\n\ door in the wall +. The gravelly floor runs with tiny rivulets seeping \n\ -from the ground itself.* The canyon continues - and -.\n"}, +from the ground itself.* The canyon continues - and -.\n", {0} }, + /* 190 */ {"You are in the drawing room.", {0, 134, 0, 0, 0, 0, 0, 0}, "Exquisitely decorated with plants and antique furniture of superb\n\ -craftsmanship, the parlor reflects its owners impeccable taste. The tropical\n\ +craftsmanship, the parlor reflects its owner's impeccable taste. The tropical\n\ sun is streaming in through open shutters *+. There doesn't seem \n\ to be anybody around. A large immaculate oaken desk is visible in the\n\ -study and it even has a old fashioned telephone to complete the decor.**\n"}, +study and it even has a old fashioned telephone to complete the decor.**\n", {0} }, + /* 191 */ {"You are in a palm grove.", {135, 191, 233, 191, 88, 0, 0, 0}, - "Grassy rows of palms stretch as far as I can see.** There is a road +.*\n"}, + "Grassy rows of palms stretch as far as I can see.** There is a road +.*\n", {0} }, + /* 192 */ {"You are on a dirt road.", {136, 233, 234, 135, 88, 0, 0, 0}, "The road winds through a coconut palm grove here. It continues on - \n\ -and -.**\n"}, +and -.**\n", {0} }, + /* 193 */ {"The road leads to several large buildings here.", {235, 136, 236, 237, 88, 0, 0, 0}, "There is a clubhouse +,* a large barn and stable +, and a garage of \n\ -similar construct to the barn +.\n"}, +similar construct to the barn +.\n", {0} }, + /* 194 */ {"This part of the beach is impassable.", {0, 138, 0, 0, 96, 0, 0, 0}, "The huge rocks and thunderous surf here would pound our frail bodies to pulp\n\ -in an instant.* The only direction I'm going is -.**\n"}, +in an instant.* The only direction I'm going is -.**\n", {0} }, + /* 195 */ {"You are in the gardens.", {195, 140, 197, 138, 96, 0, 0, 0}, - "So much green grass is a pleasure to the eyes.****\n"}, + "So much green grass is a pleasure to the eyes.****\n", {0} }, + /* 196 */ {"You are in the gardens.", {140, 183, 197, 139, 99, 0, 0, 0}, - "Beautiful flowers and shrubs surround a little goldfish pond.****\n"}, + "Beautiful flowers and shrubs surround a little goldfish pond.****\n", {0} }, + /* 197 */ {"You are on a stone walk in the garden.", {195, 196, 238, 140, 99, 0, 0, 0}, - "The walk leads to a road **+.*\n"}, + "The walk leads to a road **+.*\n", {0} }, + /* 198 */ {"You are in the forest near the road.", {198, 141, 216, 198, 73, 0, 0, 0}, - "There are many thorny bushes here!****\n"}, + "There are many thorny bushes here!****\n", {0} }, + /* 199 */ {"You are at a fork in the road.", {239, 146, 141, 170, 73, 0, 0, 0}, "Two roads come together in the forest here. One runs -,* the other \n\ -runs - and -.\n"}, +runs - and -.\n", {0} }, + /* 200 */ {"You are on a dirt path around the lagoon.", {170, 147, 146, 0, 74, 0, 0, 0}, "The still waters reflect bending palms and a cloudless sky. It looks like\n\ -the path runs into a clearing +. The path continues -.**\n"}, +the path runs into a clearing +. The path continues -.**\n", {0} }, + /* 201 */ {"You are drowning in the lagoon.", {201, 201, 147, 201, 74, 0, 0, 0}, - "I suggest you get out before you become waterlogged.****\n"}, + "I suggest you get out before you become waterlogged.****\n", {0} }, + /* 202 */ {"You are in a coconut palm grove.", {202, 148, 203, 204, 77, 0, 0, 0}, - "****\n"}, + "****\n", {0} }, + /* 203 */ {"You are in a palm grove.", {202, 149, 205, 148, 77, 0, 0, 0}, - "****\n"}, + "****\n", {0} }, + /* 204 */ {"You are in a palm grove.", {202, 150, 148, 206, 77, 0, 0, 0}, - "****\n"}, + "****\n", {0} }, + /* 205 */ {"You are on a dirt road.", {203, 155, 212, 149, 77, 0, 0, 0}, "*This road ends here at a palm grove but continues on - for quite\n\ -some way.**\n"}, +some way.**\n", {0} }, + /* 206 */ {"You are in a coconut palm grove.", {204, 156, 150, 213, 77, 0, 0, 0}, - "****\n"}, + "****\n", {0} }, + /* 207 */ {"You are in a coconut grove.", {151, 219, 208, 209, 77, 0, 0, 0}, - "*The grove ends +.**\n"}, + "*The grove ends +.**\n", {0} }, + /* 208 */ {"You are in a coconut grove.", {152, 207, 239, 151, 77, 0, 0, 0}, - "**There is a dirt road +.*\n"}, + "**There is a dirt road +.*\n", {0} }, + /* 209 */ {"You are in a coconut grove.", {153, 207, 151, 211, 77, 0, 0, 0}, - "****\n"}, + "****\n", {0} }, + /* 210 */ {"This is a dirt road.", {205, 239, 212, 154, 77, 0, 0, 0}, - "The road continues - and -.**\n"}, + "The road continues - and -.**\n", {0} }, + /* 211 */ {"You are in a coconut grove.", {153, 209, 153, 213, 77, 0, 0, 0}, - "****\n"}, + "****\n", {0} }, + /* 212 */ {"You are in the woods near the road.", {205, 210, 212, 155, 77, 0, 0, 0}, - "There are many thorny bushes here!****\n"}, + "There are many thorny bushes here!****\n", {0} }, + /* 213 */ {"You are in a coconut grove.", {213, 213, 156, 234, 88, 0, 0, 0}, - "***The grove ends in a clearing +.\n"}, + "***The grove ends in a clearing +.\n", {0} }, + /* 214 */ {"You are walking along some high cliffs.", {162, 0, 0, 159, 86, 0, 0, 0}, "The island bends sharply + here with high cliffs -\n\ -and -. The cliffs are lower +.\n"}, +and -. The cliffs are lower +.\n", {0} }, + /* 215 */ {"You are at the coast road turn around.", {0, 162, 0, 158, 90, 0, 0, 0}, "The coast road ends here in a lookout with a view of 100 kilometers of blue\n\ sea and 100 meters of rugged cliff. Far below the waves crash against rocks.\n\ -****\n"}, +****\n", {0} }, + /* 216 */ {"You are in the woods near the road.", {216, 163, 216, 198, 79, 0, 257, 0}, - "These thorny bushes are killing me.****\n"}, + "These thorny bushes are killing me.****\n", {0} }, + /* 217 */ {"You are in the kitchen.", {0, 0, 0, 165, 0, 0, 0, 0}, "A small gas stove and a refrigerator are all the only appliances here. The\n\ gas oven has been left on and the whole room is reeking with natural gas.\n\ -One spark from a match and.... The door out is ***+.\n"}, +One spark from a match and.... The door out is ***+.\n", {0} }, + /* 218 */ {"You are in the bedroom.", {0, 0, 165, 0, 0, 0, 0, 0}, "A soft feather comforter on top of layers of Answer blankets make this a very\n\ luxurious place to sleep indeed. There are also some end tables and a dresser\n\ -here.** The living room is +.*\n"}, +here.** The living room is +.*\n", {0} }, + /* 219 */ {"You are in the woods.", {207, 169, 220, 221, 81, 0, 0, 0}, - "There seems to be a clearing +.***\n"}, + "There seems to be a clearing +.***\n", {0} }, + /* 220 */ {"You are in the woods near the road.", {219, 170, 239, 169, 81, 0, 0, 0}, - "*As far as I can tell, there are two roads + and +.*\n"}, + "*As far as I can tell, there are two roads + and +.*\n", {0} }, + /* 221 */ {"You are in the woods.", {207, 171, 219, 222, 81, 0, 0, 0}, - "The forest is clearer +.***\n"}, + "The forest is clearer +.***\n", {0} }, + /* 222 */ {"You are on the lagoon's inland finger.", {0, 172, 171, 172, 81, 0, 0, 0}, "It is impossible to follow the lagoon any farther inland because of sharp\n\ -and very painful sedges.* The road is +.**\n"}, +and very painful sedges.* The road is +.**\n", {0} }, + /* 223 */ {"You are in a grassy coconut grove.", {240, 173, 224, 241, 82, 0, 0, 0}, "The tall palms provide a perfect canopy for the lush green grass.***\n\ -There is a road +.\n"}, +There is a road +.\n", {0} }, + /* 224 */ {"You are near the lagoon's inland finger.", {0, 174, 0, 173, 82, 0, 0, 0}, "Very sharp sedges make it impossible to follow the lagoon any farther inland.\n\ -*There is a road +.**\n"}, +*There is a road +.**\n", {0} }, + /* 225 */ {"You are on a dirt road.", {241, 175, 173, 226, 82, 0, 0, 0}, - "The road winds through a coconut grove here and continues - and -.**\n"}, + "The road winds through a coconut grove here and continues - and -.**\n", {0} }, + /* 226 */ {"You are in the woods near the road.", {226, 226, 175, 226, 82, 0, 0, 0}, - "**The road is +.*\n"}, + "**The road is +.*\n", {0} }, + /* 227 */ {"This is a beach?", {227, 227, 177, 0, 82, 0, 0, 0}, "Hard jagged rocks that pierce with every footstep hardly comprise a beach.**\n\ -Let's go -.*\n"}, +Let's go -.*\n", {0} }, + /* 228 */ {"The trail is lost in the woods here.", {241, 241, 179, 241, 84, 0, 0, 0}, "I suppose the animals that use this trail all depart in different directions\n\ -when they get this far into the woods.** The trail goes -.*\n"}, +when they get this far into the woods.** The trail goes -.*\n", {0} }, + /* 229 */ {"You are on the bank of a stream.", {182, 0, 242, 180, 84, 0, 0, 0}, - "The stream falls over several small boulders here and continues on **-.*\n"}, + "The stream falls over several small boulders here and continues on **-.*\n", {0} }, + /* 230 */ {"You are just inside the cave.", {181, 267, 0, 0, 0, 0, 0, 0}, "A steamy hot breath is belching from the depths of the earth within.* The\n\ -cave continues -.**\n"}, +cave continues -.**\n", {0} }, + /* 231 */ {"You are just inside the cave entrance.", {274, 0, 0, 0, 0, 0, 0, 0}, "The air is hot and sticky inside. The cave continues -. There is a \n\ stone door in the wall +. A wooden sign in the dust reads in old elven\n\ -runes, \"GSRF KDIRE NLVEMP!\".**\n"}, +runes, \"GSRF KDIRE NLVEMP!\".**\n", {0} }, + /* 232 */ {"You are at the edge of a huge chasm.", {0, 0, 189, 0, 76, 0, 0, 0}, "Several hundred feet down I can see the glimmer of placid water. The\n\ rivulets drain over the edge and trickle down into the depths. It is \n\ -impossible to climb down without a rope.** The canyon continues -.*\n"}, +impossible to climb down without a rope.** The canyon continues -.*\n", {0} }, + /* 233 */ {"You are on a dirt road.", {192, 241, 240, 191, 88, 0, 0, 0}, "The road winds through a coconut grove here. The road continues on -\n\ -and -.**\n"}, +and -.**\n", {0} }, + /* 234 */ {"You are in a coconut palm grove near the road.", {193, 233, 213, 192, 88, 0, 0, 0}, - "***The road is +.\n"}, + "***The road is +.\n", {0} }, + /* 235 */ {"You are at the clubhouse.", {0, 193, 0, 0, 0, 0, 0, 0}, "The clubhouse is built over the most inland part of the lagoon. Tropical\n\ bananas and fragrant frangipani grow along the grassy shore. Walking across\n\ the short wooden bridge, we enter. Along one wall is a bar with only a few\n\ people seated at it. The restaurant and dance floor are closed off with\n\ -a 2 inch nylon rope. ****\n"}, +a 2 inch nylon rope. ****\n", {0} }, + /* 236 */ {"You are in the stables.", {0, 0, 0, 193, 0, 0, 0, 0}, "Neighing horses snacking on hay and oats fill the stalls on both sides of\n\ the barn. It is rather warm in here but that is not the most offensive\n\ part. The old boards of the barn part just enough to let in dust laden\n\ shafts of light. Flies swarm overhead and strafe the ground for dung.\n\ -My nose is beginning to itch. ****\n"}, +My nose is beginning to itch. ****\n", {0} }, + /* 237 */ {"You are in the old garage.", {0, 0, 193, 0, 0, 0, 0, 0}, "This is an old wooden building of the same vintage as the stables. Beneath\n\ a sagging roof stand gardening tools and greasy rags. Parked in the center\n\ is an underpowered Plymouth Volare' with a red and white striped golf cart\n\ -roof. ****\n"}, +roof. ****\n", {0} }, + /* 238 */ {"You are on a dirt road.", {197, 197, 243, 197, 85, 0, 0, 0}, "The road leads to a beautiful formal garden laced with stone walks and tropical\n\ -flowers and trees.** The road continues -. A walk leads -.\n"}, +flowers and trees.** The road continues -. A walk leads -.\n", {0} }, + /* 239 */ {"You are on a dirt road.", {210, 199, 198, 220, 73, 0, 0, 0}, - "The road runs - and -.**\n"}, + "The road runs - and -.**\n", {0} }, + /* 240 */ {"You are in a coconut grove near the road.", {234, 223, 234, 233, 88, 0, 0, 0}, - "***The road is +.\n"}, + "***The road is +.\n", {0} }, + /* 241 */ {"You are on a dirt road.", {233, 225, 223, 226, 82, 0, 0, 0}, - "The road continues - and -.**\n"}, + "The road continues - and -.**\n", {0} }, + /* 242 */ {"The stream plummets over a cliff here.", {182, 0, 0, 229, 84, 0, 0, 0}, "Falling 10 agonizing meters into spray, only droplets of the stream are\n\ left to dance off the floor below. I thought I saw a sparkle of gold\n\ at the bottom of the falls, but now it is gone. There is no way down,\n\ -even with a strong rope. ****\n"}, +even with a strong rope. ****\n", {0} }, + /* 243 */ {"You are on a dirt road.", {0, 0, 244, 238, 85, 0, 0, 0}, - "**The road continues - and -.\n"}, + "**The road continues - and -.\n", {0} }, + /* 244 */ {"You are on a dirt road.", {0, 245, 0, 243, 88, 0, 0, 0}, - "*The road continues -* and -.\n"}, + "*The road continues -* and -.\n", {0} }, + /* 245 */ {"You are on a dirt road.", {244, 234, 213, 136, 88, 0, 0, 0}, - "The road goes -* and *-.\n"}, + "The road goes -* and *-.\n", {0} }, + /* 246 */ {"You are in a low passage.", {247, 160, 0, 0, 0, 0, 0, 0}, "The passage is partially flooded here and it may be hazardous to proceed.\n\ Water is surging from the tunnel and heading out to sea. Strange moaning\n\ noises rise above the rushing of the water. They are as thin as a whispering\n\ wind yet penetrate to my very soul. I think we have come too far...\n\ -The passage continues -.***\n"}, +The passage continues -.***\n", {0} }, + /* 247 */ {"The walls are very close together here.", {248, 0, 0, 0, 0, 0, 0, 0}, "I can barely squeeze through the jagged opening. Slimy sea weeds provide\n\ no footing at all. This tunnel seems to be an ancient lava tube. There is\n\ -a large room -.***\n"}, +a large room -.***\n", {0} }, + /* 248 */ {"You are in the cathedral room.", {249, 251, 249, 251, 0, 0, 0, 0}, "Your light casts ghostly shadows on the walls but cannot pierce the \n\ engulfing darkness overhead. The sound of water dripping echoes in the void.\n\ *I can see no passages leading out of this room. We have definitely\n\ -come too far.*** \n"}, +come too far.*** \n", {0} }, + /* 249 */ {"You are walking through a very round tunnel.", {252, 0, 0, 0, 252, 1, 0, 0}, "The round walls of this tunnel are amazingly smooth to the touch. A little\n\ trickle of water flows down the center. The tunnel climbs steadily +.\n\ -The cave is beginning to flood again! Let's get out of here! ***\n"}, +The cave is beginning to flood again! Let's get out of here! ***\n", {0} }, + /* 250 */ {"You are in the cathedral anteroom.", {0, 0, 0, 248, 253, 1, 0, 0}, "This small chamber with a flat stone floor is to one side of the cathedral \n\ room. We appear to be at the bottom of a tall narrow shaft. There are many \n\ puddles of water here. A staircase hewn from solid rock and black lava \n\ -leads up.*** The cathedral room is +.\n"}, +leads up.*** The cathedral room is +.\n", {0} }, + /* 251 */ {"You are in a wide chamber.", {0, 0, 248, 254, 0, 0, 0, 0}, "Water is sprinkling from the ceiling here. A shallow pool populated by a \n\ myriad of blind white creatures sparkles in your light. Tiny shrimp and\n\ crabs scurry away, frightened by the blinding rays.** The cave \n\ -continues - and -.\n"}, +continues - and -.\n", {0} }, + /* 252 */ {"You are at the top of a sloping passage.", {0, 0, 255, 256, 257, 1, 0, 0}, "There is much algae growing here, both green and brown specimens. \n\ Water from an underground sea surges and splashes against the slope of\n\ the rock. The walls glisten with shiny minerals. High above, light\n\ filters in through a narrow shaft.** A hallway here runs -\n\ -and -.\n"}, +and -.\n", {0} }, + /* 253 */ {"You are in an elaborately tiled room.", {0, 0, 258, 0, 0, 0, 250, 0}, "Large colorful tiles plate the floor and walls. The ceiling is a mosaic\n\ of gems set in gold. Hopefully it is only our footsteps that are echoing in\n\ this hollow chamber.** The room continues -. A stone staircase\n\ -leads down.*\n"}, +leads down.*\n", {0} }, + /* 254 */ {"You are at a dead end.", {0, 0, 251, 0, 0, 0, 0, 0}, "The walls here are alive with dark mussels. They click their shells menacingly\n\ -if we disturb them. ** The only exit is +.*\n"}, +if we disturb them. ** The only exit is +.*\n", {0} }, + /* 255 */ {"The tunnel is very low here.", {0, 0, 259, 252, 0, 0, 0, 0}, "I practically have to crawl on my knees to pass through this opening. The\n\ air is stiflingly damp, but I can't hear any sounds of water dripping.**\n\ -The crawlspace continues -. The tunnel seems wider +.\n"}, +The crawlspace continues -. The tunnel seems wider +.\n", {0} }, + /* 256 */ {"This is the supply room.", {0, 0, 252, 0, 0, 0, 0, 0}, "Picks and shovels line the walls here, as well as hard hats, boxes of\n\ dynamite, and a cartload of very high grade gold and silver ore.** \n\ -A tunnel leads off +.*\n"}, +A tunnel leads off +.*\n", {0} }, + /* 257 */ {"You have found a secret entrance to the catacombs.", {0, 0, 0, 0, 216, 1, 252, 0}, "I have a sickening feeling that we should not have entered the catacombs.\n\ -Below is a wet, seaweed covered floor. Above is a way out. ****\n"}, +Below is a wet, seaweed covered floor. Above is a way out. ****\n", {0} }, + /* 258 */ {"You are in the catacombs.", {0, 0, 260, 253, 0, 0, 0, 0}, "Ornate tombs and piles of treasure line the walls. Long spears with many\n\ blades, fine swords and coats of mail, heaps of coins, jewelry, pottery, \n\ and golden statues are tribute of past kings and queens.** The catacombs\n\ -continue - and -.\n"}, +continue - and -.\n", {0} }, + /* 259 */ {"You are crawling on your stomach.", {0, 0, 261, 255, 0, 0, 0, 0}, "The passage is quite narrow and jagged, but the rock is no longer lava.\n\ It appears to be a form of granite.** The crawlspace continues -, \n\ -but I would just as soon go -.\n"}, +but I would just as soon go -.\n", {0} }, + /* 260 */ {"You are in the Sepulcher.", {0, 0, 0, 258, 0, 0, 0, 0}, "A single tomb is here. Encrusted with diamonds and opals, and secured with \n\ straps of a very hard, untarnished silver, this tomb must be of a great king.\n\ Vases overflowing with gold coins stand nearby. A line of verse on the wall\n\ -reads, \"Three he made and gave them to his daughters.\"****\n"}, +reads, \"Three he made and gave them to his daughters.\"****\n", {0} }, + /* 261 */ {"The passage is wider here.", {0, 0, 0, 259, 0, 0, 0, 0}, "You are at the top of a flooded shaft. About a meter below the edge,\n\ dark water rises and falls to the rhythm of the sea. A ladder goes\n\ -down into water here.*** A small crawlspace goes -.\n"}, +down into water here.*** A small crawlspace goes -.\n", {0} }, + /* 262 */ {"You are at the bottom of a ladder.", {0, 0, 0, 0, 261, 1, 263, 0}, "This is a narrow platform to rest on before we continue either up or down this\n\ -rickety wooden ladder.****\n"}, +rickety wooden ladder.****\n", {0} }, + /* 263 */ {"You are standing in several inches of water.", {264, 0, 265, 266, 262, 1, 0, 0}, "This seems to be a working mine. Many different tunnels wander off following\n\ glowing veins of precious metal. The floor is flooded here since we must\n\ -be nearly at sea level. A ladder leads up. ****\n"}, +be nearly at sea level. A ladder leads up. ****\n", {0} }, + /* 264 */ {"The tunnel here is blocked by broken rocks.", {0, 263, 0, 0, 0, 0, 0, 0}, "The way is blocked, but if you had some dynamite, we might be able to blast our\n\ -way through.* The passage goes -.**\n"}, +way through.* The passage goes -.**\n", {0} }, + /* 265 */ {"The tunnel is too flooded to proceed.", {0, 0, 0, 263, 0, 0, 0, 0}, "Hidden shafts could swallow us if we tried to continue on down this tunnel.\n\ The flooding is already up to my waist. Large crystals overhead shimmer\n\ -rainbows of reflected light.*** Let's go -.\n"}, +rainbows of reflected light.*** Let's go -.\n", {0} }, + /* 266 */ {"The mine is less flooded here.", {0, 0, 263, 0, 0, 0, 0, 0}, "A meandering gold laden vein of quartz and blooming crystals of diamonds\n\ -and topaz burst from the walls of the cave. A passage goes -.***\n"}, +and topaz burst from the walls of the cave. A passage goes -.***\n", {0} }, + /* 267 */ {"You are inside the cave.", {230, 268, 0, 0, 0, 0, 0, 0}, "A hot steam swirls around our heads, and the walls are warm to the touch.\n\ -The trail winds + and +.**\n"}, +The trail winds + and +.**\n", {0} }, + /* 268 */ {"You are in a rather large chamber.", {267, 0, 0, 269, 0, 0, 269, 0}, "Beds of ferns and palm leaves make several cozy nests along the walls. In the\n\ center of the room is a throne of gold and silver which pulls out into a bed\n\ -of enormous size.*** A passageway leads down to the -.\n"}, +of enormous size.*** A passageway - leads down.\n", {0} }, + /* 269 */ {"You are walking along the edge of a huge abyss.", {0, 0, 268, 0, 268, 1, 270, 0}, "Steam is rising in great clouds from the immeasurable depths. A very narrow\n\ -trail winds down.** There is a tunnel +.*\n"}, +trail winds down.** There is a tunnel +.*\n", {0} }, + /* 270 */ {"You are on the edge of a huge abyss.", {0, 0, 0, 0, 269, 1, 271, 0}, - "The trail winds farther down.****\n"}, + "The trail winds farther down.****\n", {0} }, + /* 271 */ {"You are winding your way along the abyss.", {0, 0, 0, 0, 270, 1, 272, 0}, - "The trail continues up and down.****\n"}, + "The trail continues up and down.****\n", {0} }, + /* 272 */ {"You are on a wide shelf near the steamy abyss.", {0, 273, 0, 0, 271, 1, 0, 0}, "The stifling hot cave seems even hotter to me, staring down into this misty \n\ -abyss. A trail winds up.* A passageway leads -.**\n"}, +abyss. A trail winds up.* A passageway leads -.**\n", {0} }, + /* 273 */ {"You are in a wide tunnel leading to a fuming abyss.", {272, 274, 0, 0, 0, 0, 0, 0}, "The passageway winds through many beautiful formations of crystals and\n\ -sparkling minerals. The tunnel continues - and -.**\n"}, +sparkling minerals. The tunnel continues - and -.**\n", {0} }, + /* 274 */ {"You are in a tunnel.", {273, 231, 0, 0, 0, 0, 0, 0}, "It is very warm in here. The smell of steam and hot rocks permeates the place.\n\ -The cave continues - and -.**\n"}, +The cave continues - and -.**\n", {0} }, + /* 275 */ {"You are at the bottom of a pit.", {0, 0, 0, 0, 232, 0, 0, 0}, "I can see daylight far up at the mouth of the pit. A cool draft wafts down.\n\ There doesn't seem to be any way out, and I don't remember how we came in.\n\ -If you had a rope it might be possible to climb out. ****\n"}, +If you had a rope it might be possible to climb out. ****\n", {0} }, }; diff --git a/battlestar/dayobjs.c b/battlestar/dayobjs.c index 9b8dc4f..8efd71d 100644 --- a/battlestar/dayobjs.c +++ b/battlestar/dayobjs.c @@ -1,4 +1,4 @@ -/* $NetBSD: dayobjs.c,v 1.6 1997/10/11 02:07:16 lukem Exp $ */ +/* $NetBSD: dayobjs.c,v 1.8 1999/09/18 16:42:29 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)dayobjs.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: dayobjs.c,v 1.6 1997/10/11 02:07:16 lukem Exp $"); +__RCSID("$NetBSD: dayobjs.c,v 1.8 1999/09/18 16:42:29 jsm Exp $"); #endif #endif /* not lint */ diff --git a/battlestar/extern.h b/battlestar/extern.h index 94682bc..ef8e391 100644 --- a/battlestar/extern.h +++ b/battlestar/extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.9 1998/09/13 15:27:26 hubertf Exp $ */ +/* $NetBSD: extern.h,v 1.28 2000/09/25 19:37:59 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -35,8 +35,6 @@ * @(#)externs.h 8.1 (Berkeley) 5/31/93 */ -#include - #include #include #include @@ -44,6 +42,7 @@ #include #include #include +#include #include #define BITS (8 * sizeof (int)) @@ -188,6 +187,10 @@ #define BURY 1050 #define JUMP 1051 #define KICK 1052 +#define OPEN 1053 +#define VERBOSE 1054 +#define BRIEF 1055 +#define AUXVERB 1056 /* injuries */ #define ARM 6 /* broken arm */ @@ -207,6 +210,9 @@ #define DUG 5 #define NUMOFNOTES 6 +/* Number of times room description shown. */ +#define ROOMDESC 3 + /* fundamental constants */ #define NUMOFROOMS 275 #define NUMOFWORDS ((NUMOFOBJECTS + BITS - 1) / BITS) @@ -222,6 +228,19 @@ #define MAXWEIGHT 60 #define MAXCUMBER 10 +/* + * These are flags for objects in the objflags array. OBJ_PLURAL means + * that the object short name is plural; OBJ_AN that it begins with a + * vowel sound so should be preceded by "an" instead of "a"; OBJ_PERSON + * that it is a living person; OBJ_NONOBJ that it is not an object (to + * which any game action can be applied) at all (e.g. footsteps, asteroids). + * Any individual object has at most one of OBJ_PERSON and OBJ_NONOBJ. + */ +#define OBJ_PLURAL 1 +#define OBJ_AN 2 +#define OBJ_PERSON 4 +#define OBJ_NONOBJ 8 + struct room { const char *name; int link[8]; @@ -238,7 +257,7 @@ struct room { }; extern struct room dayfile[]; extern struct room nightfile[]; -struct room *location; +extern struct room *location; /* object characteristics */ extern const char *const objdes[NUMOFOBJECTS]; @@ -246,55 +265,62 @@ extern const char *const objsht[NUMOFOBJECTS]; extern const char *const ouch[NUMOFINJURIES]; extern const int objwt[NUMOFOBJECTS]; extern const int objcumber[NUMOFOBJECTS]; +extern const int objflags[NUMOFOBJECTS]; +#define is_plural_object(n) (objflags[(n)] & OBJ_PLURAL) +/* + * These macros yield words to use with objects (followed but not preceded + * by spaces, or with no spaces if the expansion is the empty string). + */ +#define A_OR_AN(n) (objflags[(n)] & OBJ_AN ? "an " : "a ") +#define A_OR_AN_OR_THE(n) (is_plural_object((n)) ? "the " : A_OR_AN((n))) +#define A_OR_AN_OR_BLANK(n) (is_plural_object((n)) ? "" : A_OR_AN((n))) +#define IS_OR_ARE(n) (is_plural_object((n)) ? "are " : "is ") /* current input line */ +#define WORDLEN 15 #define NWORD 20 /* words per line */ -char words[NWORD][15]; -int wordvalue[NWORD]; -int wordtype[NWORD]; -int wordcount, wordnumber; +extern char words[NWORD][WORDLEN]; +extern int wordvalue[NWORD]; +extern int wordtype[NWORD]; +extern int wordcount, wordnumber; /* state of the game */ -int ourtime; -int position; -int direction; -int left, right, ahead, back; -int ourclock, fuel, torps; -int carrying, encumber; -int rythmn; +extern int ourtime; +extern int position; +extern int direction; +extern int left, right, ahead, back; +extern int ourclock, fuel, torps; +extern int carrying, encumber; +extern int rythmn; extern int followfight; -int ate; -int snooze; -int meetgirl; +extern int ate; +extern int snooze; +extern int meetgirl; extern int followgod; -int godready; +extern int godready; extern int win; -int wintime; -int wiz; -int tempwiz; -int matchlight; -extern int matchcount; -int loved; -int pleasure, power, ego; +extern int wintime; +extern int wiz; +extern int tempwiz; +extern int matchlight, matchcount; +extern int loved; +extern int pleasure, power, ego; extern int WEIGHT; extern int CUMBER; -int notes[NUMOFNOTES]; -unsigned int inven[NUMOFWORDS]; -unsigned int wear[NUMOFWORDS]; -char beenthere[NUMOFROOMS + 1]; -char injuries[NUMOFINJURIES]; +extern int notes[NUMOFNOTES]; +extern unsigned int inven[NUMOFWORDS]; +extern unsigned int wear[NUMOFWORDS]; +extern char beenthere[NUMOFROOMS + 1]; +extern char injuries[NUMOFINJURIES]; +extern int verbose; -char username[9]; +extern const char *username; struct wlist { const char *string; int value, article; struct wlist *next; }; -#define HASHSIZE 256 -#define HASHMUL 81 -#define HASHMASK (HASHSIZE - 1) -struct wlist *hashtab[HASHSIZE]; extern struct wlist wlist[]; struct objs { @@ -306,10 +332,8 @@ extern const struct objs nightobjs[]; #define DEFAULT_SAVE_FILE ".Bstar" -void blast __P((void)); void bury __P((void)); int card __P((const char *, int)); -int checkout __P((const char *)); void chime __P((void)); void convert __P((int)); void crash __P((void)); @@ -317,19 +341,18 @@ int cypher __P((void)); void die __P((void)) __attribute__((__noreturn__)); void diesig __P((int)) __attribute__((__noreturn__)); void dig __P((void)); +void dooropen __P((void)); int draw __P((void)); void drink __P((void)); int drive __P((void)); int drop __P((const char *)); int eat __P((void)); -void endfly __P((void)); int fight __P((int, int)); int follow __P((void)); -void getutmp __P((char *)); +char *getcom __P((char *, int, const char *, const char *)); +char *getword __P((char *, char *, int)); int give __P((void)); -int hash __P((const char *)); void initialize __P((const char *)); -void install __P((struct wlist *)); int jump __P((void)); void kiss __P((void)); int land __P((void)); @@ -337,40 +360,32 @@ int launch __P((void)); void light __P((void)); void live __P((void)) __attribute__((__noreturn__)); void love __P((void)); -int move __P((int, int)); -void moveenemy __P((int)); +int moveplayer __P((int, int)); void murder __P((void)); void news __P((void)); void newway __P((int)); -void notarget __P((void)); void open_score_file __P((void)); void parse __P((void)); void post __P((char)); void printobjs __P((void)); int put __P((void)); int puton __P((void)); +const char *rate __P((void)); void ravage __P((void)); -void restore __P((const char *, size_t)); +void restore __P((const char *)); int ride __P((void)); -void save __P((const char *, size_t)); -void screen __P((void)); +void save __P((const char *)); +char *save_file_name __P((const char *, size_t)); int shoot __P((void)); -void succumb __P((int)); int take __P((unsigned int[])); int takeoff __P((void)); -void target __P((void)); int throw __P((const char *)); +const char *truedirec __P((int, char)); int ucard __P((const unsigned int *)); int use __P((void)); int visual __P((void)); int wearit __P((void)); void whichway __P((struct room)); -int wizard __P((const char *)); void wordinit __P((void)); void writedes __P((void)); int zzz __P((void)); -char *getcom __P((char *, int, const char *, const char *)); -char *getword __P((char *, char *, int)); -const char *rate __P((void)); -const char *truedirec __P((int, char)); -struct wlist *lookup __P((const char *)); diff --git a/battlestar/fly.c b/battlestar/fly.c index 77224c7..a78a621 100644 --- a/battlestar/fly.c +++ b/battlestar/fly.c @@ -1,4 +1,4 @@ -/* $NetBSD: fly.c,v 1.6 1997/10/11 02:07:20 lukem Exp $ */ +/* $NetBSD: fly.c,v 1.10 2001/12/04 13:00:24 blymn Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)fly.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: fly.c,v 1.6 1997/10/11 02:07:20 lukem Exp $"); +__RCSID("$NetBSD: fly.c,v 1.10 2001/12/04 13:00:24 blymn Exp $"); #endif #endif /* not lint */ @@ -46,20 +46,27 @@ __RCSID("$NetBSD: fly.c,v 1.6 1997/10/11 02:07:20 lukem Exp $"); #undef UP #include -#define abs(a) ((a) < 0 ? -(a) : (a)) #define MIDR (LINES/2 - 1) #define MIDC (COLS/2 - 1) -int row, column; -int dr = 0, dc = 0; -char destroyed; +static int row, column; +static int dr = 0, dc = 0; +static char destroyed; int ourclock = 120; /* time for all the flights in the game */ -char cross = 0; -sig_t oldsig; +static char cross = 0; +static sig_t oldsig; -void +static void blast __P((void)); +static void endfly __P((void)); +static void moveenemy __P((int)); +static void notarget __P((void)); +static void screen __P((void)); +static void succumb __P((int)); +static void target __P((void)); + +static void succumb(dummy) - int dummy __attribute__((unused)); + int dummy __attribute__((__unused__)); { if (oldsig == SIG_DFL) { endfly(); @@ -80,7 +87,7 @@ visual() return (0); } oldsig = signal(SIGINT, succumb); - crmode(); + cbreak(); noecho(); screen(); row = rnd(LINES - 3) + 1; @@ -178,7 +185,7 @@ visual() } } -void +static void screen() { int r, c, n; @@ -195,7 +202,7 @@ screen() refresh(); } -void +static void target() { int n; @@ -208,7 +215,7 @@ target() } } -void +static void notarget() { int n; @@ -221,7 +228,7 @@ notarget() } } -void +static void blast() { int n; @@ -243,9 +250,9 @@ blast() alarm(1); } -void +static void moveenemy(dummy) - int dummy __attribute__((unused)); + int dummy __attribute__((__unused__)); { double d; int oldr, oldc; @@ -283,7 +290,7 @@ moveenemy(dummy) alarm(1); } -void +static void endfly() { alarm(0); diff --git a/battlestar/getcom.c b/battlestar/getcom.c index 4eb4e65..85cee2e 100644 --- a/battlestar/getcom.c +++ b/battlestar/getcom.c @@ -1,4 +1,4 @@ -/* $NetBSD: getcom.c,v 1.5 1997/10/11 02:07:21 lukem Exp $ */ +/* $NetBSD: getcom.c,v 1.10 2000/09/24 15:51:40 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)getcom.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: getcom.c,v 1.5 1997/10/11 02:07:21 lukem Exp $"); +__RCSID("$NetBSD: getcom.c,v 1.10 2000/09/24 15:51:40 jsm Exp $"); #endif #endif /* not lint */ @@ -53,6 +53,8 @@ getcom(buf, size, prompt, error) for (;;) { fputs(prompt, stdout); if (fgets(buf, size, stdin) == 0) { + if (feof(stdin)) + die(); clearerr(stdin); continue; } @@ -63,6 +65,12 @@ getcom(buf, size, prompt, error) if (error) puts(error); } + /* If we didn't get to the end of the line, don't read it in next time. */ + if (buf[strlen(buf) - 1] != '\n') { + int i; + while ((i = getchar()) != '\n' && i != EOF) + continue; + } return (buf); } @@ -76,6 +84,9 @@ getword(buf1, buf2, flag) char *buf1, *buf2; int flag; { + int cnt; + + cnt = 1; while (isspace(*buf1)) buf1++; if (*buf1 != ',') { @@ -83,24 +94,34 @@ getword(buf1, buf2, flag) *buf2 = 0; return (0); } - while (*buf1 && !isspace(*buf1) && *buf1 != ',') - if (flag < 0) - if (isupper(*buf1)) + while (cnt < WORDLEN && *buf1 && !isspace(*buf1) && *buf1 != ',') + if (flag < 0) { + if (isupper(*buf1)) { *buf2++ = tolower(*buf1++); - else + cnt++; + } else { *buf2++ = *buf1++; - else - if (flag > 0) - if (islower(*buf1)) - *buf2++ = toupper(*buf1++); - else - *buf2++ = *buf1++; - else + cnt++; + } + } else if (flag > 0) { + if (islower(*buf1)) { + *buf2++ = toupper(*buf1++); + cnt++; + } else { *buf2++ = *buf1++; + cnt++; + } + } else { + *buf2++ = *buf1++; + cnt++; + } + if (cnt == WORDLEN) + while (*buf1 && !isspace(*buf1)) + buf1++; } else *buf2++ = *buf1++; - *buf2 = 0; + *buf2 = '\0'; while (isspace(*buf1)) buf1++; - return (*buf1 ? buf1 : 0); + return (*buf1 ? buf1 : NULL); } diff --git a/battlestar/globals.c b/battlestar/globals.c index 4474c44..2c7d7f5 100644 --- a/battlestar/globals.c +++ b/battlestar/globals.c @@ -1,4 +1,4 @@ -/* $NetBSD: globals.c,v 1.6 1997/10/11 02:07:23 lukem Exp $ */ +/* $NetBSD: globals.c,v 1.18 2000/09/25 14:45:01 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)globals.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: globals.c,v 1.6 1997/10/11 02:07:23 lukem Exp $"); +__RCSID("$NetBSD: globals.c,v 1.18 2000/09/25 14:45:01 jsm Exp $"); #endif #endif /* not lint */ @@ -48,11 +48,11 @@ int WEIGHT = MAXWEIGHT; int CUMBER = MAXCUMBER; const char *const objdes[NUMOFOBJECTS] = { - "There is a knife here", - "There is an exquisitely crafted sword and scabbard here.", - 0, /* can land from here */ + "There is a knife here.", + "There are an exquisitely crafted sword and scabbard here.", + NULL, /* Can land from here. */ "There is a fierce woodsman here brandishing a heavy mallet.", - "There is an unweildly two-handed sword here.", + "There is an unwieldy two-handed sword here.", "There is a bloody meat cleaver here.", "A rusty broadsword is lying here.", "There is an ancient coat of finely woven mail here.", @@ -62,7 +62,7 @@ const char *const objdes[NUMOFOBJECTS] = { "There is a Viper ready for launch here.", "A kerosene lantern is burning luridly here.", "An old pair of shoes has been discarded here.", - 0, /* cylon */ + NULL, /* Cylon. */ "There is a pair of pajamas here.", "A kingly robe of royal purple and spun gold is draped here.", "There is a strange golden amulet on the floor here.", @@ -73,14 +73,14 @@ const char *const objdes[NUMOFOBJECTS] = { "There is a laser pistol here.", "A flower-like young goddess is bathing in the hot mineral pools. She is \nwatching you, but continues to steep and sing softly.", "The goddess is reclining on a bed of ferns and studying you intently.", - "There is a grenade here", + "There is a grenade here.", "There is a length of heavy chain here.", "There is a stout rope here.", "There is a pair of Levi's here.", "A bloody mace is lying on the ground here.", "There is a shovel here.", "A long, sharp halberd is propped up here.", - "There is a compass here", + "There is a compass here.", "Wreckage and smoldering debris from a crash litter the ground here.", "A woodland Elf armed with a shield and deadly halberd lunges toward you!", "I think I hear footsteps behind us.", @@ -96,15 +96,15 @@ const char *const objdes[NUMOFOBJECTS] = { "There is a colorful pink potion in a small crystal vial here.", "A gold bracelet is on the ground here.", "A swarthy woman with stern features pulls you aside from the crowd,\n'I must talk to you -- but not here. Meet me at midnight in the gardens.'", - "The swarthy woman has been awaiting you anxiousy. 'I must warn you that the\nIsland has anticipated your Quest. You will not be welcomed. The Darkness is\nstrong where you must search. Seek not the shadows save only at night, for\nthen are they the weakest. In the mountains far from here a canyon winds\nwith ferns and streams and forgotten vines. There you must go. Take this\nrope.'", + "The swarthy woman has been awaiting you anxiously. 'I must warn you that the\nIsland has anticipated your Quest. You will not be welcomed. The Darkness is\nstrong where you must search. Seek not the shadows save only at night, for\nthen are they the weakest. In the mountains far from here a canyon winds\nwith ferns and streams and forgotten vines. There you must go. Take this\nrope.'", "Out from the shadows a figure leaps! His black cape swirls around, and he\nholds a laser sword at your chest. 'So, you have come to fulfill the Quest.\nHa! Your weapons are no match for me!'", - "An old timer with one eye missing and no money for a drink sits at the bar.", + "An old-timer with one eye missing and no money for a drink sits at the bar.", "You are flying through an asteroid field!", "A planet is nearby.", "The ground is charred here.", "There is a thermonuclear warhead here.", "The fragile, beautiful young goddess lies here. You murdered her horribly.", - "The old timer is lying here. He is dead.", + "The old-timer is lying here. He is dead.", "The native girl's body is lying here.", "A native girl is sitting here.", "A gorgeous white stallion is standing here.", @@ -118,7 +118,7 @@ const char *const objdes[NUMOFOBJECTS] = { const char *const objsht[NUMOFOBJECTS] = { "knife", "fine sword", - 0, + NULL, /* Can land from here. */ "Woodsman", "two-handed sword", "meat cleaver", @@ -130,7 +130,7 @@ const char *const objsht[NUMOFOBJECTS] = { "viper", "lantern", "shoes", - 0, + NULL, /* Cylon. */ "pajamas", "robe", "amulet", @@ -139,8 +139,8 @@ const char *const objsht[NUMOFOBJECTS] = { "woodsman's body", "wooden mallet", "laser", - 0, - 0, + NULL, /* Bathing goddess. */ + NULL, /* Goddess. */ "grenade", "chain", "rope", @@ -149,12 +149,12 @@ const char *const objsht[NUMOFOBJECTS] = { "shovel", "halberd", "compass", - 0, + NULL, /* Crash debris. */ "Elf", - 0, + NULL, /* Footsteps. */ "coins", "match book", - 0, + NULL, /* Man and dwarf. */ "papayas", "pineapple", "kiwi", @@ -163,18 +163,18 @@ const char *const objsht[NUMOFOBJECTS] = { "ring", "potion", "bracelet", - 0, - 0, + NULL, /* Swarthy woman. */ + NULL, /* Swarthy woman (with message). */ "Dark Lord", - 0, - 0, - 0, - 0, + NULL, /* Old-timer. */ + NULL, /* Asteroid field. */ + NULL, /* Planet nearby. */ + NULL, /* Charred ground. */ "warhead", "goddess's body", - "old timer's body", + "old-timer's body", "girl's body", - 0, + NULL, /* Native girl. */ "stallion", "car", "pot of jewels", @@ -220,7 +220,61 @@ const int objcumber[NUMOFOBJECTS] = { 10, 8, 8, 10, 10, 3, 1, 2 }; +const int objflags[NUMOFOBJECTS] = { + 0, 0, OBJ_NONOBJ, OBJ_PERSON, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, OBJ_PLURAL, OBJ_NONOBJ, OBJ_PLURAL, + 0, OBJ_AN, 0, 0, + 0, 0, 0, OBJ_PERSON, + OBJ_PERSON, 0, 0, 0, + OBJ_PLURAL, 0, 0, 0, + 0, 0, OBJ_AN|OBJ_PERSON, OBJ_NONOBJ, + OBJ_PLURAL, 0, OBJ_PERSON, OBJ_PLURAL, + 0, 0, OBJ_PLURAL, 0, + 0, 0, 0, OBJ_PERSON, + OBJ_PERSON, OBJ_PERSON, OBJ_PERSON, OBJ_NONOBJ, + OBJ_NONOBJ, OBJ_NONOBJ, 0, 0, + OBJ_AN, 0, OBJ_PERSON, 0, + 0, 0, 0, 0 +}; + int win = 1; int matchcount = 20; int followgod = -1; int followfight = -1; + +struct room *location; + + /* current input line */ +char words[NWORD][WORDLEN]; +int wordvalue[NWORD]; +int wordtype[NWORD]; +int wordcount, wordnumber; + + /* state of the game */ +int ourtime; +int position; +int direction; +int left, right, ahead, back; +int fuel, torps; +int carrying, encumber; +int rythmn; +int ate; +int snooze; +int meetgirl; +int godready; +int wintime; +int wiz; +int tempwiz; +int matchlight; +int loved; +int pleasure, power, ego; +int notes[NUMOFNOTES]; +unsigned int inven[NUMOFWORDS]; +unsigned int wear[NUMOFWORDS]; +char beenthere[NUMOFROOMS + 1]; +char injuries[NUMOFINJURIES]; +int verbose = 0; + +const char *username; diff --git a/battlestar/init.c b/battlestar/init.c index d3aeb5e..9670ea8 100644 --- a/battlestar/init.c +++ b/battlestar/init.c @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.7 1997/10/11 02:07:25 lukem Exp $ */ +/* $NetBSD: init.c,v 1.12 2000/09/09 09:37:58 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,26 +38,31 @@ #if 0 static char sccsid[] = "@(#)init.c 8.4 (Berkeley) 4/30/95"; #else -__RCSID("$NetBSD: init.c,v 1.7 1997/10/11 02:07:25 lukem Exp $"); +__RCSID("$NetBSD: init.c,v 1.12 2000/09/09 09:37:58 jsm Exp $"); #endif #endif /* not lint */ #include "extern.h" +static int checkout __P((const char *)); +static const char *getutmp __P((void)); +static int wizard __P((const char *)); + void -initialize(startup) - const char *startup; +initialize(filename) + const char *filename; { const struct objs *p; + char *savefile; puts("Version 4.2, fall 1984."); puts("First Adventure game written by His Lordship, the honorable"); puts("Admiral D.W. Riggle\n"); location = dayfile; srand(getpid()); - getutmp(username); + username = getutmp(); wordinit(); - if (startup == NULL) { + if (filename == NULL) { direction = NORTH; ourtime = 0; snooze = CYCLE * 1.5; @@ -67,23 +72,29 @@ initialize(startup) torps = TORPEDOES; for (p = dayobjs; p->room != 0; p++) setbit(location[p->room].objects, p->obj); - } else - restore(startup, strlen(startup)); + } else { + savefile = save_file_name(filename, strlen(filename)); + restore(savefile); + free(savefile); + } wiz = wizard(username); signal(SIGINT, diesig); } -void -getutmp(uname) - char *uname; +static const char * +getutmp() { struct passwd *ptr; ptr = getpwuid(getuid()); - strncpy(uname, ptr ? ptr->pw_name : "", 8); + if (ptr == NULL) + return ""; + else + return strdup(ptr->pw_name); } -const char *const list[] = { /* hereditary wizards */ +/* Hereditary wizards. A configuration file might make more sense. */ +static const char *const list[] = { "riggle", "chris", "edward", @@ -94,14 +105,14 @@ const char *const list[] = { /* hereditary wizards */ 0 }; -const char *const badguys[] = { +static const char *const badguys[] = { "wnj", "root", "ted", 0 }; -int +static int wizard(uname) const char *uname; { @@ -112,7 +123,7 @@ wizard(uname) return flag; } -int +static int checkout(uname) const char *uname; { diff --git a/battlestar/misc.c b/battlestar/misc.c index 366415e..89d636a 100644 --- a/battlestar/misc.c +++ b/battlestar/misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: misc.c,v 1.6 1997/10/11 02:07:27 lukem Exp $ */ +/* $NetBSD: misc.c,v 1.7 1999/02/10 01:36:50 hubertf Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)misc.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: misc.c,v 1.6 1997/10/11 02:07:27 lukem Exp $"); +__RCSID("$NetBSD: misc.c,v 1.7 1999/02/10 01:36:50 hubertf Exp $"); #endif #endif /* not lint */ diff --git a/battlestar/nightfile.c b/battlestar/nightfile.c index 381d274..9eff1c3 100644 --- a/battlestar/nightfile.c +++ b/battlestar/nightfile.c @@ -1,4 +1,4 @@ -/* $NetBSD: nightfile.c,v 1.7 1998/07/25 10:58:03 hubertf Exp $ */ +/* $NetBSD: nightfile.c,v 1.11 2000/09/18 06:14:32 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,122 +38,144 @@ #if 0 static char sccsid[] = "@(#)nightfile.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: nightfile.c,v 1.7 1998/07/25 10:58:03 hubertf Exp $"); +__RCSID("$NetBSD: nightfile.c,v 1.11 2000/09/18 06:14:32 jsm Exp $"); #endif #endif /* not lint */ #include "extern.h" struct room nightfile[] = { - {0}, + {0, {0}, 0, {0} }, + /* 1 */ {"You are in the main hangar.", {5, 2, 9, 3, 3, 1, 0, 0}, "This is a huge bay where many fighters and cargo craft lie. Alarms are \n\ sounding and fighter pilots are running to their ships. Above is a gallery\n\ overlooking the bay. The scream of turbo engines is coming from +. The rest\n\ -of the hangar is +. There is an exit +.*\n"}, +of the hangar is +. There is an exit +.*\n", {0} }, + /* 2 */ {"This is the landing bay.", {1, 0, 10, 0, 0, 0, 0, 0}, "Ships are landing here, some heavily damaged. Enemy fighters continually\n\ -strafe this vulnerable port. The main hangar is +, *\n\ -There is an exit +.*\n"}, +strafe this vulnerable port. The main hangar is +. *\n\ +There is an exit +.*\n", {0} }, + /* 3 */ {"You are in the gallery.", {4, 0, 0, 0, 0, 0, 1, 0}, "From here a view of the entire landing bay reveals that our battlestar\n\ is near destruction. Fires are spreading out of control and laser blasts\n\ -lick at the shadows. The control room is +. ***\n"}, +lick at the shadows. The control room is +. ***\n", {0} }, + /* 4 */ {"You are in the control room.", {0, 3, 0, 0, 0, 0, 5, 0}, "Several frantic technicians are flipping switches wildly but otherwise\n\ this room seems fairly deserted. A weapons locker has been left open.\n\ -A staircase leads down. * There is a way -. ** \n"}, +A staircase leads down. * There is a way -. ** \n", {0} }, + /* 5 */ {"This is the launch room.", {6, 1, 7, 0, 4, 1, 0, 0}, "From the launch tubes here fighters blast off into space. Only one is left,\n\ and it is guarded by two fierce men. A staircase leads up from here.\n\ There is a cluttered workbench +. From the main hangar come sounds of great\n\ -explosions. The main hangar is +. The viper launch tubes are to the -.*\n"}, +explosions. The main hangar is +. The viper launch tubes are -.*\n", {0} }, + /* 6 */ {"You are at the workbench.", {0, 5, 7, 0, 0, 0, 0, 0}, "Strange and unwieldy tools are arranged here including a lunch box \n\ and pneumatic wrenches and turbo sprocket rockets.*\n\ -The launch room is +. The remaining viper is +.*\n"}, +The launch room is +. The remaining viper is +.*\n", {0} }, + /* 7 */ {"You are in the viper launch tube.", {0, 5, 0, 5, 32, 0, 0, 0}, - "The two guards are eyeing you warily! ****\n"}, + "The two guards are eyeing you warily! ****\n", {0} }, + /* 8 */ {"This is a walk in closet.", {22, 0, 0, 0, 0, 0, 0, 0}, "A wardrobe of immense magnitude greets the eye. Furs and robes of kings\n\ hang on rack after rack. Silken gowns, capes woven with spun gold, and \n\ -delicate synthetic fabrics are stowed here. The bedroom is +.***\n"}, +delicate synthetic fabrics are stowed here. The bedroom is +.***\n", {0} }, + /* 9 */ {"You are in a wide hallway leading to the main hangar.", {0, 0, 11, 1, 0, 0, 0, 0}, "The walls and ceiling here have been blasted through in several places.\n\ It looks as if quite a battle has been fought for possession of the landing bay\n\ Gaping corpses litter the floor.** The hallway continues +.\n\ -The main hangar is +.\n"}, +The main hangar is +.\n", {0} }, + /* 10 */ {"You are in a wide hallway leading to the landing bay.", {0, 0, 12, 2, 0, 0, 0, 0}, "Most of the men and supplies needed in the main hangar come through this\n\ corridor, but the wounded are forced to use it too. It very dank and\n\ crowded here, and the floor is slippery with blood.**\n\ -The hallway continues -. The landing bay is +.\n"}, +The hallway continues -. The landing bay is +.\n", {0} }, + /* 11 */ {"The hallway is very congested with rubble here.", {0, 0, 0, 9, 13, 1, 0, 0}, "It is too choked with broken steel girders and other debris to continue\n\ on much farther. Above, the ceiling has caved in and it is possible to \n\ climb up. There is not much chance to go -, -, or -.\n\ -But the hallway seems clearer +.\n"}, +But the hallway seems clearer +.\n", {0} }, + /* 12 */ {"A wide hallway and a more narrow walkway meet here.", {14, 15, 0, 10, 0, 0, 0, 0}, "The intersection is crowded with the many wounded who have come up\n\ the wide hallway and continued +. The walkway is less crowded +.\n\ -The wide hallway goes *-.\n"}, +The wide hallway goes *-.\n", {0} }, + /* 13 */ {"You are in what was once an elegant stateroom.", {16, 0, 0, 0, 0, 0, 11, 0}, "Whoever lived in this stateroom, he and his female companion\n\ were mercilessly slain in their sleep. Clothes, trinkets and personal\n\ belongings are scattered all across the floor. Through a hole in the\n\ -collapsed floor I can see a hallway below. A door is +.***\n"}, +collapsed floor I can see a hallway below. A door is +.***\n", {0} }, + /* 14 */ {"You're at the entrance to the sick bay.", {17, 12, 18, 0, 0, 0, 0, 0}, "The wounded are entering the sick bay in loudly moaning files.\n\ The walkway continues - and +. A doctor is motioning for you to \n\ -come to the -. *\n"}, +come to the -. *\n", {0} }, + /* 15 */ {"You're in the walkway.", {12, 19, 0, 0, 0, 0, 0, 0}, "Most of the men and supplies were coming from the armory. The walkway\n\ -continues -. The armory is +.**\n"}, +continues -. The armory is +.**\n", {0} }, + /* 16 */ {"These are the executive suites of the battlestar.", {20, 13, 21, 22, 23, 1, 24, 0}, "Luxurious staterooms carpeted with crushed velvet and adorned with beaten\n\ gold open onto this parlor. A wide staircase with ivory banisters leads\n\ -up or down. This parlor leads into a hallway +. The bridal suite is +.\n\ -Other rooms lie - and +.\n"}, +up or down. This parlor leads into a hallway +. The bridal suite is\n\ ++. Other rooms lie - and +.\n", {0} }, + /* 17 */ {"You're in a long dimly lit hallway.", {0, 14, 25, 0, 0, 0, 0, 0}, "This part of the walkway is deserted. There is a dead end +. The\n\ -entrance to the sickbay is +. The walkway turns sharply -.*\n"}, +entrance to the sickbay is +. The walkway turns sharply -.*\n", {0} }, + /* 18 */ {"This is the sick bay.", {0, 0, 0, 14, 0, 0, 0, 0}, "Sinister nurses with long needles and pitiful aim probe the depths of suffering\n\ here. Only the mortally wounded receive medical attention on a battlestar,\n\ but afterwards they are thrown into the incinerators along with the rest.**\n\ -Nothing but death and suffering +. The walkway is +.\n"}, +Nothing but death and suffering +. The walkway is +.\n", {0} }, + /* 19 */ {"You're in the armory.", {15, 26, 0, 0, 0, 0, 0, 0}, "An armed guard is stationed here 365 sectars a yarn to protect the magazine.\n\ -The walkway is +. The magazine is +.**\n"}, +The walkway is +. The magazine is +.**\n", {0} }, + /* 20 */ {"The hallway ends here at the presidential suite.", {27, 16, 0, 0, 0, 0, 0, 0}, "The door to this suite is made from solid magnesium, and the entryway is\n\ inlaid with diamonds and fire opals. The door is ajar +. The hallway\n\ -goes -.**\n"}, +goes -.**\n", {0} }, + /* 21 */ {"This is the maid's utility room.", {0, 0, 0, 16, 0, 0, 0, 0}, "What a gruesome sight! The maid has been brutally drowned in a bucket of\n\ Pine Sol and repeatedly stabbed in the back with a knife.***\n\ -The hallway is +.\n"}, +The hallway is +.\n", {0} }, + /* 22 */ {"This is a luxurious stateroom.", {0, 8, 16, 0, 0, 0, 0, 0}, "The floor is carpeted with a soft animal fur and the great wooden furniture\n\ @@ -161,1024 +183,1279 @@ is inlaid with strips of platinum and gold. Electronic equipment built\n\ into the walls and ceiling is flashing wildly. The floor shudders and\n\ the sounds of dull explosions rumble though the room. From a window in\n\ the wall + comes a view of darkest space. There is a small adjoining\n\ -room +, and a doorway +.*\n"}, +room +, and a doorway +.*\n", {0} }, + /* 23 */ {"You are at the entrance to the dining hall.", {0, 0, 28, 0, 0, 0, 16, 0}, "A wide staircase with ebony banisters leads down here.**\n\ -The dining hall is to the -.*\n"}, +The dining hall is -.*\n", {0} }, + /* 24 */ {"This was once the first class lounge.", {0, 0, 29, 0, 16, 1, 0, 0}, "There is much rubble and destruction here that was not apparent elsewhere.\n\ The walls and ceilings have broken in in some places. A staircase with\n\ red coral banisters leads up. It is impossible to go - or -.\n\ -It seems a little clearer +.*\n"}, +It seems a little clearer +.*\n", {0} }, + /* 25 */ {"You are in a narrow stairwell.", {0, 17, 0, 0, 30, 1, 0, 0}, "These dusty and decrepit stairs lead up. There is no way -. The\n\ -hallway turns sharply -.**\n"}, +hallway turns sharply -.**\n", {0} }, + /* 26 */ {"You are in the magazine.", {19, 0, 0, 0, 0, 0, 0, 0}, "Rows and rows of neatly stacked ammunition for laser pistols and grenade\n\ -launchers are here. The armory is +.***\n"}, +launchers are here. The armory is +.***\n", {0} }, + /* 27 */ {"You're in the presidential suite.", {0, 20, 0, 0, 0, 0, 0, 0}, "Apparently the president has been assassinated. A scorched figure lies\n\ face downward on the carpet clutching his chest.*\n\ -The hallway leads -.**\n"}, +The hallway leads -.**\n", {0} }, + /* 28 */ {"You are in the dining hall.", {0, 30, 31, 23, 0, 0, 0, 0}, "This was the scene of a mass suicide. Hundreds of ambassadors and assorted\n\ dignitaries sit slumped over their breakfast cereal. I suppose the news\n\ of the cylon attack killed them. There is a strange chill in this room. I\n\ -would not linger here. * The kitchen is +. Entrances + and +.\n"}, +would not linger here. * The kitchen is +. Entrances + and +.\n", {0} }, + /* 29 */ {"The debris is very thick here.", {0, 11, 0, 24, 0, 0, 0, 0}, "Broken furniture, fallen girders, and other rubble block the way.\n\ There is not much chance to continue -, -, or -.\n\ -It would be best to go -.\n"}, +It would be best to go -.\n", {0} }, + /* 30 */ {"You are in the kitchen.", {28, 0, 0, 0, 0, 0, 0, 0}, "This room is full of shining stainless steel and burnished bronze cookware. An \n\ assortment of tropical fruits and vegetables as well as fine meats and cheeses \n\ lies on a sterling platter. The chef, unfortunately, has been skewered like a \n\ -side of beef. The dining room is +. ** There is a locked door +.\n"}, +side of beef. The dining room is +. ** There is a locked door +.\n", {0} }, + /* 31 */ {"You are in an arched entry leading to the dining room.", {0, 0, 0, 28, 0, 0, 0, 0}, "The door leading out is bolted shut from the outside and is very strong.***\n\ -The dining room is +.\n"}, +The dining room is +.\n", {0} }, + /* 32 */ {"You are in space.", {33, 34, 35, 36, 37, 1, 33, 1}, - "****\n"}, + "****\n", {0} }, + /* 33 */ {"You are in space.", {38, 32, 39, 40, 41, 1, 42, 1}, - "****\n"}, + "****\n", {0} }, + /* 34 */ {"You are in space.", {32, 44, 45, 46, 47, 1, 48, 1}, - "****\n"}, + "****\n", {0} }, + /* 35 */ {"You are in space.", {40, 45, 49, 32, 50, 1, 51, 1}, - "****\n"}, + "****\n", {0} }, + /* 36 */ {"You are in space.", {41, 46, 32, 52, 53, 1, 54, 1}, - "****\n"}, + "****\n", {0} }, + /* 37 */ {"You are in space.", {42, 47, 50, 53, 55, 1, 32, 1}, - "****\n"}, + "****\n", {0} }, + /* 38 */ {"You are in space.", {43, 48, 51, 54, 32, 1, 56, 1}, - "****\n"}, + "****\n", {0} }, + /* 39 */ {"You are in space.", {57, 33, 40, 41, 42, 1, 43, 1}, - "****\n"}, + "****\n", {0} }, + /* 40 */ {"You are in space.", {39, 35, 57, 33, 58, 1, 59, 1}, - "****\n"}, + "****\n", {0} }, + /* 41 */ {"You are in space.", {39, 36, 33, 59, 60, 1, 61, 1}, - "****\n"}, + "****\n", {0} }, + /* 42 */ {"You are in space.", {39, 37, 58, 60, 62, 1, 33, 1}, - "****\n"}, + "****\n", {0} }, + /* 43 */ {"You are in space.", {39, 38, 59, 61, 33, 1, 63, 1}, - "****\n"}, + "****\n", {0} }, + /* 44 */ {"You are in space.", {34, 64, 45, 46, 47, 1, 48, 1}, - "****\n"}, + "****\n", {0} }, + /* 45 */ {"You are in space.", {35, 44, 49, 34, 50, 1, 51, 1}, - "****\n"}, + "****\n", {0} }, + /* 46 */ {"You are in space.", {36, 44, 34, 52, 53, 1, 54, 1}, - "****\n"}, + "****\n", {0} }, + /* 47 */ {"You are in space.", {37, 44, 50, 53, 55, 1, 34, 1}, - "****\n"}, + "****\n", {0} }, + /* 48 */ {"You are in space.", {38, 44, 51, 54, 34, 1, 56, 1}, - "****\n"}, + "****\n", {0} }, + /* 49 */ {"You are in space.", {49, 49, 52, 35, 49, 1, 49, 1}, - "****\n"}, + "****\n", {0} }, + /* 50 */ {"You are in space.", {58, 47, 49, 37, 55, 1, 35, 1}, - "****\n"}, + "****\n", {0} }, + /* 51 */ {"You are in space.", {59, 48, 49, 38, 35, 1, 56, 1}, - "****\n"}, + "****\n", {0} }, + /* 52 */ {"You are in space.", {52, 52, 36, 49, 52, 1, 52, 1}, - "****\n"}, + "****\n", {0} }, + /* 53 */ {"You are in space.", {60, 46, 37, 52, 55, 1, 36, 1}, - "****\n"}, + "****\n", {0} }, + /* 54 */ {"You are in space.", {61, 48, 38, 52, 36, 1, 56, 1}, - "****\n"}, + "****\n", {0} }, + /* 55 */ {"You are in space.", {62, 55, 55, 55, 56, 1, 37, 1}, - "****\n"}, + "****\n", {0} }, + /* 56 */ {"You are in space.", {56, 56, 56, 56, 38, 1, 55, 1}, - "****\n"}, + "****\n", {0} }, + /* 57 */ {"You are in space.", {65, 39, 57, 57, 57, 1, 57, 1}, - "****\n"}, + "****\n", {0} }, + /* 58 */ {"You are in space.", {39, 50, 49, 42, 62, 1, 40, 1}, - "****\n"}, + "****\n", {0} }, + /* 59 */ {"You are in space.", {39, 51, 49, 43, 40, 1, 63, 1}, - "****\n"}, + "****\n", {0} }, + /* 60 */ {"You are in space.", {39, 53, 43, 59, 62, 1, 41, 1}, - "****\n"}, + "****\n", {0} }, + /* 61 */ {"You are in space.", {39, 54, 43, 59, 41, 1, 56, 1}, - "****\n"}, + "****\n", {0} }, + /* 62 */ {"You are in space.", {39, 55, 62, 62, 56, 1, 42, 1}, - "****\n"}, + "****\n", {0} }, + /* 63 */ {"You are in space.", {39, 56, 35, 36, 43, 1, 55, 1}, - "****\n"}, + "****\n", {0} }, + /* 64 */ {"You are in space.", {44, 66, 66, 66, 66, 1, 66, 1}, - "****\n"}, + "****\n", {0} }, + /* 65 */ {"You are in space.", {67, 57, 67, 67, 67, 1, 67, 1}, - "****\n"}, + "****\n", {0} }, + /* 66 */ {"You are in space.", {64, 68, 68, 68, 68, 1, 68, 1}, - "****\n"}, + "****\n", {0} }, + /* 67 */ {"You are orbiting a small blue planet.", {67, 67, 67, 67, 65, 1, 69, 1}, - "****\n"}, + "****\n", {0} }, + /* 68 */ {"You are orbiting a tropical planet.", {68, 68, 68, 68, 66, 1, 70, 1}, - "****\n"}, + "****\n", {0} }, + /* 69 */ {"You are flying through a dense fog.", {69, 69, 69, 69, 69, 1, 69, 1}, "A cold grey sea of mist is swirling around the windshield and water droplets\n\ are spewing from the wingtips. Ominous shadows loom in the darkness and it\n\ feels as if a trap is closing around us. I have lost all sense of direction.\n\ -****\n"}, +****\n", {0} }, + /* 70 */ {"You are approaching an island.", {71, 72, 73, 74, 68, 1, 0, 1}, "Feather palms outlined by mellow moonlight and a silvery black ocean line\n\ the perimeter of the island. Mighty mountains of emerald and amethyst rise\n\ like jagged teeth from black gums. The land rises sharply +. The shore\n\ -line stretches on *+.*\n"}, +line stretches on *+.*\n", {0} }, + /* 71 */ {"You are flying over a mountainous region.", {75, 73, 76, 77, 68, 1, 0, 1}, - "Below is a shadow filled canyon with luminous waterfalls plummeting down beyond sight and looming spires and pinnacles. **The ocean is +.*\n"}, +"Below is a shadow=filled canyon with looming spires and pinnacles and\n\ +luminous waterfalls plummeting down beyond sight. **The ocean is +.*\n", {0} }, + /* 72 */ {"You are flying over the ocean.", {74, 78, 78, 78, 68, 1, 0, 1}, "You bank over the water and your wingtips dip low to the green waves. The\n\ sea is very shallow here and the white coral beds beneath us teem with \n\ -shadowy fish.****\n"}, +shadowy fish.****\n", {0} }, + /* 73 */ {"You are flying over the beach.", {71, 72, 79, 74, 68, 1, 80, 1}, "A warm gentle surf caresses the beach here. The land rises\n\ -sharply +.* The beach is lost in low cliffs +.*\n"}, +sharply +.* The beach is lost in low cliffs +.*\n", {0} }, + /* 74 */ {"You are flying over a large lagoon.", {81, 72, 73, 82, 68, 1, 0, 1}, - "The water's brink winds tortuously inland. There are some lights +.***\n"}, + "The water's brink winds tortuously inland. There are some lights +.***\n", {0} }, + /* 75 */ {"You are flying over a gently sloping plane.", {83, 71, 84, 85, 68, 1, 0, 1}, "The ground appears to be choked with vegetation.* The terrain is more\n\ -rugged +.**\n"}, +rugged +.**\n", {0} }, + /* 76 */ {"You are flying through a gorge.", {0, 0, 86, 71, 68, 1, 102, 1}, "This is a narrow, steep sided canyon lined with plants. The stars above\n\ glisten through the over hanging trees. The gorge leads to the\n\ -sea** +, and to a tumultuous origin +.\n"}, +sea** +, and to a tumultuous origin +.\n", {0} }, + /* 77 */ {"You are flying over a plantation.", {85, 81, 71, 88, 68, 1, 89, 1}, "It might be possible to land here, but not in the dark.* There are some lights\n\ -+ and *+.\n"}, ++ and *+.\n", {0} }, + /* 78 */ {"You are over the ocean.", {72, 78, 79, 74, 68, 1, 0, 1}, - "The deep green swells foam and roll into the shore **+*.\n"}, + "The deep green swells foam and roll into the shore **+*.\n", {0} }, + /* 79 */ {"You are flying along the coast.", {86, 72, 90, 73, 68, 1, 91, 1}, "The coastline here is very rocky. The surf in some places is violent\n\ -and explodes in a shower of sparkling, moonlit spray. ****\n"}, +and explodes in a shower of sparkling, moonlit spray. ****\n", {0} }, + /* 80 */ {"This is a beautiful coral beach.", {106, 0, 107, 108, 73, 0, 0, 0}, "Fine silver sand kissed lightly by warm tropical waters and illuminated\n\ by a huge tropical moon stretches at least 30 meters inland.\n\ -Gently swaying palm trees are +.***\n"}, +Gently swaying palm trees are +.***\n", {0} }, + /* 81 */ {"You are flying over a small fishing village.", {77, 74, 71, 82, 68, 1, 92, 1}, "A few thatched huts lit with torches and bonfires line a road below.\n\ -The road continues on ***+.\n"}, +The road continues on ***+.\n", {0} }, + /* 82 */ {"You are flying over a clearing.", {88, 72, 74, 87, 68, 1, 93, 1}, "There is a dock here (big enough for a seaplane) leading to a clearing.\n\ -The still waters of the lagoon reflects our orange turbo thrusters.****\n"}, +The still waters of the lagoon reflects our orange turbo thrusters.****\n", {0} }, + /* 83 */ {"You are flying over the shore.", {94, 75, 95, 96, 68, 1, 0, 1}, - "Rocky lava flows have overtaken the beach here.****\n"}, + "Rocky lava flows have overtaken the beach here.****\n", {0} }, + /* 84 */ {"You are flying in a wide valley.", {95, 97, 86, 75, 68, 1, 98, 1}, "This is a shallow valley yet the floor is obscured by a thick mist.\n\ -The valley opens into blackness +. The mist grows thicker +.**\n"}, +The valley opens into blackness +. The mist grows thicker +.**\n", {0} }, + /* 85 */ {"You are flying near the shore.", {96, 77, 75, 99, 68, 1, 0, 1}, "Very tall trees growing in neatly planted rows march off from the \n\ -water here towards the hills and down to the flat lands *+.**\n"}, +water here towards the hills and down to the flat lands *+.**\n", {0} }, + /* 86 */ {"You are flying around the very tip of the island.", {95, 79, 90, 84, 68, 1, 0, 1}, "Sheer cliffs rise several hundred feet to a tree covered summit. Far below,\n\ the grey sea gnaws voraciously at the roots of these cliffs. The island bends\n\ -around +** and +.\n"}, +around +** and +.\n", {0} }, + /* 87 */ {"You are flying along the coastline.", {99, 82, 88, 100, 68, 1, 101, 1}, "This is a narrow strip of sand lined with very few trees. The stars above\n\ flicker through wisps of clouds. The beach continues on -.* There\n\ -are some lights +.*\n"}, +are some lights +.*\n", {0} }, + /* 88 */ {"You are flying over several cottages and buildings", {99, 82, 77, 87, 68, 1, 103, 1}, "Directly below is small ornate house lit up with spot lights and decorative\n\ bulbs. A bell tower and a spurting fountain are nearby. Small dirt roads go\n\ -+ and +.**\n"}, ++ and +.**\n", {0} }, + /* 89 */ {"You are in a field of sugar cane.", {109, 110, 111, 112, 77, 0, 0, 0}, "These strong, thick canes give little shelter but many cuts and scrapes.\n\ -There are some large trees ***+.\n"}, +There are some large trees ***+.\n", {0} }, + /* 90 */ {"You are flying over the ocean.", {95, 78, 90, 86, 68, 1, 0, 1}, - "The water is a placid ebony.****\n"}, + "The water is a placid ebony.****\n", {0} }, + /* 91 */ {"You are on the coast road.", {113, 114, 115, 116, 79, 0, 0, 0}, "The road winds close to the shore here. The trees on either side press close\n\ in the darkness and seem to be watching us.** The road continues -\n\ -and -.\n"}, +and -.\n", {0} }, + /* 92 */ {"You are on the main street of the village.", {117, 118, 119, 120, 81, 0, 0, 0}, "The natives are having a festive luau here. Beautiful dancers gyrate in the\n\ torchlight to the rhythm of wooden drums. A suckling pig is sizzling in a\n\ bed of coals and ti leaves are spread with poi and tropical fruits. Several\n\ natives have come over to you and want you to join in the festivities.\n\ -There is a light burning in a bungalow +.***\n"}, +There is a light burning in a bungalow +.***\n", {0} }, + /* 93 */ {"You are at the sea plane dock.", {121, 122, 123, 124, 82, 0, 0, 0}, "The clearing is deserted. The grass is wet with the evening dew +.*\n\ -There is something set up +.*\n"}, +There is something set up +.*\n", {0} }, + /* 94 */ {"You are flying over the ocean.", {94, 83, 95, 96, 68, 1, 0, 1}, - "The black waves surge off shore here. The ocean becomes much calmer +.***\n"}, + "The black waves surge off shore here. The ocean becomes much calmer +.***\n", {0} }, + /* 95 */ {"You are flying along the coast.", {94, 84, 86, 83, 68, 1, 0, 1}, "The land is very low here with a river running into the sea +. There\n\ is a wide valley opening up +, but a strange mist is flowing out of it.\n\ -The very tip of the island is +.*\n"}, +The very tip of the island is +.*\n", {0} }, + /* 96 */ {"You are flying along the coast.", {94, 85, 83, 99, 68, 1, 0, 1}, - "The coast here is cluttered with rocky outcroppings.****\n"}, + "The coast here is cluttered with rocky outcroppings.****\n", {0} }, + /* 97 */ {"You are lost in a sea of fog.", {97, 104, 97, 97, 97, 1, 0, 1}, "What have you gotten us into?\n\ -I can't see a thing! ****\n"}, +I can't see a thing! ****\n", {0} }, + /* 98 */ {"You are on a gravel wash.", {125, 126, 127, 128, 84, 0, 0, 0}, "It is very dark here. A cool breeze is blowing from +. No moonlight can\n\ reach below a thick canopy of fog above. The sound of cascading water is\n\ -coming from +.**\n"}, +coming from +.**\n", {0} }, + /* 99 */ {"You are flying over a wide beach.", {96, 88, 85, 87, 68, 1, 105, 1}, - "There are some lighted buildings *+. Some trees are growing +.*\n"}, + "There are some lighted buildings *+. Some trees are growing +.*\n", {0} }, + /* 100 */ {"You are flying over the ocean.", {100, 100, 87, 100, 68, 1, 0, 1}, - "The black waves surge and splash against the rocky shore.****\n"}, + "The black waves surge and splash against the rocky shore.****\n", {0} }, + /* 101 */ {"You are on a narrow strip of sand.", {129, 130, 131, 0, 87, 0, 0, 0}, "Rather coarse sand makes this beach very steep and only a few meters wide.\n\ -A fresh ocean breeze is rustling the ferns **+.*\n"}, +A fresh ocean breeze is rustling the ferns **+.*\n", {0} }, + /* 102 */ {"This is Fern Canyon.", {0, 0, 132, 133, 76, 0, 0, 0}, "Delicate waving ferns flourish here, suckled by warm water dripping from \n\ every fissure and crevice in the solid rock walls. The stars above sparkle\n\ -through a thin mist. The canyon winds **-, and -.\n"}, +through a thin mist. The canyon winds **-, and -.\n", {0} }, + /* 103 */ {"This is the front lawn.", {134, 135, 136, 137, 88, 0, 0, 0}, "There is a small fountain lighted with green and yellow bulbs here where\n\ the driveway meets the lawn. Across the driveway, +, is an ornate white\n\ house lit with gas lamps. A bell tower here is awash in pale blue.* There\n\ -is a road + which turns into the driveway.*\n"}, +is a road + which turns into the driveway.*\n", {0} }, + /* 104 */ {"You have just crossed the crest of a mountain.", {97, 79, 86, 71, 68, 1, 0, 1}, "The fog vanished mysteriously as we flew over the crest.*\n\ -Far + I can see the ocean sparkling in the moonlight.**\n"}, +Far + I can see the ocean sparkling in the moonlight.**\n", {0} }, + /* 105 */ {"You are on a sandy beach.", {138, 139, 140, 0, 99, 0, 0, 0}, "Fine coral sand, a fresh sea breeze, and dramatic surf add to this beach's\n\ -appeal.** Stone steps lead to a lighted path in the gardens +.*\n"}, +appeal.** Stone steps lead to a lighted path in the gardens +.*\n", {0} }, + /* 106 */ {"You are among palm trees near the shore.", {141, 80, 142, 143, 73, 0, 0, 0}, "Arching coconut palms laden with fruit provide a canopy for the glistening\n\ white sand and sparse, dew covered grasses growing here. The forest grows\n\ -denser +. Crickets are chirping loudly here. The ocean is +.**\n"}, +denser +. Crickets are chirping loudly here. The ocean is +.**\n", {0} }, + /* 107 */ {"You are walking along the beach.", {144, 0, 145, 80, 73, 0, 0, 0}, "The warm tropical waters nuzzle your ankles as you walk. Above is a gorgeous\n\ starscape. The battlestar must be up there somewhere. The slope of the sand\n\ is so gentle that the surf only slides up the sand.** There are some rocks\n\ -+.*\n"}, ++.*\n", {0} }, + /* 108 */ {"You are walking along the beach.", {146, 0, 80, 147, 73, 0, 0, 0}, "The tide is out very far tonight, and it is possible to explore hidden rocks\n\ and caves not ordinarily accessible. Rich beds of seaweed have been exposed\n\ -to the cool night air.****\n"}, +to the cool night air.****\n", {0} }, + /* 109 */ {"You are in a papaya grove.", {148, 89, 149, 150, 77, 0, 0, 0}, "Slender trees with their large seven lobed leaves bulge with succulent fruit.\n\ -There are some tall trees +.***\n"}, +There are some tall trees +.***\n", {0} }, + /* 110 */ {"You are in a field of pineapple.", {89, 151, 152, 153, 77, 0, 0, 0}, "The sharp dagger like pineapple leaves can pierce the flesh and hold fast\n\ -a skewered victim with tiny barbs.* The field ends +.**\n"}, +a skewered victim with tiny barbs.* The field ends +.**\n", {0} }, + /* 111 */ {"You are in a field of kiwi plants.", {149, 154, 155, 89, 77, 0, 0, 0}, "Round hairy fruit hang from staked vines here. There are some trees +\n\ -and +. The field ends in a road +.*\n"}, +and +. The field ends in a road +.*\n", {0} }, + /* 112 */ {"You are in a large grove of coconuts.", {150, 153, 89, 156, 77, 0, 0, 0}, "These trees are much taller than any growing near the shore and the shadows\n\ -are also deeper. It's hard to keep my sense of direction.****\n"}, +are also deeper. It's hard to keep my sense of direction.****\n", {0} }, + /* 113 */ {"You are in the woods.", {157, 91, 158, 116, 79, 0, 0, 0}, "Tropical undergrowth makes the going rough here. Sword ferns give no strong\n\ foot hold and the dangling vines would gladly throttle one. The darkness is\n\ -so intense here that we stand in utter blackness.****\n"}, +so intense here that we stand in utter blackness.****\n", {0} }, + /* 114 */ {"You are at the shore.", {91, 0, 159, 145, 79, 0, 160, 0}, "The low minus tide tonight might make it possible to climb down to a\n\ small cave entrance below. Large rocks would usually churn the waves\n\ -asunder.*** The beach goes -.\n"}, +asunder.*** The beach goes -.\n", {0} }, + /* 115 */ {"You are on the coast road.", {158, 161, 162, 91, 79, 0, 0, 0}, "The road is beginning to turn slightly -. I can hear the surf +. The road\n\ -continues into the dark forest +.*\n"}, +continues into the dark forest +.*\n", {0} }, + /* 116 */ {"The road winds deeper into the trees.", {163, 142, 91, 164, 79, 0, 0, 0}, "Only narrow moonbeams filter through the dense foliage above. The moist rich\n\ earth has nurtured a myriad of slugs, snakes, and spiders to grow here. The\n\ -road continues - and *- into the shadows.*\n"}, +road continues - and *- into the shadows.*\n", {0} }, + /* 117 */ {"This is the front porch of the bungalow.", {165, 92, 0, 0, 81, 0, 0, 0}, "The veranda is lit by a small yellow bug light. The door leads -.\n\ The stone walk down to the luau is lined with burning torches +. That\n\ -roast pig smells good.**\n"}, +roast pig smells good.**\n", {0} }, + /* 118 */ {"You are on a path leading to the lagoon.", {92, 166, 167, 168, 81, 0, 0, 0}, "This path winds through the underbrush and towards the lagoon *+. The\n\ broad faced moon peeps though the branches above. The sound of drums echos\n\ -in the woods.**\n"}, +in the woods.**\n", {0} }, + /* 119 */ {"This is a dirt road.", {169, 118, 170, 92, 81, 0, 0, 0}, "**The road continues on - here for some distance. A bonfire and party light\n\ -up the night sky +.\n"}, +up the night sky +.\n", {0} }, + /* 120 */ {"You are on a dirt road.", {171, 118, 92, 172, 81, 0, 0, 0}, "**There is a village +. A huge bonfire licks at the trees, and a celebration\n\ of some sort is going on there. The smell of luscious cooking is tantalizing\n\ -my flared nostrils. The road continues +.\n"}, +my flared nostrils. The road continues +.\n", {0} }, + /* 121 */ {"You are on a dirt road.", {173, 93, 174, 175, 82, 0, 0, 0}, "This is a wide grassy clearing bedewed with droplets of evening mist. The\n\ trees alongside the road moan and whisper as we pass. They seem annoyed at\n\ -our presence. **The road continues - and -.\n"}, +our presence. **The road continues - and -.\n", {0} }, + /* 122 */ {"You are at the seaplane dock.", {93, 0, 176, 177, 82, 0, 0, 0}, "Not a living thing stirs the calm surface of the lagoon. The wooden planks\n\ creak unnaturally as we tread on them. The dock reaches a clearing +.\n\ -A dark trail leads around the lagoon **+.\n"}, +A dark trail leads around the lagoon **+.\n", {0} }, + /* 123 */ {"There are some tables on the lawn here.", {121, 122, 123, 93, 82, 0, 0, 0}, - "Some tables are strewn on the wet lawn.****\n"}, + "Some tables are strewn on the wet lawn.****\n", {0} }, + /* 124 */ {"You are nosing around in the bushes.", {124, 124, 93, 124, 82, 0, 0, 0}, "There is little here but some old beer cans. It is damp and dirty in here.\n\ -I think I stepped in something unpleasant. It would be best to go **-.*\n"}, +I think I stepped in something unpleasant. It would be best to go **-.*\n", {0} }, + /* 125 */ {"You are walking in a dry stream bed.", {178, 98, 179, 0, 84, 0, 0, 0}, "The large cobblestones are difficult to walk on. No starlight reaches\n\ below a black canopy of fog seemingly engulfing the whole island. A dirt\n\ -path along the wash is **+. The high bank is impossible to climb +.\n"}, +path along the wash is **+. The high bank is impossible to climb +.\n", {0} }, + /* 126 */ {"You are at the thermal pools.", {98, 0, 180, 181, 84, 0, 0, 0}, "Odd spluttering and belching water splashes up around the rocks here.\n\ A spectacular waterfall nearby tumbles down as a river of effervescent\n\ -bubbles. The air is quite warm and a cave entrance ***+ spews steam.\n"}, +bubbles. The air is quite warm and a cave entrance ***+ spews steam.\n", {0} }, + /* 127 */ {"You are in the woods.", {127, 180, 182, 98, 84, 0, 0, 0}, "It is pitch black in the forest here and my pant leg is caught on something.\n\ There may be poison oak here. What was that? A lantern just flickered by in\n\ -the dark! The sound of rushing water is coming from *+.**\n"}, +the dark! The sound of rushing water is coming from *+.**\n", {0} }, + /* 128 */ {"You are on a dirt trail.", {179, 181, 98, 0, 84, 0, 0, 0}, - "The trail seems to start here and head towards the forest +.** High, dark\n\ -cliffs border the trail +. Some crickets are chirping noisily.\n"}, +"The trail seems to start here and head towards the forest +.** High,\n\ +dark cliffs border the trail +. Some crickets are chirping\n\ +noisily.\n", {0} }, + /* 129 */ {"You are walking along the beach.", {183, 101, 184, 0, 87, 0, 0, 0}, - "The surf is rather tame tonight. The beach continues + and +.**\n"}, + "The surf is rather tame tonight. The beach continues + and +.**\n", {0} }, + /* 130 */ {"You are walking along the beach.", {101, 185, 186, 0, 87, 0, 0, 0}, - "This is not a very nice beach. The coarse sand hurts my feet.****\n"}, + "This is not a very nice beach. The coarse sand hurts my feet.****\n", {0} }, + /* 131 */ {"You are walking through some ferns.", {184, 186, 187, 101, 87, 0, 0, 0}, "This is a wide field growing only ferns and small shrubs.** In the dark\n\ it would be all to easy to stumble into a venomous snake. The ocean is\n\ -*+.\n"}, +*+.\n", {0} }, + /* 132 */ {"You are in a narrow canyon.", {0, 0, 188, 102, 76, 0, 0, 0}, "The steep sides here squeeze a little freshet through a gauntlet like\n\ -series of riffles and pools. The cool mountain air is refreshing.****\n"}, +series of riffles and pools. The cool mountain air is refreshing.****\n", {0} }, + /* 133 */ {"The canyon is much wider here.", {0, 0, 102, 189, 76, 0, 0, 0}, "The sheer rock walls rise 10 meters into darkness. A slender waterfall\n\ careens away from the face of the rock high above and showers the gravel\n\ floor with sparkling raindrops.** The canyon continues -\n\ -and -.\n"}, +and -.\n", {0} }, + /* 134 */ {"You are on the front porch of the cottage.", {190, 103, 0, 0, 0, 0, 0, 0}, "The veranda is deserted. A table and chair are the only things on the porch.\n\ Inside the house is a parlor lighted with an elegant chandelier. The door\n\ -leads -. The lawn and fountain are +.**\n"}, +leads -. The lawn and fountain are +.**\n", {0} }, + /* 135 */ {"You are in a palm grove.", {103, 191, 192, 105, 88, 0, 0, 0}, - "Crickets are chirping in the cool night air.****\n"}, + "Crickets are chirping in the cool night air.****\n", {0} }, + /* 136 */ {"You are on a dirt road.", {193, 192, 245, 103, 88, 0, 0, 0}, "There are many bright lights +. The road cleaves the darkness +.\n\ -A small dirt road goes -, and a drive way peals off +.\n"}, +A small dirt road goes -, and a driveway peels off +.\n", {0} }, + /* 137 */ {"You are in a field of small shrubs.", {184, 186, 103, 187, 88, 0, 0, 0}, "**Pine and other coniferous saplings are growing here. The rich brown\n\ soil is well watered. Across a large lawn +, there is a small cottage lighted\n\ -with spot lights and gas lamps. A cool land breeze is blowing.*\n"}, +with spot lights and gas lamps. A cool land breeze is blowing.*\n", {0} }, + /* 138 */ {"The beach is pretty rocky here.", {194, 105, 195, 0, 96, 0, 0, 0}, - "The tide is very low tonight. The beach is nicer *+.**\n"}, + "The tide is very low tonight. The beach is nicer *+.**\n", {0} }, + /* 139 */ {"The beach is almost 10 meters wide here.", {105, 183, 196, 0, 99, 0, 0, 0}, - "The sand has become more coarse and the beach steeper.****\n"}, + "The sand has become more coarse and the beach steeper.****\n", {0} }, + /* 140 */ {"You are in the gardens.", {195, 196, 197, 105, 99, 0, 0, 0}, "Shadowy expanses of lawn and leaf have been groomed and manicured here.\n\ The night sky is glowing with a full moon.** A lighted path leads -.\n\ -Stone steps lead down to the beach +.\n"}, +Stone steps lead down to the beach +.\n", {0} }, + /* 141 */ {"You are on the coast road.", {198, 106, 163, 199, 73, 0, 0, 0}, "The forest is dense on either side. The trees seem to be actually squeezing\n\ -together to keep us from passing. A feeling of emnity is in the air.**\n\ -The road continues - and -.\n"}, +together to keep us from passing. A feeling of enmity is in the air.**\n\ +The road continues - and -.\n", {0} }, + /* 142 */ {"You are in the forest.", {116, 107, 91, 106, 73, 0, 0, 0}, - "I suppose there are trees and ferns all around, but it is too dark to see.****\n"}, + "I suppose there are trees and ferns all around, but it is too dark to see.****\n", {0} }, + /* 143 */ {"You are in the forest.", {199, 108, 106, 146, 73, 0, 0, 0}, - "There are shadowy trees and ferns all around.****\n"}, + "There are shadowy trees and ferns all around.****\n", {0} }, + /* 144 */ {"You are in a copse.", {142, 107, 145, 80, 0, 0, 0, 0}, "This is a secret hidden thicket only noticeable from the beach. In the\n\ -moonlight, I can tell that someone has been digging here recently.****\n"}, +moonlight, I can tell that someone has been digging here recently.****\n", {0} }, + /* 145 */ {"You are at the tide pools.", {91, 0, 114, 107, 79, 0, 0, 0}, "These rocks and pools are the home for many sea anemones and crustaceans.\n\ -They are exposed because of the low tide. There is a beach ***+.\n"}, +They are exposed because of the low tide. There is a beach ***+.\n", {0} }, + /* 146 */ {"You are in the forest.", {199, 108, 143, 0, 73, 0, 0, 0}, "This is a shallow depression sheltered from the wind by a thick growth of \n\ thorny shrubs. It looks like someone is camping here. There is a fire pit\n\ with warm, crackling flames and coals here.* The beach is +.* The thorny\n\ -shrubs block the way -.\n"}, +shrubs block the way -.\n", {0} }, + /* 147 */ {"You are at the mouth of the lagoon.", {200, 0, 108, 201, 74, 0, 0, 0}, "The beach ends here where the coral reef rises to form a wide lagoon.\n\ A path winds around the lagoon to the -.* The beach continues\n\ -on -. Only water lies +.\n"}, +on -. Only water lies +.\n", {0} }, + /* 148 */ {"You are in a breadfruit grove.", {202, 109, 203, 204, 77, 0, 0, 0}, "The tall trees bend leisurely in the breeze, holding many round breadfruits\n\ close to their large serrated leaves. There are coconut palms +,\n\ -*+, and +.\n"}, +*+, and +.\n", {0} }, + /* 149 */ {"You are in a grove of mango trees.", {203, 111, 205, 109, 77, 0, 0, 0}, "The trees are not tall enough to obscure the view and the bright moonlight\n\ -makes it fairly easy to see.****\n"}, +makes it fairly easy to see.****\n", {0} }, + /* 150 */ {"You are in a grove of coconut palms.", {204, 112, 109, 206, 77, 0, 0, 0}, "All I can see around us are trees and ominous shapes darting in and out of the\n\ -shadows.****\n"}, +shadows.****\n", {0} }, + /* 151 */ {"You are in a coconut grove.", {110, 207, 208, 209, 77, 0, 0, 0}, - "There are countless trees here.****\n"}, + "There are countless trees here.****\n", {0} }, + /* 152 */ {"You are in a field of pineapple.", {154, 208, 210, 110, 77, 0, 0, 0}, - "The sharp leaves are cutting me to ribbons. There is a road **+.*\n"}, + "The sharp leaves are cutting me to ribbons. There is a road **+.*\n", {0} }, + /* 153 */ {"You are in a coconut grove.", {112, 209, 110, 211, 77, 0, 0, 0}, - "There is a field of something **+.*\n"}, + "There is a field of something **+.*\n", {0} }, + /* 154 */ {"You are on the edge of a kiwi and pineapple field.", {111, 152, 155, 110, 77, 0, 0, 0}, - "An irrigation ditch separates the two fields here. There is a road **+.*\n"}, + "An irrigation ditch separates the two fields here. There is a road **+.*\n", {0} }, + /* 155 */ {"This is a dirt road.", {205, 210, 212, 111, 77, 0, 0, 0}, - "The road runs - and - here. It is very dark in the forest.**\n"}, + "The road runs - and - here. It is very dark in the forest.**\n", {0} }, + /* 156 */ {"You are in a palm grove.", {206, 211, 112, 213, 77, 0, 0, 0}, - "There are trees all around us.****\n"}, + "There are trees all around us.****\n", {0} }, + /* 157 */ {"You are on the edge of a small clearing.", {157, 113, 157, 157, 79, 0, 0, 0}, "The ground is rather marshy here and the darkness is intense. A swarm of\n\ ravenous mosquitoes has descended upon you and has sent you quaking to your\n\ -knees.****\n"}, +knees.****\n", {0} }, + /* 158 */ {"You are in the woods.", {158, 115, 215, 113, 79, 0, 0, 0}, - "You have walked a long way and found only spider webs. ****\n"}, + "You have walked a long way and found only spider webs. ****\n", {0} }, + /* 159 */ {"You are walking along the shore.", {115, 0, 214, 114, 86, 0, 0, 0}, "You are now about 10 meters above the surf on a gently rising cliffside.**\n\ -The land rises +. There is a beach far +.\n"}, +The land rises +. There is a beach far +.\n", {0} }, + /* 160 */ {"You are just inside the entrance to the sea cave.", {246, 114, 0, 0, 114, 1, 0, 0}, "The sound of water dripping in darkness and the roar of the ocean just outside\n\ create a very unwelcoming atmosphere inside this cave. Only on rare occasions\n\ such as this is it possible to enter the forbidden catacombs... The cave\n\ -continues -.***\n"}, +continues -.***\n", {0} }, + /* 161 */ {"You are in a secret nook beside the road.", {115, 159, 162, 91, 79, 0, 0, 0}, "This little thicket is hidden from the road in the shadows of the forest.\n\ From here we have a clear view of any traffic along the road. A great hollow\n\ -tree stuffed with something is nearby. The road is +.***\n"}, +tree stuffed with something is nearby. The road is +.***\n", {0} }, + /* 162 */ {"You are on the coast road.", {215, 214, 0, 115, 86, 0, 0, 0}, - "The road turns abruptly - here, wandering deeper into the black forest.***\n"}, + "The road turns abruptly - here, wandering deeper into the black forest.***\n", {0} }, + /* 163 */ {"You are on a dirt road.", {216, 116, 113, 141, 79, 0, 0, 0}, "We are walking through a tunnel of unfriendly trees and shrubs. The tall\n\ ones bend over the roadway and reach down with their branches to grab us.\n\ Broad leafed plants at the roadside whisper in the darkness. Something\n\ -just darted across the road and into the bushes *+. Let's go *-.\n"}, +just darted across the road and into the bushes *+. Let's go *-.\n", {0} }, + /* 164 */ {"You have discovered a hidden thicket near the road.", {163, 142, 116, 106, 73, 0, 0, 0}, - "I would think it best to stay n the road. The forest seems very unfriendly\n\ -at night. The road is **+.*\n"}, + "I would think it best to stay on the road. The forest seems very unfriendly\n\ +at night. The road is **+.*\n", {0} }, + /* 165 */ {"You are in the living room.", {0, 117, 217, 218, 0, 0, 0, 0}, "A decorative entry with fresh flowers and wall to wall carpeting leads into\n\ -the living room here where a couch and two chairs converse with an end table.\n\ -*The exit is +.* The bedroom is +.\n"}, +the living room here where a couch and two chairs converge with an end table.\n\ +*The exit is +.* The bedroom is +.\n", {0} }, + /* 166 */ {"You are at the lagoon.", {118, 0, 167, 168, 81, 0, 0, 0}, "A small beach here is deserted except for some fishing nets. It is very\n\ peaceful at the lagoon at night. The sound of native drums is carried on\n\ the night breeze. There are paths leading off into darkness +,\n\ -*+, and +.\n"}, +*+, and +.\n", {0} }, + /* 167 */ {"You are at the lagoon.", {118, 0, 170, 166, 81, 0, 0, 0}, "The grass near the water is moist with the refreshing evening dew. Far away,\n\ -drums reverberate in the forest.** The path continues + and +.\n"}, +drums reverberate in the forest.** The path continues + and +.\n", {0} }, + /* 168 */ {"You are at the lagoon.", {118, 0, 166, 172, 81, 0, 0, 0}, "The path meanders through shadows of tussocks of grass, ferns, and thorny\n\ -bushes here and continues on **- and -.\n"}, +bushes here and continues on **- and -.\n", {0} }, + /* 169 */ {"You are in the woods.", {219, 119, 220, 92, 81, 0, 0, 0}, "There are plenty of ferns and thorny bushes here! Spider webs and probing\n\ -branches snare us as we stumble along in the pitch black night.****\n"}, +branches snare us as we stumble along in the pitch black night.****\n", {0} }, + /* 170 */ {"You are on a dirt road.", {220, 167, 199, 119, 74, 0, 0, 0}, "The road winds rather close to a large lagoon here and many sedges and tall\n\ -loom in the darkness *+. The road continues - and -.\n"}, +loom in the darkness *+. The road continues - and -.\n", {0} }, + /* 171 */ {"You are in the woods beside the road.", {221, 120, 92, 222, 81, 0, 0, 0}, - "The forest grows darker +. The road is +.**\n"}, + "The forest grows darker +. The road is +.**\n", {0} }, + /* 172 */ {"The road crosses the lagoon here.", {222, 0, 120, 174, 81, 0, 0, 0}, "Strange mists rising from the water engulf a rickety old enclosed bridge here.\n\ Spider webs catch our hair as we pass through its rotting timbers. I felt\n\ something drop on my neck. The road delves into the accursed forest\n\ -**+ and +.\n"}, +**+ and +.\n", {0} }, + /* 173 */ {"You are in a coconut palm grove.", {223, 121, 224, 225, 82, 0, 0, 0}, - "The tall palms are planted about 30 feet apart and the stary sky is clearly\n\ + "The tall palms are planted about 30 feet apart and the starry sky is clearly\n\ visible above. A low growing grass carpets the ground all around. The grove\n\ -continues +.***\n"}, +continues +.***\n", {0} }, + /* 174 */ {"You are walking along a dirt road.", {224, 176, 172, 121, 82, 0, 0, 0}, - "You are near misty patch of the roadway **+. The road continues -.\n"}, + "You are near misty patch of the roadway **+. The road continues -.\n", {0} }, + /* 175 */ {"You are on a dirt road.", {225, 177, 121, 226, 82, 0, 0, 0}, "The road turns abruptly - here, splitting a grove of palm trees.* In the\n\ -starlight I can also discern that the road continues - toward the lagoon.*\n"}, +starlight I can also discern that the road continues - toward the lagoon.*\n", {0} }, + /* 176 */ {"You are on a trail running around the lagoon.", {172, 0, 0, 122, 82, 0, 0, 0}, "The dark waters brush the trail here and the path crosses an old bridge\n\ -+. There is deep water + and +. The trail continues -.\n"}, ++. There is deep water + and +. The trail continues -.\n", {0} }, + /* 177 */ {"This is the mouth of the lagoon.", {175, 0, 122, 227, 82, 0, 0, 0}, "The coral reef wraps around a natural bay here to create a wide lagoon which\n\ winds tortuously inland.** A trail goes around the lagoon +.\n\ -The beach is -.\n"}, +The beach is -.\n", {0} }, + /* 178 */ {"You are in a dry stream bed.", {0, 125, 0, 0, 84, 0, 0, 0}, "The dry wash drains over a tall precipice here into a turbid morass below. The\n\ most noisome stench imaginable is wafting up to defile our nostrils. Above,\n\ the blackness is intense and a strange mist engulfs the island.* Let's go\n\ --.**\n"}, +-.**\n", {0} }, + /* 179 */ {"You are on a dirt path along the wash.", {0, 128, 125, 228, 84, 0, 0, 0}, - "The trail winds along the gravel wash and delves into the forest ***+.\n"}, + "The trail winds along the gravel wash and delves into the forest ***+.\n", {0} }, + /* 180 */ {"The thermal pools flow into a stream here.", {127, 0, 229, 126, 84, 0, 0, 0}, "The gurgling hot waters pour over boulders into a swiftly flowing\n\ -stream **+. The pools are +.\n"}, +stream **+. The pools are +.\n", {0} }, + /* 181 */ {"You are at the entrance to a cave.", {128, 230, 126, 0, 84, 0, 0, 0}, "A torch lights the entrance to the cave. Deep inside I can see shadows moving.\n\ -A path goes + from here. The entrance is +.**\n"}, +A path goes + from here. The entrance is +.**\n", {0} }, + /* 182 */ {"You are in the woods.", {182, 229, 182, 127, 84, 0, 0, 0}, "Thorns tangle your every effort to proceed.* The sound of rushing water is\n\ -+.**\n"}, ++.**\n", {0} }, + /* 183 */ {"You are walking along the beach.", {139, 129, 184, 0, 99, 0, 0, 0}, "Some dunes here progress inland and make it impossible to get very far in that\n\ -direction. The beach continues - and -.* The ocean is +.\n"}, +direction. The beach continues - and -.* The ocean is +.\n", {0} }, + /* 184 */ {"You are in the dunes.", {183, 101, 184, 129, 87, 0, 0, 0}, "The endless rolling and pitching sand dunes are enough to make one very queasy!\n\ The sand is cool and the stars are bright at the ocean. The only way I'm going\n\ -is ***+.\n"}, +is ***+.\n", {0} }, + /* 185 */ {"This is a lousy beach.", {130, 0, 0, 0, 87, 0, 0, 0}, "Volcanic and viciously sharp bitted grains of sand here bite like cold steel\n\ into my tender feet. I refuse to continue on. Let's get out of here. The\n\ -beach is better +.***\n"}, +beach is better +.***\n", {0} }, + /* 186 */ {"You are in a field of sparse ferns.", {131, 185, 187, 130, 87, 0, 0, 0}, "The lava rock outcroppings here will support few plants. There is more \n\ -vegetation +.** The ocean is +.\n"}, +vegetation +.** The ocean is +.\n", {0} }, + /* 187 */ {"You are in the woods.", {131, 131, 137, 131, 87, 0, 0, 0}, "Young trees and tall shrubs grow densely together here.\n\ -They grow thicker **+.*\n"}, +They grow thicker **+.*\n", {0} }, + /* 188 */ {"The canyon is no wider than a foot here.", {0, 0, 0, 132, 0, 0, 0, 0}, "The freshet is gushing through the narrow trough, but the canyon has grown\n\ -too narrow to follow it any farther.*** I guess we'll have to go -.\n"}, +too narrow to follow it any farther.*** I guess we'll have to go -.\n", {0} }, + /* 189 */ {"You are in a narrow part of the canyon.", {0, 0, 133, 232, 76, 0, 0, 0}, "The two sheer sides are no more than a few meters apart here. There is a stone\n\ door in the wall +. The gravelly floor runs with tiny rivulets seeping \n\ -from the ground itself.* The canyon continues - and -.\n"}, +from the ground itself.* The canyon continues - and -.\n", {0} }, + /* 190 */ {"You are in the drawing room.", {0, 134, 0, 0, 0, 0, 0, 0}, "Exquisitely decorated with plants and antique furniture of superb\n\ -craftsmanship, the parlor reflects its owners impeccable taste. The tropical\n\ +craftsmanship, the parlor reflects its owner's impeccable taste. The tropical\n\ night air pours in through open shutters *+. There doesn't seem \n\ to be anybody around. A large immaculate oaken desk is visible in the\n\ -study and it even has a old fashioned telephone to complete the decor.**\n"}, +study and it even has a old fashioned telephone to complete the decor.**\n", {0} }, + /* 191 */ {"You are in a palm grove.", {135, 191, 233, 191, 88, 0, 0, 0}, "Grassy rows of dew covered palms stretch as far as I can see.**\n\ -There is a road +.*\n"}, +There is a road +.*\n", {0} }, + /* 192 */ {"You are on a dirt road.", {136, 233, 234, 135, 88, 0, 0, 0}, "The road winds through a coconut palm grove here. It continues on - \n\ -and -.**\n"}, +and -.**\n", {0} }, + /* 193 */ {"The road leads to several large buildings here.", {235, 136, 236, 237, 88, 0, 0, 0}, "There is a lighted clubhouse +,* a large barn and stable +, and a\n\ -garage of similar construct to the barn +.\n"}, +garage of similar construct to the barn +.\n", {0} }, + /* 194 */ {"This part of the beach is impassable.", {0, 138, 0, 0, 96, 0, 0, 0}, - "The see is calm tonight. The beach goes *-.**\n"}, + "The see is calm tonight. The beach goes *-.**\n", {0} }, + /* 195 */ {"You are in the gardens.", {195, 140, 197, 138, 96, 0, 0, 0}, "Dew beaded grass sparkles in the moonlight. Tiny lamps beside the path light\n\ -the way to the ocean ***+.\n"}, +the way to the ocean ***+.\n", {0} }, + /* 196 */ {"You are in the gardens.", {140, 183, 197, 139, 99, 0, 0, 0}, - "Beautiful flowers and shrubs surround a lighted goldfish pond.****\n"}, + "Beautiful flowers and shrubs surround a lighted goldfish pond.****\n", {0} }, + /* 197 */ {"You are on a stone walk in the garden.", {195, 196, 238, 140, 99, 0, 0, 0}, - "The walk leads to a road **+.*\n"}, + "The walk leads to a road **+.*\n", {0} }, + /* 198 */ {"You are in the forest near the road.", {198, 141, 216, 198, 73, 0, 0, 0}, - "There are many thorny bushes here!****\n"}, + "There are many thorny bushes here!****\n", {0} }, + /* 199 */ {"You are at a fork in the road.", {239, 146, 141, 170, 73, 0, 0, 0}, "Two roads come together in the darkness here. One runs -,* the other \n\ -runs - and -.\n"}, +runs - and -.\n", {0} }, + /* 200 */ {"You are on a dirt path around the lagoon.", {170, 147, 146, 0, 74, 0, 0, 0}, - "The still waters reflect bending palms and a stary sky. It looks like\n\ -the path runs into a clearing +. The path continues -.**\n"}, + "The still waters reflect bending palms and a starry sky. It looks like\n\ +the path runs into a clearing +. The path continues -.**\n", {0} }, + /* 201 */ {"You are drowning in the lagoon.", {201, 201, 147, 201, 74, 0, 0, 0}, - "I suggest you get out before you become waterlogged.****\n"}, + "I suggest you get out before you become waterlogged.****\n", {0} }, + /* 202 */ {"You are in a coconut palm grove.", {202, 148, 203, 204, 77, 0, 0, 0}, - "****\n"}, + "****\n", {0} }, + /* 203 */ {"You are in a palm grove.", {202, 149, 205, 148, 77, 0, 0, 0}, - "****\n"}, + "****\n", {0} }, + /* 204 */ {"You are in a palm grove.", {202, 150, 148, 206, 77, 0, 0, 0}, - "****\n"}, + "****\n", {0} }, + /* 205 */ {"You are on a dirt road.", {203, 155, 212, 149, 77, 0, 0, 0}, "*This road ends here at a palm grove but continues on - for quite\n\ -some way.**\n"}, +some way.**\n", {0} }, + /* 206 */ {"You are in a coconut palm grove.", {204, 156, 150, 213, 77, 0, 0, 0}, - "****\n"}, + "****\n", {0} }, + /* 207 */ {"You are in a coconut grove.", {151, 219, 208, 209, 77, 0, 0, 0}, - "*The grove ends +.**\n"}, + "*The grove ends +.**\n", {0} }, + /* 208 */ {"You are in a coconut grove.", {152, 207, 239, 151, 77, 0, 0, 0}, - "**There is a dirt road +.*\n"}, + "**There is a dirt road +.*\n", {0} }, + /* 209 */ {"You are in a coconut grove.", {153, 207, 151, 211, 77, 0, 0, 0}, - "****\n"}, + "****\n", {0} }, + /* 210 */ {"This is a dirt road.", {205, 239, 212, 154, 77, 0, 0, 0}, - "The road continues - and -.**\n"}, + "The road continues - and -.**\n", {0} }, + /* 211 */ {"You are in a coconut grove.", {153, 209, 153, 213, 77, 0, 0, 0}, - "****\n"}, + "****\n", {0} }, + /* 212 */ {"You are in the woods near the road.", {205, 210, 212, 155, 77, 0, 0, 0}, - "There are many thorny bushes here!****\n"}, + "There are many thorny bushes here!****\n", {0} }, + /* 213 */ {"You are in a coconut grove.", {213, 213, 156, 234, 88, 0, 0, 0}, - "***The grove ends in a clearing +.\n"}, + "***The grove ends in a clearing +.\n", {0} }, + /* 214 */ {"You are walking along some high cliffs.", {162, 0, 0, 159, 86, 0, 0, 0}, "The island bends sharply + here with high cliffs -\n\ -and -. The cliffs are lower +.\n"}, +and -. The cliffs are lower +.\n", {0} }, + /* 215 */ {"You are at the coast road turn around.", {0, 162, 0, 158, 90, 0, 0, 0}, "The coast road ends here in a lookout with a view of the ocean.\n\ Far below, the waves crash against the rocks.\n\ -****\n"}, +****\n", {0} }, + /* 216 */ {"You are in the woods near the road.", {216, 163, 216, 198, 79, 0, 257, 0}, - "These thorny bushes are killing me.****\n"}, + "These thorny bushes are killing me.****\n", {0} }, + /* 217 */ {"You are in the kitchen.", {0, 0, 0, 165, 0, 0, 0, 0}, "A small gas stove and a refrigerator are all the only appliances here. The\n\ gas oven has been left on and the whole room is reeking with natural gas.\n\ -One spark from a match and.... The door out is ***+.\n"}, +One spark from a match and.... The door out is ***+.\n", {0} }, + /* 218 */ {"You are in the bedroom.", {0, 0, 165, 0, 0, 0, 0, 0}, "A soft feather comforter on top of layers of Answer blankets make this a very\n\ luxurious place to sleep indeed. There are also some end tables and a dresser\n\ -here.** The living room is +.*\n"}, +here.** The living room is +.*\n", {0} }, + /* 219 */ {"You are in the woods.", {207, 169, 220, 221, 81, 0, 0, 0}, - "The darkness is intense, but there seems to be a clearing +.***\n"}, + "The darkness is intense, but there seems to be a clearing +.***\n", {0} }, + /* 220 */ {"You are in the woods near the road.", {219, 170, 239, 169, 81, 0, 0, 0}, - "*As far as I can tell, there are two roads + and +.*\n"}, + "*As far as I can tell, there are two roads + and +.*\n", {0} }, + /* 221 */ {"You are in the woods.", {207, 171, 219, 222, 81, 0, 0, 0}, - "The spider webs thin out and the forest is clearer +.***\n"}, + "The spider webs thin out and the forest is clearer +.***\n", {0} }, + /* 222 */ {"You are on the lagoon's inland finger.", {0, 172, 171, 172, 81, 0, 0, 0}, "It is impossible to follow the lagoon any farther inland because of sharp\n\ -and very painful sedges.* The road is +.**\n"}, +and very painful sedges.* The road is +.**\n", {0} }, + /* 223 */ {"You are in a grassy coconut grove.", {240, 173, 224, 241, 82, 0, 0, 0}, - "The tall palms provide a ghostly canopy for the sandy ground covering.****\n"}, + "The tall palms provide a ghostly canopy for the sandy ground covering.****\n", {0} }, + /* 224 */ {"You are near the lagoon's inland finger.", {0, 174, 0, 173, 82, 0, 0, 0}, "Very sharp sedges make it impossible to follow the lagoon any farther inland.\n\ -*There is a road +.**\n"}, +*There is a road +.**\n", {0} }, + /* 225 */ {"You are on a dirt road.", {241, 175, 173, 226, 82, 0, 0, 0}, - "The road winds through a coconut grove here and continues - and -.**\n"}, + "The road winds through a coconut grove here and continues - and -.**\n", {0} }, + /* 226 */ {"You are in the woods near the road.", {226, 226, 175, 226, 82, 0, 0, 0}, - "**The road is +.*\n"}, + "**The road is +.*\n", {0} }, + /* 227 */ {"This is a beach?", {227, 227, 177, 0, 82, 0, 0, 0}, "Hard jagged rocks that pierce with every footstep hardly comprise a beach.**\n\ -Let's go -.*\n"}, +Let's go -.*\n", {0} }, + /* 228 */ {"The trail is lost in the woods here.", {241, 241, 179, 241, 84, 0, 0, 0}, - "The trail goes **-.*\n"}, + "The trail goes **-.*\n", {0} }, + /* 229 */ {"You are on the bank of a stream.", {182, 0, 242, 180, 84, 0, 0, 0}, - "The stream falls over several small boulders here and continues on **-.*\n"}, + "The stream falls over several small boulders here and continues on **-.*\n", {0} }, + /* 230 */ {"You are just inside the cave.", {181, 267, 0, 0, 0, 0, 0, 0}, "A steamy hot breath is belching from the depths of the earth within.* The\n\ -cave continues -.**\n"}, +cave continues -.**\n", {0} }, + /* 231 */ {"You are just inside the cave entrance.", {274, 0, 0, 0, 0, 0, 0, 0}, "The air is hot and sticky inside. The cave continues -. There is a \n\ stone door in the wall +. A wooden sign in the dust warns in old elven\n\ -runes, \"GSRF KDIRE NLVEMP!\".**\n"}, +runes, \"GSRF KDIRE NLVEMP!\".**\n", {0} }, + /* 232 */ {"You are at the edge of a huge chasm.", {0, 0, 189, 0, 76, 0, 0, 0}, "Several hundred feet down I can see the glimmer of placid water. The\n\ rivulets drain over the edge and trickle down into the depths. It is \n\ -impossible to climb down.** The canyon continues -.*\n"}, +impossible to climb down.** The canyon continues -.*\n", {0} }, + /* 233 */ {"You are on a dirt road.", {192, 241, 240, 191, 88, 0, 0, 0}, "The road winds through a coconut grove here. The road continues on into the\n\ -shadows - and -.**\n"}, +shadows - and -.**\n", {0} }, + /* 234 */ {"You are in a coconut palm grove near the road.", {193, 233, 213, 192, 88, 0, 0, 0}, - "***The road is +.\n"}, + "***The road is +.\n", {0} }, + /* 235 */ {"You are at the clubhouse.", {0, 193, 0, 0, 0, 0, 0, 0}, "The clubhouse is built over the most inland part of the lagoon. Tropical\n\ bananas and fragrant frangipani grow along the grassy shore. Walking across\n\ the short wooden bridge, we enter. Along one wall is a bar crowded with people.\n\ The restaurant and disco dance floor are filled to capacity. A rock group\n\ -electrocutes itself to the satisfaction of the audience.****\n"}, +electrocutes itself to the satisfaction of the audience.****\n", {0} }, + /* 236 */ {"You are in the stables.", {0, 0, 0, 193, 0, 0, 0, 0}, "Neighing horses snacking on hay and oats fill the stalls on both sides of\n\ the barn. It is rather warm in here but that is not the most offensive\n\ -part.****\n"}, +part.****\n", {0} }, + /* 237 */ {"You are in the old garage.", {0, 0, 193, 0, 0, 0, 0, 0}, "This is an old wooden building of the same vintage as the stables. Beneath\n\ a sagging roof stand gardening tools and greasy rags. Parked in the center\n\ is an underpowered Plymouth Volare' with a red and white striped golf cart\n\ -roof. ****\n"}, +roof. ****\n", {0} }, + /* 238 */ {"You are on a dirt road.", {197, 197, 243, 197, 85, 0, 0, 0}, "The road leads to a formal garden laced with lighted stone walks and tropical\n\ -flowers and trees.** The road continues -. A walk leads -.\n"}, +flowers and trees.** The road continues -. A walk leads -.\n", {0} }, + /* 239 */ {"You are on a dirt road.", {210, 199, 198, 220, 73, 0, 0, 0}, - "The road runs - and -.**\n"}, + "The road runs - and -.**\n", {0} }, + /* 240 */ {"You are in a coconut grove near the road.", {234, 223, 234, 233, 88, 0, 0, 0}, - "***The road is +.\n"}, + "***The road is +.\n", {0} }, + /* 241 */ {"You are on a dirt road.", {233, 225, 223, 226, 82, 0, 0, 0}, - "The road continues - and -.**\n"}, + "The road continues - and -.**\n", {0} }, + /* 242 */ {"The stream plummets over a cliff here.", {182, 0, 0, 229, 84, 0, 0, 0}, "Falling 10 agonizing meters into darkness, only droplets of the stream must\n\ be left to dance off the floor below. There is no way down, even with a\n\ -strong rope. ****\n"}, +strong rope. ****\n", {0} }, + /* 243 */ {"You are on a dirt road.", {0, 0, 244, 238, 85, 0, 0, 0}, - "**The road continues - and -.\n"}, + "**The road continues - and -.\n", {0} }, + /* 244 */ {"You are on a dirt road.", {0, 245, 0, 243, 88, 0, 0, 0}, - "*The road continues -* and -.\n"}, + "*The road continues -* and -.\n", {0} }, + /* 245 */ {"You are on a dirt road.", {244, 234, 213, 136, 88, 0, 0, 0}, - "The road goes -* and *-.\n"}, + "The road goes -* and *-.\n", {0} }, + /* 246 */ {"You are in a low passage.", {247, 160, 0, 0, 0, 0, 0, 0}, - "The ceiling here sparkles with iridiscent gems and minerals. Colorful starfish\n\ + "The ceiling here sparkles with iridescent gems and minerals. Colorful starfish\n\ and sea anemones cling to the slippery walls and floor. The passage continues\n\ -+.***\n"}, ++.***\n", {0} }, + /* 247 */ {"The walls are very close together here.", {248, 246, 0, 0, 0, 0, 0, 0}, "I can barely squeeze through the jagged opening. Slimy sea weeds provide\n\ no footing at all. This tunnel seems to be an ancient lava tube. There is\n\ -a large room +.***\n"}, +a large room +.***\n", {0} }, + /* 248 */ {"You are in the cathedral room.", {249, 247, 250, 251, 0, 0, 0, 0}, "Your light casts ghostly shadows on the walls but cannot pierce the \n\ engulfing darkness overhead. The sound of water dripping echoes in the void.\n\ -*I can see no passages leading out of this room.*** \n"}, +*I can see no passages leading out of this room.*** \n", {0} }, + /* 249 */ {"You are walking through a very round tunnel.", {252, 248, 0, 0, 252, 1, 0, 0}, "The round walls of this tunnel are amazingly smooth to the touch. A little\n\ trickle of water flows down the center. The tunnel climbs steadily +.\n\ -There is a large room +.**\n"}, +There is a large room +.**\n", {0} }, + /* 250 */ {"You are in the cathedral anteroom.", {0, 0, 0, 248, 253, 1, 0, 0}, "This small chamber with a flat stone floor is to one side of the cathedral \n\ room. We appear to be at the bottom of a tall narrow shaft. There are many \n\ puddles of water here. A staircase hewn from solid rock and black lava \n\ -leads up.*** The cathedral room is -.\n"}, +leads up.*** The cathedral room is -.\n", {0} }, + /* 251 */ {"You are in a wide chamber.", {0, 0, 248, 254, 0, 0, 0, 0}, "Water is sprinkling from the ceiling here. A shallow pool populated by a \n\ myriad of blind white creatures sparkles in your light. Tiny shrimp and\n\ crabs scurry away, frightened by the blinding rays.** The cave \n\ -continues + and +.\n"}, +continues + and +.\n", {0} }, + /* 252 */ {"You are at the top of a sloping passage.", {0, 249, 255, 256, 257, 1, 249, 0}, "There is much algae growing here, both green and brown specimens. I suspect\n\ that we are near the high tide zone, but no light can get in here. The walls\n\ -glisten with shiny minerals.** A hallway here runs + and -.\n"}, +glisten with shiny minerals.** A hallway here runs + and -.\n", {0} }, + /* 253 */ {"You are in an elaborately tiled room.", {0, 0, 258, 0, 0, 0, 250, 0}, "Large colorful tiles plate the floor and walls. The ceiling is a mosaic\n\ of gems set in gold. Hopefully it is only our footsteps that are echoing in\n\ this hollow chamber.** The room continues -. A stone staircase leads\n\ -down.*\n"}, +down.*\n", {0} }, + /* 254 */ {"You are at a dead end.", {0, 0, 251, 0, 0, 0, 0, 0}, "The walls here are alive with dark mussels. They click their shells menacingly\n\ -if we disturb them.** The only exit is +.*\n"}, +if we disturb them.** The only exit is +.*\n", {0} }, + /* 255 */ {"The tunnel is very low here.", {0, 0, 259, 252, 0, 0, 0, 0}, "You practically have to crawl on your knees to pass through this opening. The\n\ air is stiflingly damp, but you can't hear any sounds of water dripping.**\n\ -The crawlspace continues -. The tunnel seems wider +.\n"}, +The crawlspace continues -. The tunnel seems wider +.\n", {0} }, + /* 256 */ {"This is the supply room.", {0, 0, 252, 0, 0, 0, 0, 0}, "Picks and shovels line the walls here, as well as hard hats, boxes of\n\ dynamite, and a cartload of very high grade gold and silver ore.** \n\ -A tunnel leads off +.*\n"}, +A tunnel leads off +.*\n", {0} }, + /* 257 */ {"You have found a secret entrance to the catacombs", {0, 0, 0, 0, 216, 1, 252, 0}, - "Below is a wet, seaweed covered floor. Above is a way out.****\n"}, + "Below is a wet, seaweed covered floor. Above is a way out.****\n", {0} }, + /* 258 */ {"You are in the catacombs.", {0, 0, 260, 253, 0, 0, 0, 0}, "Ornate tombs and piles of treasure line the walls. Long spears with many\n\ blades, fine swords and coats of mail, heaps of coins, jewelry, pottery, \n\ and golden statues are tribute past kings and queens.** The catacombs\n\ -continue - and -.\n"}, +continue - and -.\n", {0} }, + /* 259 */ {"You are crawling on your stomach.", {0, 0, 261, 255, 0, 0, 0, 0}, "The passage is quite narrow and jagged, but the rock is no longer lava.\n\ It appears to be a form of granite.** The crawlspace continues -, \n\ -but I would just as soon go -.\n"}, +but I would just as soon go -.\n", {0} }, + /* 260 */ {"You are in the Sepulcher.", {0, 0, 0, 258, 0, 0, 0, 0}, "A single tomb is here. Encrusted with diamonds and opals, and secured with \n\ straps of a very hard, untarnished silver, this tomb must be of a great king.\n\ Vases overflowing with gold coins stand nearby. A line of verse on the wall\n\ -reads, \"Three he made and gave them to his daughters.\"****\n"}, +reads, \"Three he made and gave them to his daughters.\"****\n", {0} }, + /* 261 */ {"The passage is wider here.", {0, 0, 0, 259, 0, 0, 262, 0}, - "A ladder goes down into darkness here.*** A small crawlspace goes -.\n"}, + "A ladder goes down into darkness here.*** A small crawlspace goes -.\n", {0} }, + /* 262 */ {"You are at the bottom of a ladder.", {0, 0, 0, 0, 261, 1, 263, 0}, "This is a narrow platform to rest on before we continue either up or down this\n\ -rickety wooden ladder.****\n"}, +rickety wooden ladder.****\n", {0} }, + /* 263 */ {"You are standing in several inches of water.", {264, 0, 265, 266, 262, 1, 0, 0}, "This seems to be a working mine. Many different tunnels wander off following\n\ glowing veins of precious metal. The floor is flooded here since we must\n\ -be nearly at sea level. A ladder leads up.****\n"}, +be nearly at sea level. A ladder leads up.****\n", {0} }, + /* 264 */ {"The tunnel here is blocked by broken rocks.", {0, 263, 0, 0, 0, 0, 0, 0}, "The way is blocked, but if you had some dynamite, we might be able to blast our\n\ -way through.* The passage goes -.**\n"}, +way through.* The passage goes -.**\n", {0} }, + /* 265 */ {"The tunnel is too flooded to proceed.", {0, 0, 0, 263, 0, 0, 0, 0}, "Hidden shafts could swallow us if we tried to continue on down this tunnel.\n\ The flooding is already up to my waist. Large crystals overhead shimmer\n\ -rainbows of reflected light.*** Let's go -.\n"}, +rainbows of reflected light.*** Let's go -.\n", {0} }, + /* 266 */ {"The mine is less flooded here.", {0, 0, 263, 0, 0, 0, 0, 0}, "A meandering gold laden vein of quartz and blooming crystals of diamonds\n\ -and topaz burst from the walls of the cave. A passage goes -.***\n"}, +and topaz burst from the walls of the cave. A passage goes -.***\n", {0} }, + /* 267 */ {"You are inside the cave.", {230, 268, 0, 0, 0, 0, 0, 0}, "A hot steam swirls around our heads, and the walls are warm to the touch.\n\ -The trail winds - and -.**\n"}, +The trail winds - and -.**\n", {0} }, + /* 268 */ {"You are in a rather large chamber.", {267, 0, 0, 269, 0, 0, 269, 0}, "Beds of ferns and palm leaves make several cozy nests along the walls. In the\n\ center of the room is a throne of gold and silver.*** A passageway leads\n\ -down and +.\n"}, +down and +.\n", {0} }, + /* 269 */ {"You are walking along the edge of a huge abyss.", {0, 0, 268, 0, 268, 1, 270, 0}, "Steam is rising in great clouds from the immeasurable depths. A very narrow\n\ -trail winds down.** There is a tunnel -.*\n"}, +trail winds down.** There is a tunnel -.*\n", {0} }, + /* 270 */ {"You are on the edge of a huge abyss.", {0, 0, 0, 0, 269, 1, 271, 0}, - "The trail winds farther down.****\n"}, + "The trail winds farther down.****\n", {0} }, + /* 271 */ {"You are winding your way along the abyss.", {0, 0, 0, 0, 270, 1, 272, 0}, - "The trail continues up and down.****\n"}, + "The trail continues up and down.****\n", {0} }, + /* 272 */ {"You are on a wide shelf near the steamy abyss.", {0, 273, 0, 0, 271, 1, 0, 0}, "The stifling hot cave seems even hotter to me, staring down into this misty \n\ -abyss. A trail winds up.* A passageway leads -.**\n"}, +abyss. A trail winds up.* A passageway leads -.**\n", {0} }, + /* 273 */ {"You are in a wide tunnel leading to a fuming abyss.", {272, 274, 0, 0, 0, 0, 0, 0}, "The passageway winds through many beautiful formations of crystals and\n\ -sparkling minerals. The tunnel continues - and -.**\n"}, +sparkling minerals. The tunnel continues - and -.**\n", {0} }, + /* 274 */ {"You are in a tunnel.", {273, 231, 0, 0, 0, 0, 0, 0}, "It is very warm in here. The smell of steam and hot rocks permeates the place.\n\ -The cave continues - and -.**\n"}, +The cave continues - and -.**\n", {0} }, + /* 275 */ {"You are at the bottom of a pit.", {0, 0, 0, 0, 232, 0, 0, 0}, "At the top of the pit, a single star can be seen in the night sky. There\n\ doesn't appear to be any way to get out without a rope. I don't remember\n\ -how we got here.****\n"}, +how we got here.****\n", {0} }, }; diff --git a/battlestar/nightobjs.c b/battlestar/nightobjs.c index 5520061..fa65487 100644 --- a/battlestar/nightobjs.c +++ b/battlestar/nightobjs.c @@ -1,4 +1,4 @@ -/* $NetBSD: nightobjs.c,v 1.6 1997/10/11 02:07:31 lukem Exp $ */ +/* $NetBSD: nightobjs.c,v 1.8 1999/09/18 16:42:29 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)nightobjs.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: nightobjs.c,v 1.6 1997/10/11 02:07:31 lukem Exp $"); +__RCSID("$NetBSD: nightobjs.c,v 1.8 1999/09/18 16:42:29 jsm Exp $"); #endif #endif /* not lint */ diff --git a/battlestar/parse.c b/battlestar/parse.c index d391099..4470366 100644 --- a/battlestar/parse.c +++ b/battlestar/parse.c @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.6 1997/10/11 02:07:33 lukem Exp $ */ +/* $NetBSD: parse.c,v 1.12 2001/06/19 13:42:09 wiz Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,12 +38,22 @@ #if 0 static char sccsid[] = "@(#)parse.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: parse.c,v 1.6 1997/10/11 02:07:33 lukem Exp $"); +__RCSID("$NetBSD: parse.c,v 1.12 2001/06/19 13:42:09 wiz Exp $"); #endif #endif /* not lint */ #include "extern.h" +#define HASHSIZE 256 +#define HASHMUL 81 +#define HASHMASK (HASHSIZE - 1) + +static int hash __P((const char *)); +static void install __P((struct wlist *)); +static struct wlist *lookup __P((const char *)); + +static struct wlist *hashtab[HASHSIZE]; + void wordinit() { @@ -53,7 +63,7 @@ wordinit() install(w); } -int +static int hash(s) const char *s; { @@ -67,7 +77,7 @@ hash(s) return hashval; } -struct wlist * +static struct wlist * lookup(s) const char *s; { @@ -79,7 +89,7 @@ lookup(s) return NULL; } -void +static void install(wp) struct wlist *wp; { @@ -98,6 +108,7 @@ parse() { struct wlist *wp; int n; + int flag; wordnumber = 0; /* for cypher */ for (n = 0; n <= wordcount; n++) { @@ -109,4 +120,72 @@ parse() wordtype[n] = wp->article; } } + /* We never use adjectives for anything, so yank them all. */ + for (n = 1; n < wordcount; n++) + if (wordtype[n] == ADJS) { + int i; + for (i = n + 1; i < wordcount; i++) { + wordtype[i - 1] = wordtype[i]; + wordvalue[i - 1] = wordvalue[i]; + strcpy(words[i - 1], words[i]); + } + wordcount--; + } + /* Don't let a comma mean AND if followed by a verb. */ + for (n = 0; n < wordcount; n++) + if (wordvalue[n] == AND && words[n][0] == ',' + && wordtype[n + 1] == VERB) { + wordvalue[n] = -1; + wordtype[n] = -1; + } + /* Trim "AND AND" which can happen naturally at the end of a + * comma-delimited list. + */ + for (n = 1; n < wordcount; n++) + if (wordvalue[n - 1] == AND && wordvalue[n] == AND) { + int i; + for (i = n + 1; i < wordcount; i++) { + wordtype[i - 1] = wordtype[i]; + wordvalue[i - 1] = wordvalue[i]; + strcpy(words[i - 1], words[i]); + } + wordcount--; + } + + /* If there is a sequence (NOUN | OBJECT) AND EVERYTHING + * then move all the EVERYTHINGs to the beginning, since that's where + * they're expected. We can't get rid of the NOUNs and OBJECTs in + * case they aren't in EVERYTHING (i.e. not here or nonexistent). + */ + flag = 1; + while (flag) { + flag = 0; + for (n = 1; n < wordcount; n++) + if ((wordtype[n - 1] == NOUNS || wordtype[n - 1] == OBJECT) && + wordvalue[n] == AND && wordvalue[n + 1] == EVERYTHING) { + char tmpword[WORDLEN]; + wordvalue[n + 1] = wordvalue[n - 1]; + wordvalue[n - 1] = EVERYTHING; + wordtype[n + 1] = wordtype[n - 1]; + wordtype[n - 1] = OBJECT; + strcpy(tmpword, words[n - 1]); + strcpy(words[n - 1], words[n + 1]); + strcpy(words[n + 1], tmpword); + flag = 1; + } + /* And trim EVERYTHING AND EVERYTHING. */ + for (n = 1; n < wordcount; n++) + if (wordvalue[n - 1] == EVERYTHING && + wordvalue[n] == AND && wordvalue[n + 1] == EVERYTHING) { + int i; + for (i = n + 1; i < wordcount; i++) { + wordtype[i - 1] = wordtype[i + 1]; + wordvalue[i - 1] = wordvalue[i + 1]; + strcpy(words[i - 1], words[i + 1]); + } + wordcount--; + wordcount--; + flag = 1; + } + } } diff --git a/battlestar/room.c b/battlestar/room.c index 7947cfc..3cdc0e1 100644 --- a/battlestar/room.c +++ b/battlestar/room.c @@ -1,4 +1,4 @@ -/* $NetBSD: room.c,v 1.6 1997/10/11 02:07:35 lukem Exp $ */ +/* $NetBSD: room.c,v 1.10 2000/09/17 23:03:43 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)room.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: room.c,v 1.6 1997/10/11 02:07:35 lukem Exp $"); +__RCSID("$NetBSD: room.c,v 1.10 2000/09/17 23:03:43 jsm Exp $"); #endif #endif /* not lint */ @@ -52,12 +52,15 @@ writedes() int c; printf("\n\t%s\n", location[position].name); - if (beenthere[position] < 3) { + if (beenthere[position] < ROOMDESC || verbose) { compass = NORTH; for (p = location[position].desc; (c = *p++) != 0;) - if (c != '-' && c != '*' && c != '+') - putchar(c); - else { + if (c != '-' && c != '*' && c != '+') { + if (c == '=') + putchar('-'); + else + putchar(c); + } else { if (c != '*') printf(truedirec(compass, c)); compass++; diff --git a/battlestar/save.c b/battlestar/save.c index 3841d38..e37d109 100644 --- a/battlestar/save.c +++ b/battlestar/save.c @@ -1,4 +1,4 @@ -/* $NetBSD: save.c,v 1.8 1998/09/13 15:24:41 hubertf Exp $ */ +/* $NetBSD: save.c,v 1.10 2000/01/09 17:17:20 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,51 +38,24 @@ #if 0 static char sccsid[] = "@(#)save.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: save.c,v 1.8 1998/09/13 15:24:41 hubertf Exp $"); +__RCSID("$NetBSD: save.c,v 1.10 2000/01/09 17:17:20 jsm Exp $"); #endif #endif /* not lint */ #include "extern.h" void -restore(filename, len) +restore(filename) const char *filename; - size_t len; { - char *home; - char *home1; int n; int tmp; - size_t tmpl; FILE *fp; - if (memchr(filename, '/', len)) { - home1 = malloc(len + 1); - if (home1 == NULL) - errx(1, "out of memory"); - memcpy(home1, filename, len); - home1[len] = 0; - } else { - home = getenv("HOME"); - if (home != NULL) { - tmpl = strlen(home); - home1 = malloc(tmpl + len + 2); - if (home1 == NULL) - errx(1, "out of memory"); - memcpy(home1, home, tmpl); - home1[tmpl] = '/'; - memcpy(home1 + tmpl + 1, filename, len); - home1[tmpl + len + 1] = 0; - } else { - home1 = malloc(len + 1); - if (home1 == NULL) - errx(1, "out of memory"); - memcpy(home1, filename, len); - home1[len] = 0; - } - } - if ((fp = fopen(home1, "r")) == 0) { - err(1, "fopen %s", home1); + if (filename == NULL) + exit(1); /* Error determining save file name. */ + if ((fp = fopen(filename, "r")) == 0) { + err(1, "fopen %s", filename); } fread(&WEIGHT, sizeof WEIGHT, 1, fp); fread(&CUMBER, sizeof CUMBER, 1, fp); @@ -120,54 +93,25 @@ restore(filename, len) fread(&power, sizeof power, 1, fp); /* We must check the last read, to catch truncated save files */ if (fread(&ego, sizeof ego, 1, fp) < 1) - errx(1, "save file %s too short", home1); + errx(1, "save file %s too short", filename); fclose(fp); - free(home1); } void -save(filename, len) +save(filename) const char *filename; - size_t len; { - char *home; - char *home1; int n; int tmp; - size_t tmpl; FILE *fp; - if (memchr(filename, '/', len)) { - home1 = malloc(len + 1); - if (home1 == NULL) - errx(1, "out of memory"); - memcpy(home1, filename, len); - home1[len] = 0; - } else { - home = getenv("HOME"); - if (home != NULL) { - tmpl = strlen(home); - home1 = malloc(tmpl + len + 2); - if (home1 == NULL) - errx(1, "out of memory"); - memcpy(home1, home, tmpl); - home1[tmpl] = '/'; - memcpy(home1 + tmpl + 1, filename, len); - home1[tmpl + len + 1] = 0; - } else { - home1 = malloc(len + 1); - if (home1 == NULL) - errx(1, "out of memory"); - memcpy(home1, filename, len); - home1[len] = 0; - } - } - - if ((fp = fopen(home1, "w")) == NULL) { - warn("fopen %s", home1); + if (filename == NULL) + return; /* Error determining save file name. */ + if ((fp = fopen(filename, "w")) == NULL) { + warn("fopen %s", filename); return; } - printf("Saved in %s.\n", home1); + printf("Saved in %s.\n", filename); fwrite(&WEIGHT, sizeof WEIGHT, 1, fp); fwrite(&CUMBER, sizeof CUMBER, 1, fp); fwrite(&ourclock, sizeof ourclock, 1, fp); @@ -205,7 +149,55 @@ save(filename, len) fwrite(&ego, sizeof ego, 1, fp); fflush(fp); if (ferror(fp)) - warn("fwrite %s", home1); + warn("fwrite %s", filename); fclose(fp); - free(home1); +} + +/* + * Given a save file name (possibly from fgetln, so without terminating NUL), + * determine the name of the file to be saved to by adding the HOME + * directory if the name does not contain a slash. Name will be allocated + * with malloc(3). + */ +char * +save_file_name(filename, len) + const char *filename; + size_t len; +{ + char *home; + char *newname; + size_t tmpl; + + if (memchr(filename, '/', len)) { + newname = malloc(len + 1); + if (newname == NULL) { + warn(NULL); + return NULL; + } + memcpy(newname, filename, len); + newname[len] = 0; + } else { + home = getenv("HOME"); + if (home != NULL) { + tmpl = strlen(home); + newname = malloc(tmpl + len + 2); + if (newname == NULL) { + warn(NULL); + return NULL; + } + memcpy(newname, home, tmpl); + newname[tmpl] = '/'; + memcpy(newname + tmpl + 1, filename, len); + newname[tmpl + len + 1] = 0; + } else { + newname = malloc(len + 1); + if (newname == NULL) { + warn(NULL); + return NULL; + } + memcpy(newname, filename, len); + newname[len] = 0; + } + } + return newname; } diff --git a/battlestar/words.c b/battlestar/words.c index 44356ac..6bcc541 100644 --- a/battlestar/words.c +++ b/battlestar/words.c @@ -1,4 +1,4 @@ -/* $NetBSD: words.c,v 1.6 1997/10/11 02:07:39 lukem Exp $ */ +/* $NetBSD: words.c,v 1.10 2000/09/25 19:37:59 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,176 +38,183 @@ #if 0 static char sccsid[] = "@(#)words.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: words.c,v 1.6 1997/10/11 02:07:39 lukem Exp $"); +__RCSID("$NetBSD: words.c,v 1.10 2000/09/25 19:37:59 jsm Exp $"); #endif #endif /* not lint */ #include "extern.h" struct wlist wlist[] = { - {"knife", KNIFE, OBJECT}, - {"sword", SWORD, NOUNS}, - {"scabbard", SWORD, OBJECT}, - {"fine", SWORD, OBJECT}, - {"two-handed", TWO_HANDED, OBJECT}, - {"cleaver", CLEAVER, OBJECT}, - {"broadsword", BROAD, OBJECT}, - {"mail", MAIL, OBJECT}, - {"coat", MAIL, OBJECT}, - {"helmet", HELM, OBJECT}, - {"shield", SHIELD, OBJECT}, - {"maid", MAID, OBJECT}, - {"maid's", MAID, OBJECT}, - {"body", BODY, NOUNS}, - {"viper", VIPER, OBJECT}, - {"lamp", LAMPON, OBJECT}, - {"lantern", LAMPON, OBJECT}, - {"shoes", SHOES, OBJECT}, - {"pajamas", PAJAMAS, OBJECT}, - {"robe", ROBE, OBJECT}, - {"amulet", AMULET, NOUNS}, - {"medallion", MEDALION, NOUNS}, - {"talisman", TALISMAN, NOUNS}, - {"woodsman", DEADWOOD, OBJECT}, - {"woodsman's", DEADWOOD, OBJECT}, - {"mallet", MALLET, OBJECT}, - {"laser", LASER, OBJECT}, - {"pistol", LASER, OBJECT}, - {"blaster", LASER, OBJECT}, - {"gun", LASER, OBJECT}, - {"goddess", NORMGOD, NOUNS}, - {"grenade", GRENADE, OBJECT}, - {"chain", CHAIN, OBJECT}, - {"rope", ROPE, OBJECT}, - {"levis", LEVIS, OBJECT}, - {"pants", LEVIS, OBJECT}, - {"mace", MACE, OBJECT}, - {"shovel", SHOVEL, OBJECT}, - {"halberd", HALBERD, OBJECT}, - {"compass", COMPASS, OBJECT}, - {"elf", ELF, OBJECT}, - {"coins", COINS, OBJECT}, - {"matches", MATCHES, OBJECT}, - {"match", MATCHES, OBJECT}, - {"book", MATCHES, OBJECT}, - {"man", MAN, NOUNS}, - {"papayas", PAPAYAS, OBJECT}, - {"pineapple", PINEAPPLE, OBJECT}, - {"kiwi", KIWI, OBJECT}, - {"coconuts", COCONUTS, OBJECT}, - {"mango", MANGO, OBJECT}, - {"ring", RING, OBJECT}, - {"potion", POTION, OBJECT}, - {"bracelet", BRACELET, OBJECT}, - {"timer", TIMER, NOUNS}, - {"bomb", BOMB, OBJECT}, - {"warhead", BOMB, OBJECT}, - {"girl", NATIVE, NOUNS}, - {"native", NATIVE, NOUNS}, - {"horse", HORSE, OBJECT}, - {"stallion", HORSE, OBJECT}, - {"car", CAR, OBJECT}, - {"volare", CAR, OBJECT}, - {"pot", POT, OBJECT}, - {"jewels", POT, OBJECT}, - {"bar", BAR, OBJECT}, - {"diamond", BLOCK, OBJECT}, - {"block", BLOCK, OBJECT}, - {"up", UP, VERB}, - {"u", UP, VERB}, - {"down", DOWN, VERB}, - {"d", DOWN, VERB}, - {"ahead", AHEAD, VERB}, - {"a", AHEAD, VERB}, - {"back", BACK, VERB}, - {"b", BACK, VERB}, - {"right", RIGHT, VERB}, - {"r", RIGHT, VERB}, - {"left", LEFT, VERB}, - {"l", LEFT, VERB}, - {"take", TAKE, VERB}, - {"get", TAKE, VERB}, - {"use", USE, VERB}, - {"look", LOOK, VERB}, - {"lo", LOOK, VERB}, - {"quit", QUIT, VERB}, - {"q", QUIT, VERB}, - {"su", SU, VERB}, - {"drop", DROP, VERB}, - {"draw", DRAW, VERB}, - {"pull", DRAW, VERB}, - {"carry", DRAW, VERB}, - {"wear", WEARIT, VERB}, - {"sheathe", WEARIT, VERB}, - {"put", PUT, VERB}, - {"buckle", PUT, VERB}, - {"strap", PUT, VERB}, - {"tie", PUT, VERB}, - {"inven", INVEN, VERB}, - {"i", INVEN, VERB}, - {"everything", EVERYTHING, OBJECT}, - {"all", EVERYTHING, OBJECT}, - {"and", AND, CONJ}, - {"kill", KILL, VERB}, - {"fight", KILL, VERB}, - {"ravage", RAVAGE, VERB}, - {"rape", RAVAGE, VERB}, - {"undress", UNDRESS, VERB}, - {"throw", THROW, VERB}, - {"launch", LAUNCH, VERB}, - {"land", LANDIT, VERB}, - {"light", LIGHT, VERB}, - {"strike", LIGHT, VERB}, - {"follow", FOLLOW, VERB}, - {"chase", FOLLOW, VERB}, - {"kiss", KISS, VERB}, - {"love", LOVE, VERB}, - {"fuck", LOVE, VERB}, - {"give", GIVE, VERB}, - {"smite", SMITE, VERB}, - {"attack", SMITE, VERB}, - {"swing", SMITE, VERB}, - {"stab", SMITE, VERB}, - {"slice", SMITE, VERB}, - {"cut", SMITE, VERB}, - {"hack", SMITE, VERB}, - {"shoot", SHOOT, VERB}, - {"blast", SHOOT, VERB}, - {"on", ON, PREPS}, - {"off", OFF, PREPS}, - {"time", TIME, VERB}, - {"sleep", SLEEP, VERB}, - {"dig", DIG, VERB}, - {"eat", EAT, VERB}, - {"swim", SWIM, VERB}, - {"drink", DRINK, VERB}, - {"door", DOOR, NOUNS}, - {"save", SAVE, VERB}, - {"ride", RIDE, VERB}, - {"mount", RIDE, VERB}, - {"drive", DRIVE, VERB}, - {"start", DRIVE, VERB}, - {"score", SCORE, VERB}, - {"points", SCORE, VERB}, - {"bury", BURY, VERB}, - {"jump", JUMP, VERB}, - {"kick", KICK, VERB}, - {"kerosene", 0, ADJS}, - {"plumed", 0, ADJS}, - {"ancient", 0, ADJS}, - {"golden", 0, ADJS}, - {"gold", 0, ADJS}, - {"ostrich", 0, ADJS}, - {"rusty", 0, ADJS}, - {"old", 0, ADJS}, - {"dented", 0, ADJS}, - {"blue", 0, ADJS}, - {"purple", 0, ADJS}, - {"kingly", 0, ADJS}, - {"the", 0, ADJS}, - {"climb", 0, ADJS}, - {"move", 0, ADJS}, - {"make", 0, ADJS}, - {"to", 0, ADJS}, - {0} + { "knife", KNIFE, OBJECT, NULL }, + { "sword", SWORD, NOUNS, NULL }, + { "scabbard", SWORD, OBJECT, NULL }, + { "fine", SWORD, OBJECT, NULL }, + { "two-handed", TWO_HANDED, OBJECT, NULL }, + { "cleaver", CLEAVER, OBJECT, NULL }, + { "broadsword", BROAD, OBJECT, NULL }, + { "mail", MAIL, OBJECT, NULL }, + { "coat", MAIL, OBJECT, NULL }, + { "helmet", HELM, OBJECT, NULL }, + { "shield", SHIELD, OBJECT, NULL }, + { "maid", MAID, OBJECT, NULL }, + { "maid's", MAID, OBJECT, NULL }, + { "body", BODY, NOUNS, NULL }, + { "viper", VIPER, OBJECT, NULL }, + { "lamp", LAMPON, OBJECT, NULL }, + { "lantern", LAMPON, OBJECT, NULL }, + { "shoes", SHOES, OBJECT, NULL }, + { "pajamas", PAJAMAS, OBJECT, NULL }, + { "robe", ROBE, OBJECT, NULL }, + { "amulet", AMULET, NOUNS, NULL }, + { "medallion", MEDALION, NOUNS, NULL }, + { "talisman", TALISMAN, NOUNS, NULL }, + { "woodsman", DEADWOOD, OBJECT, NULL }, + { "woodsman's", DEADWOOD, OBJECT, NULL }, + { "mallet", MALLET, OBJECT, NULL }, + { "laser", LASER, OBJECT, NULL }, + { "pistol", LASER, OBJECT, NULL }, + { "blaster", LASER, OBJECT, NULL }, + { "gun", LASER, OBJECT, NULL }, + { "goddess", NORMGOD, NOUNS, NULL }, + { "grenade", GRENADE, OBJECT, NULL }, + { "chain", CHAIN, OBJECT, NULL }, + { "rope", ROPE, OBJECT, NULL }, + { "levis", LEVIS, OBJECT, NULL }, + { "pants", LEVIS, OBJECT, NULL }, + { "mace", MACE, OBJECT, NULL }, + { "shovel", SHOVEL, OBJECT, NULL }, + { "halberd", HALBERD, OBJECT, NULL }, + { "compass", COMPASS, OBJECT, NULL }, + { "elf", ELF, OBJECT, NULL }, + { "coins", COINS, OBJECT, NULL }, + { "matches", MATCHES, OBJECT, NULL }, + { "match", MATCHES, OBJECT, NULL }, + { "book", MATCHES, OBJECT, NULL }, + { "man", MAN, NOUNS, NULL }, + { "papaya", PAPAYAS, OBJECT, NULL }, + { "papayas", PAPAYAS, OBJECT, NULL }, + { "pineapple", PINEAPPLE, OBJECT, NULL }, + { "kiwi", KIWI, OBJECT, NULL }, + { "coconut", COCONUTS, OBJECT, NULL }, + { "coconuts", COCONUTS, OBJECT, NULL }, + { "mango", MANGO, OBJECT, NULL }, + { "ring", RING, OBJECT, NULL }, + { "potion", POTION, OBJECT, NULL }, + { "bracelet", BRACELET, OBJECT, NULL }, + { "timer", TIMER, NOUNS, NULL }, + { "bomb", BOMB, OBJECT, NULL }, + { "warhead", BOMB, OBJECT, NULL }, + { "girl", NATIVE, NOUNS, NULL }, + { "native", NATIVE, NOUNS, NULL }, + { "horse", HORSE, OBJECT, NULL }, + { "stallion", HORSE, OBJECT, NULL }, + { "car", CAR, OBJECT, NULL }, + { "volare", CAR, OBJECT, NULL }, + { "pot", POT, OBJECT, NULL }, + { "jewels", POT, OBJECT, NULL }, + { "bar", BAR, OBJECT, NULL }, + { "diamond", BLOCK, OBJECT, NULL }, + { "block", BLOCK, OBJECT, NULL }, + { "up", UP, VERB, NULL }, + { "u", UP, VERB, NULL }, + { "down", DOWN, VERB, NULL }, + { "d", DOWN, VERB, NULL }, + { "ahead", AHEAD, VERB, NULL }, + { "a", AHEAD, VERB, NULL }, + { "back", BACK, VERB, NULL }, + { "b", BACK, VERB, NULL }, + { "right", RIGHT, VERB, NULL }, + { "r", RIGHT, VERB, NULL }, + { "left", LEFT, VERB, NULL }, + { "l", LEFT, VERB, NULL }, + { "take", TAKE, VERB, NULL }, + { "get", TAKE, VERB, NULL }, + { "use", USE, VERB, NULL }, + { "look", LOOK, VERB, NULL }, + { "lo", LOOK, VERB, NULL }, + { "quit", QUIT, VERB, NULL }, + { "q", QUIT, VERB, NULL }, + { "su", SU, VERB, NULL }, + { "drop", DROP, VERB, NULL }, + { "draw", DRAW, VERB, NULL }, + { "pull", DRAW, VERB, NULL }, + { "carry", DRAW, VERB, NULL }, + { "wear", WEARIT, VERB, NULL }, + { "sheathe", WEARIT, VERB, NULL }, + { "put", PUT, VERB, NULL }, + { "buckle", PUT, VERB, NULL }, + { "strap", PUT, VERB, NULL }, + { "tie", PUT, VERB, NULL }, + { "inven", INVEN, VERB, NULL }, + { "i", INVEN, VERB, NULL }, + { "everything", EVERYTHING, OBJECT, NULL }, + { "all", EVERYTHING, OBJECT, NULL }, + { "and", AND, CONJ, NULL }, + { ",", AND, CONJ, NULL }, + { "kill", KILL, VERB, NULL }, + { "fight", KILL, VERB, NULL }, + { "ravage", RAVAGE, VERB, NULL }, + { "rape", RAVAGE, VERB, NULL }, + { "undress", UNDRESS, VERB, NULL }, + { "throw", THROW, VERB, NULL }, + { "launch", LAUNCH, VERB, NULL }, + { "land", LANDIT, VERB, NULL }, + { "light", LIGHT, VERB, NULL }, + { "strike", LIGHT, VERB, NULL }, + { "follow", FOLLOW, VERB, NULL }, + { "chase", FOLLOW, VERB, NULL }, + { "kiss", KISS, VERB, NULL }, + { "love", LOVE, VERB, NULL }, + { "fuck", LOVE, VERB, NULL }, + { "give", GIVE, VERB, NULL }, + { "smite", SMITE, VERB, NULL }, + { "attack", SMITE, VERB, NULL }, + { "swing", SMITE, VERB, NULL }, + { "stab", SMITE, VERB, NULL }, + { "slice", SMITE, VERB, NULL }, + { "cut", SMITE, VERB, NULL }, + { "hack", SMITE, VERB, NULL }, + { "shoot", SHOOT, VERB, NULL }, + { "blast", SHOOT, VERB, NULL }, + { "open", OPEN, VERB, NULL }, + { "unlock", OPEN, VERB, NULL }, + { "on", ON, PREPS, NULL }, + { "off", OFF, PREPS, NULL }, + { "time", TIME, VERB, NULL }, + { "sleep", SLEEP, VERB, NULL }, + { "dig", DIG, VERB, NULL }, + { "eat", EAT, VERB, NULL }, + { "swim", SWIM, VERB, NULL }, + { "drink", DRINK, VERB, NULL }, + { "door", DOOR, NOUNS, NULL }, + { "verbose", VERBOSE, VERB, NULL }, + { "brief", BRIEF, VERB, NULL }, + { "save", SAVE, VERB, NULL }, + { "ride", RIDE, VERB, NULL }, + { "mount", RIDE, VERB, NULL }, + { "drive", DRIVE, VERB, NULL }, + { "start", DRIVE, VERB, NULL }, + { "score", SCORE, VERB, NULL }, + { "points", SCORE, VERB, NULL }, + { "bury", BURY, VERB, NULL }, + { "jump", JUMP, VERB, NULL }, + { "kick", KICK, VERB, NULL }, + { "kerosene", 0, ADJS, NULL }, + { "plumed", 0, ADJS, NULL }, + { "ancient", 0, ADJS, NULL }, + { "golden", 0, ADJS, NULL }, + { "gold", 0, ADJS, NULL }, + { "ostrich", 0, ADJS, NULL }, + { "rusty", 0, ADJS, NULL }, + { "old", 0, ADJS, NULL }, + { "dented", 0, ADJS, NULL }, + { "blue", 0, ADJS, NULL }, + { "purple", 0, ADJS, NULL }, + { "kingly", 0, ADJS, NULL }, + { "the", 0, ADJS, NULL }, + { "climb", AUXVERB, VERB, NULL }, + { "move", AUXVERB, VERB, NULL }, + { "make", AUXVERB, VERB, NULL }, + { "to", 0, ADJS, NULL }, + { NULL, 0, 0, NULL } }; diff --git a/bcd/Makefrag b/bcd/Makefrag index f297cf2..0e62ea5 100644 --- a/bcd/Makefrag +++ b/bcd/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for bcd +# +# Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. bcd_DIRS := $(GAMESDIR) $(MAN6DIR) @@ -8,6 +34,3 @@ bcd_install: bcd_all $(INSTALL_BINARY) bcd/bcd $(INSTALL_PREFIX)$(GAMESDIR)/bcd $(HIDE_GAME) bcd $(INSTALL_MANUAL) bcd/bcd.6 - -bcd_check: bcd_all - date | bcd/bcd diff --git a/bcd/bcd.c b/bcd/bcd.c index 65b346c..23c357b 100644 --- a/bcd/bcd.c +++ b/bcd/bcd.c @@ -1,4 +1,4 @@ -/* $NetBSD: bcd.c,v 1.7 1997/10/10 09:54:18 lukem Exp $ */ +/* $NetBSD: bcd.c,v 1.11 2000/07/03 03:57:40 matt Exp $ */ /* * Copyright (c) 1989, 1993 @@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\ #if 0 static char sccsid[] = "@(#)bcd.c 8.2 (Berkeley) 3/20/94"; #else -__RCSID("$NetBSD: bcd.c,v 1.7 1997/10/10 09:54:18 lukem Exp $"); +__RCSID("$NetBSD: bcd.c,v 1.11 2000/07/03 03:57:40 matt Exp $"); #endif #endif /* not lint */ @@ -83,6 +83,7 @@ __RCSID("$NetBSD: bcd.c,v 1.7 1997/10/10 09:54:18 lukem Exp $"); #include #include +#include #include #include #include @@ -128,7 +129,7 @@ const u_short holes[256] = { #define bit(w,i) ((w)&(1<<(i))) int main __P((int, char *[])); -void printcard __P((char *)); +void printcard __P((unsigned char *)); int main(argc, argv) @@ -147,10 +148,10 @@ main(argc, argv) if (argc > 1) { while (--argc) - printcard(*++argv); + printcard((unsigned char *)*++argv); } else while (fgets(cardline, sizeof(cardline), stdin)) - printcard(cardline); + printcard((unsigned char *)cardline); exit(0); } @@ -158,17 +159,17 @@ main(argc, argv) void printcard(str) - char *str; + unsigned char *str; { static const char rowchars[] = " 123456789"; int i, row; unsigned char *p; /* ruthlessly remove newlines and truncate at 48 characters. */ - if ((p = strchr(str, '\n'))) + if ((p = (unsigned char *)strchr((char *)str, '\n'))) *p = '\0'; - if (strlen(str) > COLUMNS) + if (strlen((char *)str) > COLUMNS) str[COLUMNS] = '\0'; /* make string upper case. */ diff --git a/boggle/Makefile.bsd b/boggle/Makefile.bsd index 712ec03..ecfcfc2 100644 --- a/boggle/Makefile.bsd +++ b/boggle/Makefile.bsd @@ -1,25 +1,29 @@ -# $NetBSD: Makefile,v 1.12 1997/10/11 09:34:16 mycroft Exp $ +# $NetBSD: Makefile,v 1.19 2002/09/18 02:51:46 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 6/11/93 +.include + SUBDIR= boggle mkdict mkindex -MKDICT!=cd $(.CURDIR)/mkdict; \ - printf "xxx: .MAKE\n\t@echo \$${.OBJDIR}/mkdict\n" | ${MAKE} -s -f- -MKINDEX!=cd $(.CURDIR)/mkindex; \ - printf "xxx: .MAKE\n\t@echo \$${.OBJDIR}/mkindex\n" | ${MAKE} -s -f- -WORDS=${.CURDIR}/../../share/dict/web2 -FILES=dictionary dictindex +MKDICTDIR!= cd $(.CURDIR)/mkdict; ${PRINTOBJDIR} +MKDICT=${MKDICTDIR}/mkdict +MKINDEXDIR!= cd $(.CURDIR)/mkindex; ${PRINTOBJDIR} +MKINDEX=${MKINDEXDIR}/mkindex +WORDS=${NETBSDSRCDIR}/share/dict/web2 +DICTFILES=dictionary dictindex +.if ${MKSHARE} != "no" +FILES=${DICTFILES} FILESDIR=/usr/share/games/boggle -CLEANFILES+=${FILES} +.endif +CLEANFILES+=${DICTFILES} -all: ${FILES} +realall: ${FILES} ${MKDICT}: @cd ${.CURDIR}/mkdict && ${MAKE} ${MKINDEX}: @cd ${.CURDIR}/mkindex && ${MAKE} - dictionary: ${WORDS} ${MKDICT} rm -f ${.TARGET} diff --git a/boggle/Makefrag b/boggle/Makefrag index b909aae..137aea9 100644 --- a/boggle/Makefrag +++ b/boggle/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for boggle +# +# Copyright (c) 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. boggle_all: diff --git a/boggle/mkdict/Makefile.bsd b/boggle/mkdict/Makefile.bsd index 5b3f764..2966798 100644 --- a/boggle/mkdict/Makefile.bsd +++ b/boggle/mkdict/Makefile.bsd @@ -1,21 +1,9 @@ -# $NetBSD: Makefile,v 1.8 1998/04/13 14:14:39 lukem Exp $ +# $NetBSD: Makefile,v 1.12 2002/09/18 06:16:40 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 6/11/93 -PROG= mkdict -HOST_CPPFLAGS+=-I${.CURDIR}/../boggle -NOMAN= noman +NOMAN= # defined -# XXX for "make depend" -CPPFLAGS+=-I${.CURDIR}/../boggle +HOSTPROG= mkdict +HOST_CPPFLAGS+= -I${.CURDIR}/../boggle -# only needed during build -proginstall:: - -# Override these rules for cross-compilation -.c.o: - ${HOST_COMPILE.c} ${.IMPSRC} - -${PROG}: ${OBJS} - ${HOST_LINK.c} -o ${.TARGET} ${OBJS} - -.include +.include diff --git a/boggle/mkdict/Makefrag b/boggle/mkdict/Makefrag index d2e40ba..3e27969 100644 --- a/boggle/mkdict/Makefrag +++ b/boggle/mkdict/Makefrag @@ -1,10 +1,36 @@ # Makefrag - makefile fragment for boggle/mkdict +# +# Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. boggle_mkdict_CLEANFILES := dictionary # boggle_mkdict_DICTSRC is the dictionary that will be used to construct the # word list used by boggle. -boggle_mkdict_DICTSRC := hangman/words +boggle_mkdict_DICTSRC := $(DICTIONARY_SRC) boggle_mkdict_DIRS := $(BOGGLE_DIR) boggle_mkdict_INCS := -Iboggle/boggle diff --git a/boggle/mkdict/mkdict.c b/boggle/mkdict/mkdict.c index f0eaf17..1dfdcb4 100644 --- a/boggle/mkdict/mkdict.c +++ b/boggle/mkdict/mkdict.c @@ -1,4 +1,4 @@ -/* $NetBSD: mkdict.c,v 1.3 1997/10/11 02:12:21 lukem Exp $ */ +/* $NetBSD: mkdict.c,v 1.8 2001/08/29 18:22:56 jsm Exp $ */ /*- * Copyright (c) 1993 @@ -36,17 +36,15 @@ * SUCH DAMAGE. */ -#include -#ifndef lint -__COPYRIGHT("@(#) Copyright (c) 1993\n\ - The Regents of the University of California. All rights reserved.\n"); -#endif /* not lint */ - #ifndef lint +static const char copyright[] __attribute__((__unused__)) = + "@(#) Copyright (c) 1993\n\ + The Regents of the University of California. All rights reserved.\n"; #if 0 static char sccsid[] = "@(#)mkdict.c 8.1 (Berkeley) 6/11/93"; #else -__RCSID("$NetBSD: mkdict.c,v 1.3 1997/10/11 02:12:21 lukem Exp $"); +static const char rcsid[] __attribute__((__unused__)) = + "$NetBSD: mkdict.c,v 1.8 2001/08/29 18:22:56 jsm Exp $"; #endif #endif /* not lint */ @@ -62,11 +60,10 @@ __RCSID("$NetBSD: mkdict.c,v 1.3 1997/10/11 02:12:21 lukem Exp $"); #include #include #include -#include #include "bog.h" -int main __P((int, char *[])); +int main(int, char *[]); int main(argc, argv) @@ -85,7 +82,7 @@ main(argc, argv) for (nwords = 1; fgets(buf[current], MAXWORDLEN + 1, stdin) != NULL; ++nwords) { if ((p = strchr(buf[current], '\n')) == NULL) { - warnx("word too long: %s", buf[current]); + fprintf(stderr, "word too long: %s\n", buf[current]); while ((ch = getc(stdin)) != EOF && ch != '\n') ; if (ch == EOF) @@ -125,6 +122,11 @@ main(argc, argv) prev = !prev; current = !current; } - warnx("%d words", nwords); + fprintf(stderr, "%d words\n", nwords); + fflush(stdout); + if (ferror(stdout)) { + perror("error writing standard output"); + exit(1); + } exit(0); } diff --git a/boggle/mkindex/Makefile.bsd b/boggle/mkindex/Makefile.bsd index 448e795..cc5bdbd 100644 --- a/boggle/mkindex/Makefile.bsd +++ b/boggle/mkindex/Makefile.bsd @@ -1,21 +1,9 @@ -# $NetBSD: Makefile,v 1.6 1998/04/13 14:14:39 lukem Exp $ +# $NetBSD: Makefile,v 1.10 2002/09/18 06:16:40 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 6/11/93 -PROG= mkindex -HOST_CPPFLAGS+=-I${.CURDIR}/../boggle -NOMAN= noman +NOMAN= # defined -# XXX for "make depend" -CPPFLAGS+=-I${.CURDIR}/../boggle +HOSTPROG= mkindex +HOST_CPPFLAGS+= -I${.CURDIR}/../boggle -# only needed during build -proginstall:: - -# Override these rules for cross-compilation -.c.o: - ${HOST_COMPILE.c} ${.IMPSRC} - -${PROG}: ${OBJS} - ${HOST_LINK.c} -o ${.TARGET} ${OBJS} - -.include +.include diff --git a/boggle/mkindex/Makefrag b/boggle/mkindex/Makefrag index 71e191a..5d406b3 100644 --- a/boggle/mkindex/Makefrag +++ b/boggle/mkindex/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for boggle/mkindex +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. boggle_mkindex_CLEANFILES := dictindex boggle_mkindex_DIRS := $(BOGGLE_DIR) diff --git a/boggle/mkindex/mkindex.c b/boggle/mkindex/mkindex.c index 0c5593e..c14e229 100644 --- a/boggle/mkindex/mkindex.c +++ b/boggle/mkindex/mkindex.c @@ -1,4 +1,4 @@ -/* $NetBSD: mkindex.c,v 1.4 1998/09/11 13:16:05 hubertf Exp $ */ +/* $NetBSD: mkindex.c,v 1.8 2000/07/31 11:29:48 simonb Exp $ */ /*- * Copyright (c) 1993 @@ -36,17 +36,15 @@ * SUCH DAMAGE. */ -#include #ifndef lint -__COPYRIGHT("@(#) Copyright (c) 1993\n\ - The Regents of the University of California. All rights reserved.\n"); -#endif /* not lint */ +static const char copyright[] __attribute__((__unused__)) = "@(#) Copyright (c) 1993\n\ + The Regents of the University of California. All rights reserved.\n"; -#ifndef lint #if 0 static char sccsid[] = "@(#)mkindex.c 8.1 (Berkeley) 6/11/93"; #else -__RCSID("$NetBSD: mkindex.c,v 1.4 1998/09/11 13:16:05 hubertf Exp $"); +static const char rcsid[] __attribute__((__unused__)) = + "$NetBSD: mkindex.c,v 1.8 2000/07/31 11:29:48 simonb Exp $"; #endif #endif /* not lint */ @@ -55,13 +53,13 @@ __RCSID("$NetBSD: mkindex.c,v 1.4 1998/09/11 13:16:05 hubertf Exp $"); #include "bog.h" -int main __P((void)); -char *nextword __P((FILE *, char *, int *, int *)); +int main(void); +char *nextword(FILE *, char *, int *, int *); int main(void) { - int clen, rlen, prev; + int clen, rlen, prev, i; long off, start; char buf[MAXWORDLEN + 1]; @@ -69,14 +67,29 @@ main(void) off = start = 0L; while (nextword(stdin, buf, &clen, &rlen) != NULL) { if (*buf != prev) { + /* + * Boggle expects a full index even if the dictionary + * had no words beginning with some letters. + * So we write out entries for every letter from prev + * to *buf. + */ if (prev != '\0') printf("%c %6ld %6ld\n", prev, start, off - 1); + for (i = (prev ? prev + 1 : 'a'); i < *buf; i++) + printf("%c %6ld %6ld\n", i, off, off - 1); prev = *buf; start = off; } off += clen + 1; } printf("%c %6ld %6ld\n", prev, start, off - 1); + for (i = prev + 1; i <= 'z'; i++) + printf("%c %6ld %6ld\n", i, off, off - 1); + fflush(stdout); + if (ferror(stdout)) { + perror("error writing standard output"); + exit(1); + } exit(0); } diff --git a/caesar/Makefrag b/caesar/Makefrag index ae5cb24..70b08dc 100644 --- a/caesar/Makefrag +++ b/caesar/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for caesar +# +# Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. caesar_DIRS := $(GAMESDIR) $(MAN6DIR) @@ -11,6 +37,3 @@ caesar_install: caesar_all $(HIDE_GAME) rot13 $(INSTALL_MANUAL) caesar/caesar.6 $(INSTALL_MANUAL) caesar.6 rot13.6 - -#caesar_check: caesar_all -# caesar/caesar diff --git a/countmail/Makefrag b/countmail/Makefrag index 037a1b2..5911293 100644 --- a/countmail/Makefrag +++ b/countmail/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for countmail +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. countmail_DIRS := $(GAMESDIR) $(MAN6DIR) diff --git a/countmail/countmail b/countmail/countmail index fa763e4..e574d6c 100644 --- a/countmail/countmail +++ b/countmail/countmail @@ -1,8 +1,8 @@ #!/bin/sh -# $NetBSD: countmail,v 1.3 1998/08/15 09:16:27 mycroft Exp $ +# $NetBSD: countmail,v 1.5 2002/07/02 17:18:21 mycroft Exp $ # -# Copyright (c) 1998 The NetBSD Foundation, Inc. +# Copyright (c) 1998, 2002 The NetBSD Foundation, Inc. # All rights reserved. # # This code is derived from software contributed to The NetBSD Foundation @@ -61,125 +61,103 @@ v=$1 #done #exec 0<&- -result= +set -- g=0 +v=000$v while :; do case $v in - 0 | '') break ;; - ?) v=00$v ;; - ??) v=0$v ;; - esac - - case $v in + '' | 0 | 00) break ;; *000) ;; *) case $g in - 0) ;; - 1) val=THOUSAND ;; - 2) val=MILLION ;; - 3) val=BILLION ;; - 4) val=TRILLION ;; - 5) val=QUADRILLION ;; - 6) val=QUINTILLION ;; - 7) val=SEXTILLION ;; - 8) val=SEPTILLION ;; + 0) x= ;; + 1) x=THOUSAND ;; + 2) x=MILLION ;; + 3) x=BILLION ;; + 4) x=TRILLION ;; + 5) x=QUADRILLION ;; + 6) x=QUINTILLION ;; + 7) x=SEXTILLION ;; + 8) x=SEPTILLION ;; *) echo "YOU HAVE TOO MUCH MAIL!" 1>&2 exit 1 ;; esac - case $g in - 0) ;; - *) result="$val $result" ;; + case $v in + *10) y=TEN ;; + *11) y=ELEVEN ;; + *12) y=TWELVE ;; + *13) y=THIRTEEN ;; + *14) y=FOURTEEN ;; + *15) y=FIFTEEN ;; + *16) y=SIXTEEN ;; + *17) y=SEVENTEEN ;; + *18) y=EIGHTEEN ;; + *19) y=NINETEEN ;; + *2?) y=TWENTY ;; + *3?) y=THIRTY ;; + *4?) y=FORTY ;; + *5?) y=FIFTY ;; + *6?) y=SIXTY ;; + *7?) y=SEVENTY ;; + *8?) y=EIGHTY ;; + *9?) y=NINETY ;; + *) y= ;; esac + + case $v in + *[01]? | *?0) ;; + *) y=$y- ;; + esac + + case $v in + *1?) ;; + *1) y=${y}ONE ;; + *2) y=${y}TWO ;; + *3) y=${y}THREE ;; + *4) y=${y}FOUR ;; + *5) y=${y}FIVE ;; + *6) y=${y}SIX ;; + *7) y=${y}SEVEN ;; + *8) y=${y}EIGHT ;; + *9) y=${y}NINE ;; + esac + + case $v in + *1??) z=ONE ;; + *2??) z=TWO ;; + *3??) z=THREE ;; + *4??) z=FOUR ;; + *5??) z=FIVE ;; + *6??) z=SIX ;; + *7??) z=SEVEN ;; + *8??) z=EIGHT ;; + *9??) z=NINE ;; + *) z= ;; + esac + + set $z ${z:+HUNDRED} $y $x $* ;; esac g=$(($g + 1)) - - case $v in - *?10) val=TEN ;; - *?11) val=ELEVEN ;; - *?12) val=TWELVE ;; - *?13) val=THIRTEEN ;; - *?14) val=FOURTEEN ;; - *?15) val=FIFTEEN ;; - *?16) val=SIXTEEN ;; - *?17) val=SEVENTEEN ;; - *?18) val=EIGHTEEN ;; - *?19) val=NINETEEN ;; - *) - case $v in - *?2?) val=TWENTY ;; - *?3?) val=THIRTY ;; - *?4?) val=FOURTY ;; - *?5?) val=FIFTY ;; - *?6?) val=SIXTY ;; - *?7?) val=SEVENTY ;; - *?8?) val=EIGHTY ;; - *?9?) val=NINETY ;; - *) val= ;; - esac - - case $v in - *?0? | *??0) ;; - *) val=${val}- ;; - esac - - case $v in - *??1) val=${val}ONE ;; - *??2) val=${val}TWO ;; - *??3) val=${val}THREE ;; - *??4) val=${val}FOUR ;; - *??5) val=${val}FIVE ;; - *??6) val=${val}SIX ;; - *??7) val=${val}SEVEN ;; - *??8) val=${val}EIGHT ;; - *??9) val=${val}NINE ;; - esac - ;; - esac - - case $v in - *?00) ;; - *) result="$val $result" ;; - esac - - case $v in - *1??) val=ONE ;; - *2??) val=TWO ;; - *3??) val=THREE ;; - *4??) val=FOUR ;; - *5??) val=FIVE ;; - *6??) val=SIX ;; - *7??) val=SEVEN ;; - *8??) val=EIGHT ;; - *9??) val=NINE ;; - esac - - case $v in - *0??) ;; - *) result="$val HUNDRED $result" ;; - esac - v=${v%%???} done -plural=S +p=S -case "$result" in - "") result=ZERO ;; - "ONE ") plural= ;; +case "$*" in + "") set ZERO ;; + ONE) p= ;; esac -set -- $result - echo "$*! -$* NEW MAIL MESSAGE$plural! +$* MAIL MESSAGE$p! HAHAHAHAHA!" diff --git a/cribbage/Makefile.bsd b/cribbage/Makefile.bsd index 8440563..537e0ea 100644 --- a/cribbage/Makefile.bsd +++ b/cribbage/Makefile.bsd @@ -1,6 +1,8 @@ -# $NetBSD: Makefile,v 1.10 1998/02/18 22:37:31 jtc Exp $ +# $NetBSD: Makefile,v 1.12 1999/02/13 02:54:21 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 +.include + PROG= cribbage DPADD= ${LIBCURSES} LDADD= -lcurses @@ -8,8 +10,10 @@ SRCS= extern.c crib.c cards.c instr.c io.c score.c support.c MAN= cribbage.6 HIDEGAME=hidegame SETGIDGAME=yes +.if ${MKSHARE} != "no" FILES= cribbage.n FILESNAME=cribbage.instr FILESDIR=/usr/share/games +.endif .include diff --git a/cribbage/Makefrag b/cribbage/Makefrag index f7104f4..4dbbdd8 100644 --- a/cribbage/Makefrag +++ b/cribbage/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for cribbage +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. cribbage_DIRS := $(GAMESDIR) $(MAN6DIR) $(shell dirname $(CRIBBAGE_INSTRFILE)) diff --git a/cribbage/cards.c b/cribbage/cards.c index d24b3ec..29eed58 100644 --- a/cribbage/cards.c +++ b/cribbage/cards.c @@ -1,4 +1,4 @@ -/* $NetBSD: cards.c,v 1.4 1997/10/10 12:32:22 lukem Exp $ */ +/* $NetBSD: cards.c,v 1.6 1999/09/30 18:01:32 jsm Exp $ */ /*- * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)cards.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: cards.c,v 1.4 1997/10/10 12:32:22 lukem Exp $"); +__RCSID("$NetBSD: cards.c,v 1.6 1999/09/30 18:01:32 jsm Exp $"); #endif #endif /* not lint */ diff --git a/cribbage/crib.c b/cribbage/crib.c index d51c9a5..5f89539 100644 --- a/cribbage/crib.c +++ b/cribbage/crib.c @@ -1,4 +1,4 @@ -/* $NetBSD: crib.c,v 1.10 1998/08/30 09:19:37 veego Exp $ */ +/* $NetBSD: crib.c,v 1.16 2001/12/06 11:59:45 blymn Exp $ */ /*- * Copyright (c) 1980, 1993 @@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ #if 0 static char sccsid[] = "@(#)crib.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: crib.c,v 1.10 1998/08/30 09:19:37 veego Exp $"); +__RCSID("$NetBSD: crib.c,v 1.16 2001/12/06 11:59:45 blymn Exp $"); #endif #endif /* not lint */ @@ -76,6 +76,8 @@ main(argc, argv) f = fopen(_PATH_LOG, "a"); if (f == NULL) warn("fopen %s", _PATH_LOG); + if (f != NULL && fileno(f) < 3) + exit(1); /* Revoke setgid privileges */ setregid(getgid(), getgid()); @@ -110,7 +112,7 @@ main(argc, argv) initscr(); (void)signal(SIGINT, rint); - crmode(); + cbreak(); noecho(); Playwin = subwin(stdscr, PLAY_Y, PLAY_X, 0, 0); @@ -130,7 +132,7 @@ main(argc, argv) mvcur(0, COLS - 1, LINES - 1, 0); fflush(stdout); instructions(); - crmode(); + cbreak(); noecho(); clear(); refresh(); @@ -194,8 +196,6 @@ makeboard() void gamescore() { - extern int Lastscore[]; - if (pgames || cgames) { mvprintw(SCORE_Y + 1, SCORE_X + 28, "Games: %3d", pgames); mvprintw(SCORE_Y + 7, SCORE_X + 28, "Games: %3d", cgames); diff --git a/cribbage/cribbage.6.in b/cribbage/cribbage.6.in index 002adc0..4eb0677 100644 --- a/cribbage/cribbage.6.in +++ b/cribbage/cribbage.6.in @@ -1,4 +1,4 @@ -.\" $NetBSD: cribbage.6,v 1.5 1997/10/10 12:32:26 lukem Exp $ +.\" $NetBSD: cribbage.6,v 1.10 2002/09/30 12:43:22 wiz Exp $ .\" .\" Copyright (c) 1980, 1993 .\" The Regents of the University of California. All rights reserved. @@ -45,9 +45,9 @@ .Sh DESCRIPTION .Nm plays the card game cribbage, with the program playing one hand -and the user the other. The program will initially ask the user if -the rules of the game are needed \- if so, it will print out -the appropriate section from +and the user the other. +The program will initially ask the user if the rules of the game are +needed \(en if so, it will print out the appropriate section from .Em According to Hoyle with .Xr more 1 . @@ -57,10 +57,10 @@ options include: .Bl -tag -width indent .It Fl e When the player makes a mistake scoring his hand or crib, provide an -explanation of the correct score. (This is especially useful for -beginning players.) +explanation of the correct score. +(This is especially useful for beginning players.) .It Fl q -Print a shorter form of all messages \- this is only recommended for +Print a shorter form of all messages \(en this is only recommended for users who have played the game without specifying this option. .It Fl r Instead of asking the player to cut the deck, the program will randomly @@ -72,24 +72,23 @@ first asks the player whether he wishes to play a short game ( .Dq once around , to 61) or a long game ( .Dq twice around , -to 121). A -response of +to 121). +A response of .Sq Ic s -will result in a short game, any other response will -play a long game. +will result in a short game, any other response will play a long game. .Pp At the start of the first game, the program -asks the player to cut the deck to determine who gets the -first crib. The user should respond with a number between 0 and -51, indicating how many cards down the deck is to be cut. The player -who cuts the lower ranked card gets the first crib. +asks the player to cut the deck to determine who gets the first crib. +The user should respond with a number between 0 and +51, indicating how many cards down the deck is to be cut. +The player who cuts the lower ranked card gets the first crib. If more than one game is played, the loser of the previous game gets the first crib in the current game. .Pp For each hand, the program first prints the player's hand, whose crib it is, and then asks the player -to discard two cards into the crib. The cards are prompted for -one per line, and are typed as explained below. +to discard two cards into the crib. +The cards are prompted for one per line, and are typed as explained below. .Pp After discarding, the program cuts the deck (if it is the player's crib) or asks the player to cut the deck (if it's its crib); in the latter @@ -98,11 +97,12 @@ how far down the remaining 40 cards are to be cut. .Pp After cutting the deck, play starts with the non-dealer (the person who doesn't have the crib) leading the first card. -Play continues, as per cribbage, until all cards are exhausted. The -program keeps track of the scoring of all points and the total of +Play continues, as per cribbage, until all cards are exhausted. +The program keeps track of the scoring of all points and the total of the cards on the table. .Pp -After play, the hands are scored. The program requests the player to +After play, the hands are scored. +The program requests the player to score his hand (and the crib, if it is his) by printing out the appropriate cards (and the cut card enclosed in brackets). Play continues until one player reaches the game limit (61 or 121). @@ -111,7 +111,8 @@ A carriage return when a numeric input is expected is equivalent to typing the lowest legal value; when cutting the deck this is equivalent to choosing the top card. .Pp -Cards are specified as rank followed by suit. The ranks may be specified +Cards are specified as rank followed by suit. +The ranks may be specified as one of: .Sq a , .Sq 2 , @@ -140,9 +141,9 @@ or alternatively, one of: .Sq ten , .Sq jack , .Sq queen , -and +and .Sq king . -Suits may be specified as: +Suits may be specified as: .Sq s , .Sq h , .Sq d , @@ -154,16 +155,17 @@ or alternatively as: .Sq diamonds , and .Sq clubs . -A card may be specified as: +A card may be specified as: .Dq Ao rank Ac \ Aq suit , -or: +or: .Dq Ao rank Ac of Aq suit . If the single letter rank and suit designations are used, the space -separating the suit and rank may be left out. Also, if only one card +separating the suit and rank may be left out. +Also, if only one card of the desired rank is playable, typing the rank is sufficient. -For example, if your hand was +For example, if your hand was .Dq 2H, 4D, 5C, 6H, JC, and KD -and it was desired to discard the king of diamonds, any of +and it was desired to discard the king of diamonds, any of the following could be typed: .Sq k , .Sq king , @@ -177,7 +179,7 @@ the following could be typed: .Sq king diamonds , .Sq king of diamonds . .Sh FILES -.Bl -tag -width @gamesdir@/cribbage -compact +.Bl -tag -width @cribbage_instrfile@ -compact .It Pa @gamesdir@/cribbage .It Pa @cribbage_scorefile@ .It Pa @cribbage_instrfile@ diff --git a/cribbage/cribbage.h b/cribbage/cribbage.h index 492b315..bcaa8ea 100644 --- a/cribbage/cribbage.h +++ b/cribbage/cribbage.h @@ -1,4 +1,4 @@ -/* $NetBSD: cribbage.h,v 1.4 1998/09/13 15:27:27 hubertf Exp $ */ +/* $NetBSD: cribbage.h,v 1.8 2002/12/06 01:48:24 thorpej Exp $ */ /* * Copyright (c) 1980, 1993 @@ -59,9 +59,10 @@ extern BOOLEAN rflag; /* if all cuts random */ extern BOOLEAN quiet; /* if suppress random mess */ extern BOOLEAN playing; /* currently playing game */ -extern char expl[]; /* string for explanation */ +extern char explan[]; /* string for explanation */ -void addmsg __P((const char *, ...)); +void addmsg __P((const char *, ...)) + __attribute__((__format__(__printf__, 1, 2))); int adjust __P((const CARD [], CARD)); int anymove __P((const CARD [], int, int)); int anysumto __P((const CARD [], int, int, int)); @@ -89,7 +90,8 @@ int is_one __P((CARD, const CARD [], int)); void makeboard __P((void)); void makedeck __P((CARD [])); void makeknown __P((const CARD [], int)); -void msg __P((const char *, ...)); +void msg __P((const char *, ...)) + __attribute__((__format__(__printf__, 1, 2))); int msgcard __P((CARD, BOOLEAN)); int msgcrd __P((CARD, BOOLEAN, const char *, BOOLEAN)); int number __P((int, int, const char *)); diff --git a/cribbage/extern.c b/cribbage/extern.c index 7aac39f..12e23ba 100644 --- a/cribbage/extern.c +++ b/cribbage/extern.c @@ -1,4 +1,4 @@ -/* $NetBSD: extern.c,v 1.4 1997/10/10 12:32:29 lukem Exp $ */ +/* $NetBSD: extern.c,v 1.6 2002/12/06 01:48:24 thorpej Exp $ */ /*- * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)extern.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: extern.c,v 1.4 1997/10/10 12:32:29 lukem Exp $"); +__RCSID("$NetBSD: extern.c,v 1.6 2002/12/06 01:48:24 thorpej Exp $"); #endif #endif /* not lint */ @@ -52,7 +52,7 @@ BOOLEAN iwon = FALSE; /* if comp won last game */ BOOLEAN quiet = FALSE; /* if suppress random mess */ BOOLEAN rflag = FALSE; /* if all cuts random */ -char expl[128]; /* explanation */ +char explan[128]; /* explanation */ int cgames = 0; /* number games comp won */ int cscore = 0; /* comp score in this game */ diff --git a/cribbage/instr.c b/cribbage/instr.c index d297184..5c7738c 100644 --- a/cribbage/instr.c +++ b/cribbage/instr.c @@ -1,4 +1,4 @@ -/* $NetBSD: instr.c,v 1.7 1997/10/11 02:44:31 lukem Exp $ */ +/* $NetBSD: instr.c,v 1.9 1999/11/09 15:06:32 drochner Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)instr.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: instr.c,v 1.7 1997/10/11 02:44:31 lukem Exp $"); +__RCSID("$NetBSD: instr.c,v 1.9 1999/11/09 15:06:32 drochner Exp $"); #endif #endif /* not lint */ @@ -90,7 +90,7 @@ instructions() _exit(1); } execl("/bin/sh", "sh", "-c", path, NULL); - warn("%s", ""); + warn(NULL); _exit(1); default: do { diff --git a/cribbage/io.c b/cribbage/io.c index 5c2f7e7..21075e2 100644 --- a/cribbage/io.c +++ b/cribbage/io.c @@ -1,4 +1,4 @@ -/* $NetBSD: io.c,v 1.10 1997/10/10 12:32:32 lukem Exp $ */ +/* $NetBSD: io.c,v 1.15 2002/05/26 00:12:11 wiz Exp $ */ /*- * Copyright (c) 1980, 1993 @@ -38,24 +38,19 @@ #if 0 static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: io.c,v 1.10 1997/10/10 12:32:32 lukem Exp $"); +__RCSID("$NetBSD: io.c,v 1.15 2002/05/26 00:12:11 wiz Exp $"); #endif #endif /* not lint */ #include #include #include +#include #include #include #include #include -#if __STDC__ -#include -#else -#include -#endif - #include "deck.h" #include "cribbage.h" #include "cribcur.h" @@ -392,21 +387,11 @@ int Mpos = 0; static int Newpos = 0; void -#if __STDC__ msg(const char *fmt, ...) -#else -msg(fmt, va_alist) - char *fmt; - va_dcl -#endif { va_list ap; -#if __STDC__ va_start(ap, fmt); -#else - va_start(ap); -#endif (void)vsprintf(&Msgbuf[Newpos], fmt, ap); Newpos = strlen(Msgbuf); va_end(ap); @@ -418,21 +403,11 @@ msg(fmt, va_alist) * Add things to the current message */ void -#if __STDC__ addmsg(const char *fmt, ...) -#else -addmsg(fmt, va_alist) - char *fmt; - va_dcl -#endif { va_list ap; -#if __STDC__ va_start(ap, fmt); -#else - va_start(ap); -#endif (void)vsprintf(&Msgbuf[Newpos], fmt, ap); Newpos = strlen(Msgbuf); va_end(ap); @@ -612,7 +587,7 @@ getline() void rint(signo) - int signo __attribute__((unused)); + int signo __attribute__((__unused__)); { bye(); exit(1); diff --git a/cribbage/score.c b/cribbage/score.c index 29f9d3f..6677314 100644 --- a/cribbage/score.c +++ b/cribbage/score.c @@ -1,4 +1,4 @@ -/* $NetBSD: score.c,v 1.6 1998/08/30 09:19:37 veego Exp $ */ +/* $NetBSD: score.c,v 1.9 2002/12/06 01:48:24 thorpej Exp $ */ /*- * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: score.c,v 1.6 1998/08/30 09:19:37 veego Exp $"); +__RCSID("$NetBSD: score.c,v 1.9 2002/12/06 01:48:24 thorpej Exp $"); #endif #endif /* not lint */ @@ -122,7 +122,7 @@ scorehand(hand, starter, n, crb, do_explain) CARD h[(CINHAND + 1)]; char buf[32]; - expl[0] = '\0'; /* initialize explanation */ + explan[0] = '\0'; /* initialize explanation */ score = 0; flag = TRUE; k = hand[0].suit; @@ -132,29 +132,29 @@ scorehand(hand, starter, n, crb, do_explain) if (hand[i].suit == starter.suit) { score++; if (do_explain) - strcat(expl, "His Nobs"); + strcat(explan, "His Nobs"); } h[i] = hand[i]; } if (flag && n >= CINHAND) { - if (do_explain && expl[0] != '\0') - strcat(expl, ", "); + if (do_explain && explan[0] != '\0') + strcat(explan, ", "); if (starter.suit == k) { score += 5; if (do_explain) - strcat(expl, "Five-flush"); + strcat(explan, "Five-flush"); } else if (!crb) { score += 4; - if (do_explain && expl[0] != '\0') - strcat(expl, ", Four-flush"); + if (do_explain && explan[0] != '\0') + strcat(explan, ", Four-flush"); else - strcpy(expl, "Four-flush"); + strcpy(explan, "Four-flush"); } } - if (do_explain && expl[0] != '\0') - strcat(expl, ", "); + if (do_explain && explan[0] != '\0') + strcat(explan, ", "); h[n] = starter; sorthand(h, n + 1); /* sort by rank */ i = 2 * fifteens(h, n + 1); @@ -162,9 +162,9 @@ scorehand(hand, starter, n, crb, do_explain) if (do_explain) { if (i > 0) { (void) sprintf(buf, "%d points in fifteens", i); - strcat(expl, buf); + strcat(explan, buf); } else - strcat(expl, "No fifteens"); + strcat(explan, "No fifteens"); } i = pairuns(h, n + 1); score += i; @@ -172,9 +172,9 @@ scorehand(hand, starter, n, crb, do_explain) if (i > 0) { (void) sprintf(buf, ", %d points in pairs, %d in runs", pairpoints, runpoints); - strcat(expl, buf); + strcat(explan, buf); } else - strcat(expl, ", No pairs/runs"); + strcat(explan, ", No pairs/runs"); } return (score); } @@ -354,7 +354,7 @@ pegscore(crd, tbl, n, sum) int adjust(cb, tnv) const CARD cb[]; - CARD tnv __attribute__((unused)); + CARD tnv __attribute__((__unused__)); { long scr; int i, c0, c1; diff --git a/cribbage/support.c b/cribbage/support.c index 1ccbdc9..288bb0c 100644 --- a/cribbage/support.c +++ b/cribbage/support.c @@ -1,4 +1,4 @@ -/* $NetBSD: support.c,v 1.4 1997/10/10 12:32:36 lukem Exp $ */ +/* $NetBSD: support.c,v 1.6 2002/12/06 01:48:25 thorpej Exp $ */ /*- * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)support.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: support.c,v 1.4 1997/10/10 12:32:36 lukem Exp $"); +__RCSID("$NetBSD: support.c,v 1.6 2002/12/06 01:48:25 thorpej Exp $"); #endif #endif /* not lint */ @@ -152,7 +152,7 @@ plyrhand(hand, s) msg("You should have taken %d, not %d!", i, j); } if (explain) - msg("Explanation: %s", expl); + msg("Explanation: %s", explan); do_wait(); } else win = chkscr(&pscore, i); diff --git a/dm/Makefile.bsd b/dm/Makefile.bsd index d32cad7..c3fa4b2 100644 --- a/dm/Makefile.bsd +++ b/dm/Makefile.bsd @@ -1,11 +1,17 @@ -# $NetBSD: Makefile,v 1.8 1997/11/19 08:23:37 mrg Exp $ +# $NetBSD: Makefile,v 1.11 2002/09/18 03:23:00 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 +.include + # -DLOG log games PROG= dm +SRCS= dm.c utmpentry.c MAN= dm.8 dm.conf.5 # shouldn't be necessary; just in case. BINGRP= games BINMODE=2555 +.PATH.c: ${NETBSDSRCDIR}/usr.bin/who +CPPFLAGS+=-I${NETBSDSRCDIR}/usr.bin/who -DSUPPORT_UTMPX -DSUPPORT_UTMP + .include diff --git a/dm/Makefrag b/dm/Makefrag index 2da4540..8f1cc29 100644 --- a/dm/Makefrag +++ b/dm/Makefrag @@ -1,7 +1,33 @@ # Makefrag - makefile fragment for dm +# +# Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. # Add -DLOG if you want logging -dm_DEFS := # -DLOG +dm_DEFS := $(GETLOADAVG_DEFS) # -DLOG dm_DIRS := $(GAMESDIR) $(MAN8DIR) $(MAN5DIR) dm_all: dm/dm dm/dm.8 dm/dm.conf.5 diff --git a/dm/README.linux b/dm/README.linux index 2014c1c..d5196a8 100644 --- a/dm/README.linux +++ b/dm/README.linux @@ -10,4 +10,4 @@ Add -DLOG to the DEFS in the Makefile if you want logging of games playing. Joseph S. Myers -jsm28@cam.ac.uk +jsm@polyomino.org.uk diff --git a/dm/dm.8.in b/dm/dm.8.in index 0bafd99..54e7ad2 100644 --- a/dm/dm.8.in +++ b/dm/dm.8.in @@ -1,4 +1,4 @@ -.\" $NetBSD: dm.8,v 1.6 1998/06/08 12:41:41 lukem Exp $ +.\" $NetBSD: dm.8,v 1.8 2003/02/25 10:34:45 wiz Exp $ .\" .\" Copyright (c) 1987, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -48,7 +48,7 @@ is a program used to regulate game playing. .Nm expects to be invoked with the name of a game that a user wishes to play. This is done by creating symbolic links to -.Nm "" , +.Nm , in the directory .Pa @gamesdir@ for all of the regulated games. @@ -63,8 +63,7 @@ program. determines if the requested game is available and, if so, runs it. The file .Pa @dm_configfile@ -controls the conditions under which games may -be run. +controls the conditions under which games may be run. .Pp The file .Pa @dm_nogamesfile@ @@ -99,7 +98,7 @@ running the games setgid First, all games that allow users to run .Ux commands should carefully -set both the real and effective group id's immediately before executing +set both the real and effective group ids immediately before executing those commands. Probably more important is that .Nm diff --git a/dm/dm.c b/dm/dm.c index 4899729..c5a108f 100644 --- a/dm/dm.c +++ b/dm/dm.c @@ -1,4 +1,5 @@ -/* $NetBSD: dm.c,v 1.11 1998/09/13 15:27:27 hubertf Exp $ */ +/* $NetBSD: dm.c,v 1.17 2002/08/02 03:06:24 christos Exp $ */ +/* For Linux: still using old utmp interface from version 1.16. */ /* * Copyright (c) 1987, 1993 @@ -43,7 +44,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993\n\ #if 0 static char sccsid[] = "@(#)dm.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: dm.c,v 1.11 1998/09/13 15:27:27 hubertf Exp $"); +__RCSID("$NetBSD: dm.c,v 1.17 2002/08/02 03:06:24 christos Exp $"); #endif #endif /* not lint */ @@ -83,7 +84,7 @@ int users __P((void)); int main(argc, argv) - int argc __attribute__((unused)); + int argc __attribute__((__unused__)); char *argv[]; { char *cp; @@ -116,10 +117,7 @@ play(args) { char pbuf[MAXPATHLEN]; - (void)strncpy(pbuf, _PATH_HIDE, sizeof(pbuf) - 1); - (void)strncpy(pbuf + sizeof(_PATH_HIDE) - 1, game, - sizeof(pbuf) - sizeof(_PATH_HIDE) - 1); - pbuf[sizeof(pbuf) - 1] = '\0'; + snprintf(pbuf, sizeof(pbuf), "%s%s", _PATH_HIDE, game); if (priority > 0) /* < 0 requires root */ (void)setpriority(PRIO_PROCESS, 0, priority); execv(pbuf, args); diff --git a/dm/dm.conf.5.in b/dm/dm.conf.5.in index 99a0356..aca057c 100644 --- a/dm/dm.conf.5.in +++ b/dm/dm.conf.5.in @@ -1,4 +1,4 @@ -.\" $NetBSD: dm.conf.5,v 1.5 1998/04/29 18:16:01 fair Exp $ +.\" $NetBSD: dm.conf.5,v 1.7 2002/09/26 18:32:00 wiz Exp $ .\" .\" Copyright (c) 1988, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -35,7 +35,7 @@ .\" .Dd May 31, 1993 .Dt DM.CONF 5 -.Os BSD 4.2 +.Os .Sh NAME .Nm dm.conf .Nd dungeon master configuration file @@ -59,8 +59,7 @@ Entries consist of two white-space separated fields: the string .Em badtty and the ttyname as returned by .Xr ttyname 3 . -For example, -to keep the uucp dialout, +For example, to keep the uucp dialout, .Dq tty19 , from being used for games, the entry would be: .Bd -literal -offset indent @@ -94,17 +93,14 @@ in no game limitation or priority based on that field. .Pp The game .Em default -controls the settings for -any game not otherwise listed, and must be the last +controls the settings for any game not otherwise listed, and must be the last .Em game entry in the file. Priorities may not be negative. -For example, the following entries -limits the game +For example, the following entries limits the game .Dq hack -to running only when the system has 10 or less -users and a load average of 5 or less; all other games may be run any time -the system has 15 or less users. +to running only when the system has 10 or less users and a load average of 5 +or less; all other games may be run any time the system has 15 or less users. .Bd -literal -offset indent game hack 5 10 * game default * 15 * diff --git a/factor/Makefile.bsd b/factor/Makefile.bsd index 8f8baf7..0be0475 100644 --- a/factor/Makefile.bsd +++ b/factor/Makefile.bsd @@ -1,11 +1,23 @@ -# $NetBSD: Makefile,v 1.7 1997/10/22 04:43:26 lukem Exp $ +# $NetBSD: Makefile,v 1.10 2002/09/19 03:15:39 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 +# For MKCRYPTO +.include + +PRIMES= ${NETBSDSRCDIR}/games/primes + PROG= factor SRCS= factor.c pr_tbl.c -CPPFLAGS+=-I${.CURDIR}/../primes +CPPFLAGS+=-I${PRIMES} + +.if (${MKCRYPTO} != "no") +CPPFLAGS+=-DHAVE_OPENSSL +LDADD+= -lcrypto +DPADD+= ${LIBCRYPTO} +.endif + MAN= factor.6 MLINKS+=factor.6 primes.6 -.PATH: ${.CURDIR}/../primes +.PATH: ${PRIMES} .include diff --git a/factor/Makefrag b/factor/Makefrag index 53aabe8..b978533 100644 --- a/factor/Makefrag +++ b/factor/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for factor +# +# Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. # _GNU_SOURCE for isblank() factor_DEFS := -D_GNU_SOURCE @@ -11,6 +37,3 @@ factor_install: factor_all $(INSTALL_BINARY) factor/factor $(INSTALL_PREFIX)$(GAMESDIR)/factor $(HIDE_GAME) factor $(INSTALL_MANUAL) factor/factor.6 - -factor_check: factor_all - factor/factor 69300 diff --git a/factor/factor.c b/factor/factor.c index 2dddf58..c18e388 100644 --- a/factor/factor.c +++ b/factor/factor.c @@ -1,4 +1,4 @@ -/* $NetBSD: factor.c,v 1.8 1998/09/13 15:27:27 hubertf Exp $ */ +/* $NetBSD: factor.c,v 1.13 2002/06/18 23:07:36 simonb Exp $ */ /* * Copyright (c) 1989, 1993 @@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\ #if 0 static char sccsid[] = "@(#)factor.c 8.4 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: factor.c,v 1.8 1998/09/13 15:27:27 hubertf Exp $"); +__RCSID("$NetBSD: factor.c,v 1.13 2002/06/18 23:07:36 simonb Exp $"); #endif #endif /* not lint */ @@ -69,37 +69,85 @@ __RCSID("$NetBSD: factor.c,v 1.8 1998/09/13 15:27:27 hubertf Exp $"); * If no args are given, the list of numbers are read from stdin. */ -#include #include +#include #include #include #include #include #include +#ifdef HAVE_OPENSSL +#include +#else +typedef long BIGNUM; +typedef u_long BN_ULONG; +int BN_dec2bn(BIGNUM **a, const char *str); +#define BN_new() ((BIGNUM *)calloc(sizeof(BIGNUM), 1)) +#define BN_is_zero(v) (*(v) == 0) +#define BN_is_one(v) (*(v) == 1) +#define BN_new() ((BIGNUM *)calloc(sizeof(BIGNUM), 1)) +#define BN_is_zero(v) (*(v) == 0) +#define BN_is_one(v) (*(v) == 1) +#define BN_mod_word(a, b) (*(a) % (b)) +#endif + #include "primes.h" /* * prime[i] is the (i-1)th prime. * - * We are able to sieve 2^32-1 because this byte table yields all primes + * We are able to sieve 2^32-1 because this byte table yields all primes * up to 65537 and 65537^2 > 2^32-1. */ extern const ubig prime[]; extern const ubig *pr_limit; /* largest prime in the prime array */ -int main __P((int, char *[])); -void pr_fact __P((ubig)); /* print factors of a value */ -void usage __P((void)) __attribute__((__noreturn__)); +#define PRIME_CHECKS 5 + +#ifdef HAVE_OPENSSL +BN_CTX *ctx; /* just use a global context */ +#endif + +int main(int, char *[]); +void pr_fact(BIGNUM *); /* print factors of a value */ +void BN_print_dec_fp(FILE *, const BIGNUM *); +void usage(void) __attribute__((__noreturn__)); +#ifdef HAVE_OPENSSL +void pollard_pminus1(BIGNUM *); /* print factors for big numbers */ +#else +char *BN_bn2dec(const BIGNUM *); +BN_ULONG BN_div_word(BIGNUM *, BN_ULONG); +#endif + + +#ifndef HAVE_OPENSSL +int +BN_dec2bn(BIGNUM **a, const char *str) +{ + char *p; + + errno = 0; + **a = strtoul(str, &p, 10); + if (errno) + err(1, "%s", str); + return (*p == '\n' || *p == '\0'); +} +#endif int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { - ubig val; + BIGNUM *val; int ch; - char *p, buf[100]; /* > max number of digits. */ + char *p, buf[LINE_MAX]; /* > max number of digits. */ + +#ifdef HAVE_OPENSSL + ctx = BN_CTX_new(); +#endif + val = BN_new(); + if (val == NULL) + errx(1, "can't initialise bignum"); /* Revoke setgid privileges */ setregid(getgid(), getgid()); @@ -126,12 +174,8 @@ main(argc, argv) continue; if (*p == '-') errx(1, "negative numbers aren't permitted."); - errno = 0; - val = strtoul(buf, &p, 10); - if (errno) - err(1, "%s", buf); - if (*p != '\n') - errx(1, "%s: illegal numeric format.", buf); + if (BN_dec2bn(&val, buf) == 0) + errx(1, "%s: illegal numeric format.", argv[0]); pr_fact(val); } /* Factor the arguments. */ @@ -139,11 +183,7 @@ main(argc, argv) for (; *argv != NULL; ++argv) { if (argv[0][0] == '-') errx(1, "negative numbers aren't permitted."); - errno = 0; - val = strtoul(argv[0], &p, 10); - if (errno) - err(1, "%s", argv[0]); - if (*p != '\0') + if (BN_dec2bn(&val, argv[0]) == 0) errx(1, "%s: illegal numeric format.", argv[0]); pr_fact(val); } @@ -164,49 +204,152 @@ main(argc, argv) * Factors are printed with leading tabs. */ void -pr_fact(val) - ubig val; /* Factor this value. */ +pr_fact(BIGNUM *val) { const ubig *fact; /* The factor found. */ /* Firewall - catch 0 and 1. */ - if (val == 0) /* Historical practice; 0 just exits. */ + if (BN_is_zero(val)) /* Historical practice; 0 just exits. */ exit(0); - if (val == 1) { - (void)printf("1: 1\n"); + if (BN_is_one(val)) { + printf("1: 1\n"); return; } /* Factor value. */ - (void)printf("%lu:", val); - for (fact = &prime[0]; val > 1; ++fact) { + + BN_print_dec_fp(stdout, val); + putchar(':'); + for (fact = &prime[0]; !BN_is_one(val); ++fact) { /* Look for the smallest factor. */ do { - if (val % (long)*fact == 0) + if (BN_mod_word(val, (BN_ULONG)*fact) == 0) break; } while (++fact <= pr_limit); /* Watch for primes larger than the table. */ if (fact > pr_limit) { - (void)printf(" %lu", val); +#ifdef HAVE_OPENSSL + BIGNUM *bnfact; + + bnfact = BN_new(); + BN_set_word(bnfact, *(fact - 1)); + BN_sqr(bnfact, bnfact, ctx); + if (BN_cmp(bnfact, val) > 0) { + putchar(' '); + BN_print_dec_fp(stdout, val); + } else + pollard_pminus1(val); +#else + printf(" %s", BN_bn2dec(val)); +#endif break; } /* Divide factor out until none are left. */ do { - (void)printf(" %lu", *fact); - val /= (long)*fact; - } while ((val % (long)*fact) == 0); + printf(" %lu", *fact); + BN_div_word(val, (BN_ULONG)*fact); + } while (BN_mod_word(val, (BN_ULONG)*fact) == 0); /* Let the user know we're doing something. */ - (void)fflush(stdout); + fflush(stdout); } - (void)putchar('\n'); + putchar('\n'); +} + +/* + * Sigh.. No _decimal_ output to file functions in BN. + */ +void +BN_print_dec_fp(FILE *fp, const BIGNUM *num) +{ + char *buf; + + buf = BN_bn2dec(num); + if (buf == NULL) + return; /* XXX do anything here? */ + fprintf(fp, buf); + free(buf); } void -usage() +usage(void) { - (void)fprintf(stderr, "usage: factor [value ...]\n"); + fprintf(stderr, "usage: factor [value ...]\n"); exit (0); } + + + + +#ifdef HAVE_OPENSSL +/* pollard rho, algorithm from Jim Gillogly, May 2000 */ + +void +pollard_pminus1(BIGNUM *val) +{ + BIGNUM *base, *num, *i, *x; + + base = BN_new(); + num = BN_new(); + i = BN_new(); + x = BN_new(); + + BN_set_word(i, 2); + BN_set_word(base, 2); + + for (;;) { + BN_mod_exp(base, base, i, val, ctx); + + BN_copy(x, base); + BN_sub_word(x, 1); + BN_gcd(x, x, val, ctx); + + if (!BN_is_one(x)) { + if (BN_is_prime(x, PRIME_CHECKS, NULL, NULL, + NULL) == 1) { + putchar(' '); + BN_print_dec_fp(stdout, x); + } else + pollard_pminus1(x); + fflush(stdout); + + BN_div(num, NULL, val, x, ctx); + if (BN_is_one(num)) + return; + if (BN_is_prime(num, PRIME_CHECKS, NULL, NULL, + NULL) == 1) { + putchar(' '); + BN_print_dec_fp(stdout, num); + fflush(stdout); + return; + } + BN_copy(val, num); + } + BN_add_word(i, 1); + } +} +#else +char * +BN_bn2dec(const BIGNUM *val) +{ + char *buf; + + buf = malloc(100); + if (!buf) + return buf; + snprintf(buf, 100, "%ld", (long)*val); + return buf; +} + +BN_ULONG +BN_div_word(BIGNUM *a, BN_ULONG b) +{ + BN_ULONG mod; + + mod = *a % b; + *a /= b; + return mod; +} +#endif diff --git a/fish/Makefile.bsd b/fish/Makefile.bsd index f9533a0..854bd56 100644 --- a/fish/Makefile.bsd +++ b/fish/Makefile.bsd @@ -1,10 +1,14 @@ -# $NetBSD: Makefile,v 1.8 1997/03/24 22:15:42 christos Exp $ +# $NetBSD: Makefile,v 1.10 1999/02/13 02:54:21 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 +.include + PROG= fish MAN= fish.6 HIDEGAME=hidegame +.if ${MKSHARE} != "no" FILES=fish.instr FILESDIR=/usr/share/games +.endif .include diff --git a/fish/Makefrag b/fish/Makefrag index 7268a1f..1039af5 100644 --- a/fish/Makefrag +++ b/fish/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for fish +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. fish_DIRS := $(GAMESDIR) $(MAN6DIR) $(shell dirname $(FISH_INSTRFILE)) diff --git a/fish/fish.6 b/fish/fish.6 index d9847c2..34c2f3e 100644 --- a/fish/fish.6 +++ b/fish/fish.6 @@ -1,4 +1,4 @@ -.\" $NetBSD: fish.6,v 1.5 1997/10/10 12:58:29 lukem Exp $ +.\" $NetBSD: fish.6,v 1.7 2001/04/02 22:42:38 wiz Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -34,11 +34,12 @@ .\" @(#)fish.6 8.1 (Berkeley) 5/31/93 .\" .Dd May 31, 1993 -.Dt FISH 6 +.Dt FISH 6 .Os .Sh NAME -.Nm fish -.Nd play ``Go Fish'' +.Nm fish +.Nd play +.Dq Go Fish .Sh SYNOPSIS .Nm .Op Fl p @@ -50,10 +51,10 @@ a traditional children's card game. .Pp The computer deals the player and itself seven cards, and places the rest of the deck face-down (figuratively). -The object of the game is to collect +The object of the game is to collect .Dq books , or all of the members of a single rank. -For example, collecting four 2's would give the player a +For example, collecting four 2's would give the player a .Dq book of 2's . .Pp The options are as follows: @@ -70,7 +71,7 @@ them up to the asking player. A player must have at least one of the cards of the rank they request in their hand. When a player asks for a rank of which the other player has no -cards, the asker is told to +cards, the asker is told to .Dq Go Fish! . Then, the asker draws a card from the non-dealt cards. If they draw the card they asked for, they continue their turn, asking diff --git a/fish/fish.c b/fish/fish.c index b8e9a8e..4098a11 100644 --- a/fish/fish.c +++ b/fish/fish.c @@ -1,4 +1,4 @@ -/* $NetBSD: fish.c,v 1.6 1998/09/13 15:27:27 hubertf Exp $ */ +/* $NetBSD: fish.c,v 1.13 2000/05/08 07:56:03 mycroft Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 1993\n\ #if 0 static char sccsid[] = "@(#)fish.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: fish.c,v 1.6 1998/09/13 15:27:27 hubertf Exp $"); +__RCSID("$NetBSD: fish.c,v 1.13 2000/05/08 07:56:03 mycroft Exp $"); #endif #endif /* not lint */ @@ -65,6 +65,7 @@ __RCSID("$NetBSD: fish.c,v 1.6 1998/09/13 15:27:27 hubertf Exp $"); #define RANKS 13 #define HANDSIZE 7 #define CARDS 4 +#define TOTCARDS RANKS * CARDS #define USER 1 #define COMPUTER 0 @@ -77,8 +78,9 @@ const char *const cards[] = { #define PRC(card) (void)printf(" %s", cards[card]) int promode; -int asked[RANKS], comphand[RANKS], deck[RANKS]; +int asked[RANKS], comphand[RANKS], deck[TOTCARDS]; int userasked[RANKS], userhand[RANKS]; +int curcard = TOTCARDS; void chkwinner __P((int, const int *)); int compmove __P((void)); @@ -164,13 +166,13 @@ usermove() for (;;) { (void)printf("You ask me for: "); (void)fflush(stdout); - if (fgets(buf, BUFSIZ, stdin) == NULL) + if (fgets(buf, sizeof(buf), stdin) == NULL) exit(0); if (buf[0] == '\0') continue; if (buf[0] == '\n') { (void)printf("%d cards in my hand, %d in the pool.\n", - countcards(comphand), countcards(deck)); + countcards(comphand), curcard); (void)printf("My books:"); (void)countbooks(comphand); continue; @@ -270,9 +272,7 @@ drawcard(player, hand) { int card; - while (deck[card = nrandom(RANKS)] == 0); - ++hand[card]; - --deck[card]; + ++hand[card = deck[--curcard]]; if (player == USER || hand[card] == CARDS) { printplayer(player); (void)printf("drew %s", cards[card]); @@ -423,19 +423,21 @@ countbooks(hand) void init() { - int i, rank; + int i, j, temp; - for (i = 0; i < RANKS; ++i) - deck[i] = CARDS; - for (i = 0; i < HANDSIZE; ++i) { - while (!deck[rank = nrandom(RANKS)]); - ++userhand[rank]; - --deck[rank]; + for (i = 0; i < TOTCARDS; ++i) + deck[i] = i % RANKS; + for (i = 0; i < TOTCARDS - 1; ++i) { + j = nrandom(TOTCARDS-i); + if (j == 0) + continue; + temp = deck[i]; + deck[i] = deck[i+j]; + deck[i+j] = temp; } for (i = 0; i < HANDSIZE; ++i) { - while (!deck[rank = nrandom(RANKS)]); - ++comphand[rank]; - --deck[rank]; + ++userhand[deck[--curcard]]; + ++comphand[deck[--curcard]]; } } diff --git a/fortune/Makefile.bsd b/fortune/Makefile.bsd index bb1dd30..28d1172 100644 --- a/fortune/Makefile.bsd +++ b/fortune/Makefile.bsd @@ -1,8 +1,6 @@ -# $NetBSD: Makefile,v 1.7 1997/10/22 04:56:11 lukem Exp $ +# $NetBSD: Makefile,v 1.9 2001/01/09 03:13:40 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 -SUBDIR= fortune strfile datfiles - -all-datfiles: all-strfile +SUBDIR= fortune strfile .WAIT datfiles .include diff --git a/fortune/Makefrag b/fortune/Makefrag index 8bdb014..35358c6 100644 --- a/fortune/Makefrag +++ b/fortune/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for fortune +# +# Copyright (c) 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. fortune_all: diff --git a/gomoku/Makefrag b/gomoku/Makefrag index 6d3b56b..5660a70 100644 --- a/gomoku/Makefrag +++ b/gomoku/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for gomoku +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. gomoku_DIRS := $(GAMESDIR) $(MAN6DIR) diff --git a/gomoku/bdisp.c b/gomoku/bdisp.c index 0acf502..cf719bb 100644 --- a/gomoku/bdisp.c +++ b/gomoku/bdisp.c @@ -1,4 +1,4 @@ -/* $NetBSD: bdisp.c,v 1.5 1997/10/10 13:36:02 lukem Exp $ */ +/* $NetBSD: bdisp.c,v 1.7 2001/02/05 00:30:38 christos Exp $ */ /* * Copyright (c) 1994 @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)bdisp.c 8.2 (Berkeley) 5/3/95"; #else -__RCSID("$NetBSD: bdisp.c,v 1.5 1997/10/10 13:36:02 lukem Exp $"); +__RCSID("$NetBSD: bdisp.c,v 1.7 2001/02/05 00:30:38 christos Exp $"); #endif #endif /* not lint */ @@ -55,6 +55,9 @@ __RCSID("$NetBSD: bdisp.c,v 1.5 1997/10/10 13:36:02 lukem Exp $"); static int lastline; static char pcolor[] = "*O.?"; +extern int interactive; +extern char *plyr[]; + /* * Initialize screen display. */ @@ -122,7 +125,6 @@ bdwho(update) int update; { int i; - extern char *plyr[]; move(21, 0); clrtoeol(); @@ -249,7 +251,6 @@ getline(buf, size) { char *cp, *end; int c; - extern int interactive; c = 0; cp = buf; diff --git a/gomoku/gomoku.6 b/gomoku/gomoku.6 index b5adae9..29056b2 100644 --- a/gomoku/gomoku.6 +++ b/gomoku/gomoku.6 @@ -1,4 +1,4 @@ -.\" $NetBSD: gomoku.6,v 1.4 1997/10/10 13:36:02 lukem Exp $ +.\" $NetBSD: gomoku.6,v 1.9 2002/09/26 18:32:01 wiz Exp $ .\" .\" Copyright (c) 1994 .\" The Regents of the University of California. All rights reserved. @@ -38,7 +38,7 @@ .\" .Dd August 4, 1994 .Dt GOMOKU 6 -.Os BSD 4.4 +.Os .Sh NAME .Nm gomoku .Nd game of 5 in a row @@ -50,13 +50,14 @@ .Sh DESCRIPTION .Nm is a two player game were the object is to get 5 in a row horizontally, -vertically or diagonally on a 19 by 19 grid. By convention, black always -moves first. +vertically or diagonally on a 19 by 19 grid. +By convention, black always moves first. With no arguments, .Nm will display a playing board and prompt for moves from the user. Valid moves are a letter for the column and a number for the row of an empty -board location. Entering ``quit" or ``resign" will end the game. +board location. +Entering ``quit" or ``resign" will end the game. You can save the current state of the game by entering ``save" and supplying a file name when prompted. The optional file @@ -66,28 +67,32 @@ can be used to restore a saved game. The options are: .Bl -tag -width Ds .It Fl b -This option sets background mode. Input moves are read from standard input, -the computer picks a move, and prints it to standard output. The first -input line should be either ``black" or ``white" to specify whether +This option sets background mode. +Input moves are read from standard input, +the computer picks a move, and prints it to standard output. +The first input line should be either ``black" or ``white" to specify whether .Nm -has the first move or not respectively. This -option was intended for game tournaments where a referee program handles +has the first move or not respectively. +This option was intended for game tournaments where a referee program handles the board display and pits one program against another. .It Fl c -Computer verses computer. +Computer versus computer. .Nm -will play a game against itself. This is mostly used for testing. +will play a game against itself. +This is mostly used for testing. .It Fl d -Print debugging information. Repeating this option more than -once yields more detailed information. +Print debugging information. +Repeating this option more than once yields more detailed information. .It Fl D Ar debugfile Print the debug information to .Ar debugfile instead of to the standard output. .It Fl u -User verses user. This is mostly used for testing. +User versus user. +This is mostly used for testing. +.El .Sh AUTHOR -Ralph Campbell +.An Ralph Campbell .Sh ACKNOWLEDGEMENTS The board display routines were based on the .Nm goref diff --git a/gomoku/gomoku.h b/gomoku/gomoku.h index b27171d..0798402 100644 --- a/gomoku/gomoku.h +++ b/gomoku/gomoku.h @@ -1,4 +1,4 @@ -/* $NetBSD: gomoku.h,v 1.5 1998/09/13 15:27:28 hubertf Exp $ */ +/* $NetBSD: gomoku.h,v 1.7 1999/09/13 17:18:57 jsm Exp $ */ /* * Copyright (c) 1994 diff --git a/gomoku/main.c b/gomoku/main.c index 367f457..e6cbbcb 100644 --- a/gomoku/main.c +++ b/gomoku/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.5 1998/02/03 05:40:45 perry Exp $ */ +/* $NetBSD: main.c,v 1.10 2000/05/08 07:56:03 mycroft Exp $ */ /* * Copyright (c) 1994 @@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1994\n\ #if 0 static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: main.c,v 1.5 1998/02/03 05:40:45 perry Exp $"); +__RCSID("$NetBSD: main.c,v 1.10 2000/05/08 07:56:03 mycroft Exp $"); #endif #endif /* not lint */ @@ -98,7 +98,7 @@ main(argc, argv) "%3d %-6s" }; - /* revoke setgid privileges */ + /* Revoke setgid privileges */ setregid(getgid(), getgid()); color = curmove = 0; @@ -536,7 +536,7 @@ quit() void quitsig(dummy) - int dummy __attribute__((unused)); + int dummy __attribute__((__unused__)); { quit(); } diff --git a/gomoku/makemove.c b/gomoku/makemove.c index c278403..50decd4 100644 --- a/gomoku/makemove.c +++ b/gomoku/makemove.c @@ -1,4 +1,4 @@ -/* $NetBSD: makemove.c,v 1.4 1997/10/10 13:36:05 lukem Exp $ */ +/* $NetBSD: makemove.c,v 1.6 2000/03/13 23:57:23 soren Exp $ */ /* * Copyright (c) 1994 @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)makemove.c 8.2 (Berkeley) 5/3/95"; #else -__RCSID("$NetBSD: makemove.c,v 1.4 1997/10/10 13:36:05 lukem Exp $"); +__RCSID("$NetBSD: makemove.c,v 1.6 2000/03/13 23:57:23 soren Exp $"); #endif #endif /* not lint */ @@ -59,7 +59,7 @@ const int weight[5] = { 0, 1, 7, 22, 100 }; * MOVEOK everything is OK. * RESIGN Player resigned. * ILLEGAL Illegal move. - * WIN The the winning move was just played. + * WIN The winning move was just played. * TIE The game is a tie. */ int diff --git a/gomoku/pickmove.c b/gomoku/pickmove.c index f382585..06ccbdd 100644 --- a/gomoku/pickmove.c +++ b/gomoku/pickmove.c @@ -1,4 +1,4 @@ -/* $NetBSD: pickmove.c,v 1.5 1997/10/10 13:36:06 lukem Exp $ */ +/* $NetBSD: pickmove.c,v 1.9 1999/09/18 19:38:51 jsm Exp $ */ /* * Copyright (c) 1994 @@ -41,18 +41,14 @@ #if 0 static char sccsid[] = "@(#)pickmove.c 8.2 (Berkeley) 5/3/95"; #else -__RCSID("$NetBSD: pickmove.c,v 1.5 1997/10/10 13:36:06 lukem Exp $"); +__RCSID("$NetBSD: pickmove.c,v 1.9 1999/09/18 19:38:51 jsm Exp $"); #endif #endif /* not lint */ #include #include #include -#ifndef __linux__ -#include -#else #include -#endif #include "gomoku.h" @@ -1058,7 +1054,7 @@ updatecombo(cbp, color) void appendcombo(cbp, color) struct combostr *cbp; - int color __attribute__((unused)); + int color __attribute__((__unused__)); { struct combostr *pcbp, *ncbp; diff --git a/gomoku/stoc.c b/gomoku/stoc.c index 733419a..a9fbef5 100644 --- a/gomoku/stoc.c +++ b/gomoku/stoc.c @@ -1,4 +1,4 @@ -/* $NetBSD: stoc.c,v 1.4 1997/10/10 13:36:07 lukem Exp $ */ +/* $NetBSD: stoc.c,v 1.6 2000/07/03 03:57:41 matt Exp $ */ /* * Copyright (c) 1994 @@ -41,12 +41,13 @@ #if 0 static char sccsid[] = "@(#)stoc.c 8.1 (Berkeley) 7/24/94"; #else -__RCSID("$NetBSD: stoc.c,v 1.4 1997/10/10 13:36:07 lukem Exp $"); +__RCSID("$NetBSD: stoc.c,v 1.6 2000/07/03 03:57:41 matt Exp $"); #endif #endif /* not lint */ #include #include +#include #include "gomoku.h" const char *letters = ""; diff --git a/hangman/Makefrag b/hangman/Makefrag index b26b62b..e0028a2 100644 --- a/hangman/Makefrag +++ b/hangman/Makefrag @@ -1,12 +1,36 @@ # Makefile - makefile for hangman +# +# Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. -hangman_DIRS := $(GAMESDIR) $(MAN6DIR) $(shell dirname $(HANGMAN_WORDSFILE)) -hangman_WORDS := hangman/words +hangman_DIRS := $(GAMESDIR) $(MAN6DIR) -hangman_all: hangman/hangman $(hangman_WORDS) hangman/hangman.6 +hangman_all: hangman/hangman hangman/hangman.6 hangman_install: hangman_all $(INSTALL_BINARY) hangman/hangman $(INSTALL_PREFIX)$(GAMESDIR)/hangman $(HIDE_GAME) hangman - $(INSTALL_DATA) $(hangman_WORDS) $(INSTALL_PREFIX)$(HANGMAN_WORDSFILE) $(INSTALL_MANUAL) hangman/hangman.6 diff --git a/hangman/setup.c b/hangman/setup.c index d6dc491..f625e87 100644 --- a/hangman/setup.c +++ b/hangman/setup.c @@ -1,4 +1,4 @@ -/* $NetBSD: setup.c,v 1.5 1997/10/11 08:01:06 lukem Exp $ */ +/* $NetBSD: setup.c,v 1.9 2001/12/06 12:07:37 blymn Exp $ */ /*- * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)setup.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: setup.c,v 1.5 1997/10/11 08:01:06 lukem Exp $"); +__RCSID("$NetBSD: setup.c,v 1.9 2001/12/06 12:07:37 blymn Exp $"); #endif #endif /* not lint */ @@ -57,7 +57,7 @@ setup() static struct stat sbuf; noecho(); - crmode(); + cbreak(); mvaddstr(PROMPTY, PROMPTX, "Guess:"); mvaddstr(GUESSY, GUESSX, "Guessed:"); @@ -72,9 +72,9 @@ setup() } srand(time(NULL) + getpid()); - if ((Dict = fopen(_PATH_DICT, "r")) == NULL) { + if ((Dict = fopen(Dict_name, "r")) == NULL) { endwin(); - err(1, "fopen %s", _PATH_DICT); + err(1, "fopen %s", Dict_name); } fstat(fileno(Dict), &sbuf); Dict_size = sbuf.st_size; diff --git a/hunt/Makefile.inc.bsd b/hunt/Makefile.inc.bsd index 176ad4a..2038362 100644 --- a/hunt/Makefile.inc.bsd +++ b/hunt/Makefile.inc.bsd @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.3 1997/10/22 05:05:21 lukem Exp $ +# $NetBSD: Makefile.inc,v 1.6 2002/09/20 21:00:01 mycroft Exp $ # # Hunt # Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold @@ -39,7 +39,7 @@ GAME_PARAM= -DRANDOM -DREFLECT -DMONITOR -DOOZE -DFLY -DVOLCANO -DBOOTS \ # HPUX do special HPUX only hacks # DEFS_BSD43= -DINTERNET -DLOG -DBSD_RELEASE=43 -DSIGNAL_TYPE=int -DEFS_BSD44= -DINTERNET -DLOG -DBSD_RELEASE=44 -DSIGNAL_TYPE=void +DEFS_BSD44= -DINTERNET -DLOG -DBSD_RELEASE=44 -DSIGNAL_TYPE=void -DUSE_CURSES DEFS_SUN= -DINTERNET -DLOG -DBSD_RELEASE=42 -DBROADCAST -DSIGNAL_TYPE=int DEFS_SUN4_0= -DINTERNET -DLOG -DSYSLOG_43 -DBROADCAST -DSIGNAL_TYPE=void DEFS_ULTRIX= -DINTERNET -DLOG -DBSD_RELEASE=42 -DSIGNAL_TYPE=void diff --git a/hunt/Makefrag b/hunt/Makefrag index 2b5e104..bdb9799 100644 --- a/hunt/Makefrag +++ b/hunt/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for hunt +# +# Copyright (c) 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. hunt_all: diff --git a/hunt/README.linux b/hunt/README.linux index bc02b50..1d42d10 100644 --- a/hunt/README.linux +++ b/hunt/README.linux @@ -6,7 +6,7 @@ sockets rather than Unix domain sockets, but is almost completely untested. The original README.linux is below. Joseph S. Myers -jsm28@cam.ac.uk +jsm@polyomino.org.uk 8/25/93 diff --git a/hunt/huntd/Makefrag b/hunt/huntd/Makefrag index f6580a3..9237a9c 100644 --- a/hunt/huntd/Makefrag +++ b/hunt/huntd/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for hunt/huntd +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. include hunt/Makeconfig diff --git a/hunt/huntd/answer.c b/hunt/huntd/answer.c index dad5d45..935fb4f 100644 --- a/hunt/huntd/answer.c +++ b/hunt/huntd/answer.c @@ -1,4 +1,4 @@ -/* $NetBSD: answer.c,v 1.3 1997/10/10 16:32:50 lukem Exp $ */ +/* $NetBSD: answer.c,v 1.5 2003/02/26 07:14:45 jdc Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold @@ -7,7 +7,7 @@ #include #ifndef lint -__RCSID("$NetBSD: answer.c,v 1.3 1997/10/10 16:32:50 lukem Exp $"); +__RCSID("$NetBSD: answer.c,v 1.5 2003/02/26 07:14:45 jdc Exp $"); #endif /* not lint */ # include @@ -33,11 +33,12 @@ answer() static int enter_status; static int socklen; static u_long machine; - static u_long uid; + static u_int32_t uid; static SOCKET sockstruct; char *cp1, *cp2; int flags; - long version; + u_int32_t version; + int i; # ifdef INTERNET socklen = sizeof sockstruct; @@ -124,9 +125,10 @@ answer() # endif # ifdef MONITOR if (mode == C_MONITOR) - if (End_monitor < &Monitor[MAXMON]) + if (End_monitor < &Monitor[MAXMON]) { pp = End_monitor++; - else { + i = pp - Monitor + MAXPL + 3; + } else { socklen = 0; (void) write(newsock, (char *) &socklen, sizeof socklen); @@ -135,9 +137,10 @@ answer() } else # endif - if (End_player < &Player[MAXPL]) + if (End_player < &Player[MAXPL]) { pp = End_player++; - else { + i = pp - Player + 3; + } else { socklen = 0; (void) write(newsock, (char *) &socklen, sizeof socklen); @@ -153,9 +156,8 @@ answer() pp->p_output = fdopen(newsock, "w"); pp->p_death[0] = '\0'; pp->p_fd = newsock; - FD_SET(pp->p_fd, &Fds_mask); - if (pp->p_fd >= Num_fds) - Num_fds = pp->p_fd + 1; + fdset[i].fd = newsock; + fdset[i].events = POLLIN; pp->p_y = 0; pp->p_x = 0; diff --git a/hunt/huntd/bsd.h b/hunt/huntd/bsd.h index bfd6c7e..d746f1d 100644 --- a/hunt/huntd/bsd.h +++ b/hunt/huntd/bsd.h @@ -1,4 +1,4 @@ -/* $NetBSD: bsd.h,v 1.2 1998/01/09 08:03:40 perry Exp $ */ +/* $NetBSD: bsd.h,v 1.3 2002/09/20 21:00:02 mycroft Exp $ */ /* * Hunt @@ -9,13 +9,7 @@ # if defined(BSD_RELEASE) && BSD_RELEASE >= 43 # define BROADCAST # define SYSLOG_43 -#ifdef __linux__ -#define TALK_42 /* Kludge around broken */ -#else -# define TALK_43 -#endif # endif # if defined(BSD_RELEASE) && BSD_RELEASE == 42 # define SYSLOG_42 -# define TALK_42 # endif diff --git a/hunt/huntd/ctl_transact.c b/hunt/huntd/ctl_transact.c index d183bd3..8d30374 100644 --- a/hunt/huntd/ctl_transact.c +++ b/hunt/huntd/ctl_transact.c @@ -1,4 +1,4 @@ -/* $NetBSD: ctl_transact.c,v 1.3 1997/10/20 00:37:16 lukem Exp $ */ +/* $NetBSD: ctl_transact.c,v 1.5 2002/09/20 20:54:16 mycroft Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement @@ -14,7 +14,7 @@ #if 0 static char sccsid[] = "@(#)ctl_transact.c 5.2 (Berkeley) 3/13/86"; #else -__RCSID("$NetBSD: ctl_transact.c,v 1.3 1997/10/20 00:37:16 lukem Exp $"); +__RCSID("$NetBSD: ctl_transact.c,v 1.5 2002/09/20 20:54:16 mycroft Exp $"); #endif #endif /* not lint */ @@ -28,7 +28,7 @@ __RCSID("$NetBSD: ctl_transact.c,v 1.3 1997/10/20 00:37:16 lukem Exp $"); /* * SOCKDGRAM is unreliable, so we must repeat messages if we have - * not recieved an acknowledgement within a reasonable amount + * not received an acknowledgement within a reasonable amount * of time */ void @@ -38,24 +38,21 @@ ctl_transact(target, msg, type, rp) int type; CTL_RESPONSE *rp; { - fd_set read_mask, ctl_mask; + struct pollfd set[1]; int nready, cc, retries; - struct timeval wait; nready = 0; msg.type = type; daemon_addr.sin_addr = target; daemon_addr.sin_port = daemon_port; - FD_ZERO(&ctl_mask); - FD_SET(ctl_sockt, &ctl_mask); + set[0].fd = ctl_sockt; + set[0].events = POLLIN; /* * Keep sending the message until a response of * the proper type is obtained. */ do { - wait.tv_sec = CTL_WAIT; - wait.tv_usec = 0; /* resend message until a response is obtained */ for (retries = MAX_RETRY; retries > 0; retries -= 1) { cc = sendto(ctl_sockt, (char *)&msg, sizeof (msg), 0, @@ -65,8 +62,7 @@ ctl_transact(target, msg, type, rp) continue; p_error("Error on write to talk daemon"); } - read_mask = ctl_mask; - nready = select(32, &read_mask, 0, 0, &wait); + nready = poll(set, 1, CTL_WAIT * 1000); if (nready < 0) { if (errno == EINTR) continue; @@ -89,10 +85,8 @@ ctl_transact(target, msg, type, rp) continue; p_error("Error on read from talk daemon"); } - read_mask = ctl_mask; /* an immediate poll */ - timerclear(&wait); - nready = select(32, &read_mask, 0, 0, &wait); + nready = poll(set, 1, 0); } while (nready > 0 && ( #ifdef TALK_43 rp->vers != TALK_VERSION || diff --git a/hunt/huntd/driver.c b/hunt/huntd/driver.c index ae1938c..75bfe41 100644 --- a/hunt/huntd/driver.c +++ b/hunt/huntd/driver.c @@ -1,4 +1,4 @@ -/* $NetBSD: driver.c,v 1.5 1997/10/20 00:37:16 lukem Exp $ */ +/* $NetBSD: driver.c,v 1.8 2002/09/20 20:54:16 mycroft Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold @@ -7,7 +7,7 @@ #include #ifndef lint -__RCSID("$NetBSD: driver.c,v 1.5 1997/10/20 00:37:16 lukem Exp $"); +__RCSID("$NetBSD: driver.c,v 1.8 2002/09/20 20:54:16 mycroft Exp $"); #endif /* not lint */ # include @@ -17,6 +17,7 @@ __RCSID("$NetBSD: driver.c,v 1.5 1997/10/20 00:37:16 lukem Exp $"); # include # include # include +# include # include # include "hunt.h" @@ -44,12 +45,12 @@ u_short stat_port; /* port # of statistics tcp socket */ # endif static void clear_scores __P((void)); -static int havechar __P((PLAYER *)); +static int havechar __P((PLAYER *, int)); static void init __P((void)); int main __P((int, char *[], char *[])); static void makeboots __P((void)); static void send_stats __P((void)); -static void zap __P((PLAYER *, FLAG)); +static void zap __P((PLAYER *, FLAG, int)); /* @@ -62,20 +63,16 @@ main(ac, av, ep) char **av, **ep; { PLAYER *pp; - int had_char; # ifdef INTERNET u_short msg; short port_num, reply; int namelen; SOCKET test; # endif - static fd_set read_fds; static FLAG first = TRUE; static FLAG server = FALSE; - extern int optind; - extern char *optarg; - int c; - static struct timeval linger = { 90, 0 }; + int c, i; + const int linger = 90 * 1000; First_arg = av[0]; if (ep == NULL || *ep == NULL) @@ -109,9 +106,8 @@ erred: again: do { - read_fds = Fds_mask; errno = 0; - while (select(Num_fds, &read_fds, NULL, NULL, NULL) < 0) + while (poll(fdset, 3+MAXPL+MAXMON, INFTIM) < 0) { if (errno != EINTR) # ifdef LOG @@ -121,9 +117,8 @@ again: # endif errno = 0; } - Have_inp = read_fds; # ifdef INTERNET - if (FD_ISSET(Test_socket, &read_fds)) { + if (fdset[2].revents & POLLIN) { namelen = DAEMON_SIZE; port_num = htons(sock_port); (void) recvfrom(Test_socket, (char *) &msg, sizeof msg, @@ -155,39 +150,34 @@ again: } } # endif - for (;;) { - had_char = FALSE; - for (pp = Player; pp < End_player; pp++) - if (havechar(pp)) { + { + for (pp = Player, i = 0; pp < End_player; pp++, i++) + if (havechar(pp, i + 3)) { execute(pp); pp->p_nexec++; - had_char++; } # ifdef MONITOR - for (pp = Monitor; pp < End_monitor; pp++) - if (havechar(pp)) { + for (pp = Monitor, i = 0; pp < End_monitor; pp++, i++) + if (havechar(pp, i + MAXPL + 3)) { mon_execute(pp); pp->p_nexec++; - had_char++; } # endif - if (!had_char) - break; moveshots(); - for (pp = Player; pp < End_player; ) + for (pp = Player, i = 0; pp < End_player; ) if (pp->p_death[0] != '\0') - zap(pp, TRUE); + zap(pp, TRUE, i + 3); else - pp++; + pp++, i++; # ifdef MONITOR - for (pp = Monitor; pp < End_monitor; ) + for (pp = Monitor, i = 0; pp < End_monitor; ) if (pp->p_death[0] != '\0') - zap(pp, FALSE); + zap(pp, FALSE, i + MAXPL + 3); else - pp++; + pp++, i++; # endif } - if (FD_ISSET(Socket, &read_fds)) + if (fdset[0].revents & POLLIN) if (answer()) { # ifdef INTERNET if (first && standard_port) @@ -195,17 +185,17 @@ again: # endif first = FALSE; } - if (FD_ISSET(Status, &read_fds)) + if (fdset[1].revents & POLLIN) send_stats(); - for (pp = Player; pp < End_player; pp++) { - if (FD_ISSET(pp->p_fd, &read_fds)) + for (pp = Player, i = 0; pp < End_player; pp++, i++) { + if (fdset[i + 3].revents & POLLIN) sendcom(pp, READY, pp->p_nexec); pp->p_nexec = 0; (void) fflush(pp->p_output); } # ifdef MONITOR - for (pp = Monitor; pp < End_monitor; pp++) { - if (FD_ISSET(pp->p_fd, &read_fds)) + for (pp = Monitor, i = 0; pp < End_monitor; pp++, i++) { + if (fdset[i + MAXPL + 3].revents & POLLIN) sendcom(pp, READY, pp->p_nexec); pp->p_nexec = 0; (void) fflush(pp->p_output); @@ -213,8 +203,7 @@ again: # endif } while (Nplayer > 0); - read_fds = Fds_mask; - if (select(Num_fds, &read_fds, NULL, NULL, &linger) > 0) { + if (poll(fdset, 3+MAXPL+MAXMON, linger) > 0) { goto again; } if (server) { @@ -229,8 +218,8 @@ again: } # ifdef MONITOR - for (pp = Monitor; pp < End_monitor; ) - zap(pp, FALSE); + for (pp = Monitor, i = 0; pp < End_monitor; i++) + zap(pp, FALSE, i + MAXPL + 3); # endif cleanup(0); /* NOTREACHED */ @@ -252,6 +241,14 @@ init() # endif # ifndef DEBUG + switch (fork()) { + case -1: + err(1, "fork"); + case 0: + break; /* child */ + default: + exit(0); /* parent */ + } if (setsid() == -1) err(1, "setsid"); (void) signal(SIGHUP, SIG_IGN); @@ -266,10 +263,10 @@ init() # ifdef LOG # ifdef SYSLOG_43 - openlog("HUNT", LOG_PID, LOG_DAEMON); + openlog("huntd", LOG_PID, LOG_DAEMON); # endif # ifdef SYSLOG_42 - openlog("HUNT", LOG_PID); + openlog("huntd", LOG_PID); # endif # endif @@ -367,10 +364,10 @@ init() /* * Initialize minimal select mask */ - FD_ZERO(&Fds_mask); - FD_SET(Socket, &Fds_mask); - FD_SET(Status, &Fds_mask); - Num_fds = ((Socket > Status) ? Socket : Status) + 1; + fdset[0].fd = Socket; + fdset[0].events = POLLIN; + fdset[1].fd = Status; + fdset[1].events = POLLIN; # ifdef INTERNET len = sizeof (SOCKET); @@ -399,9 +396,10 @@ init() (void) listen(Test_socket, 5); } - FD_SET(Test_socket, &Fds_mask); - if (Test_socket + 1 > Num_fds) - Num_fds = Test_socket + 1; + fdset[2].fd = Test_socket; + fdset[2].events = POLLIN; +# else + fdset[2].fd = -1; # endif Seed = getpid() + time((time_t *) NULL); @@ -584,11 +582,12 @@ checkdam(ouch, gotcha, credit, amt, shot_type) * Kill off a player and take him out of the game. */ static void -zap(pp, was_player) +zap(pp, was_player, i) PLAYER *pp; FLAG was_player; + int i; { - int i, len; + int n, len; BULLET *bp; PLAYER *np; int x, y; @@ -605,8 +604,8 @@ zap(pp, was_player) x = (WIDTH - len) / 2; cgoto(pp, HEIGHT / 2, x); outstr(pp, pp->p_death, len); - for (i = 1; i < len; i++) - pp->p_death[i] = '-'; + for (n = 1; n < len; n++) + pp->p_death[n] = '-'; pp->p_death[0] = '+'; pp->p_death[len - 1] = '+'; cgoto(pp, HEIGHT / 2 - 1, x); @@ -627,22 +626,22 @@ zap(pp, was_player) bp->b_over = SPACE; } - i = rand_num(pp->p_ammo); + n = rand_num(pp->p_ammo); x = rand_num(pp->p_ammo); - if (x > i) - i = x; + if (x > n) + n = x; if (pp->p_ammo == 0) x = 0; - else if (i == pp->p_ammo - 1) { + else if (n == pp->p_ammo - 1) { x = pp->p_ammo; len = SLIME; } else { for (x = MAXBOMB - 1; x > 0; x--) - if (i >= shot_req[x]) + if (n >= shot_req[x]) break; for (y = MAXSLIME - 1; y > 0; y--) - if (i >= slime_req[y]) + if (n >= slime_req[y]) break; if (y >= 0 && slime_req[y] > shot_req[x]) { x = slime_req[y]; @@ -730,31 +729,34 @@ zap(pp, was_player) End_player--; if (pp != End_player) { memcpy(pp, End_player, sizeof (PLAYER)); + fdset[i] = fdset[End_player - Player + 3]; + fdset[End_player - Player + 3].fd = -1; (void) sprintf(Buf, "%5.2f%c%-10.10s %c", pp->p_ident->i_score, stat_char(pp), pp->p_ident->i_name, pp->p_ident->i_team); - i = STAT_PLAY_ROW + 1 + (pp - Player); + n = STAT_PLAY_ROW + 1 + (pp - Player); for (np = Player; np < End_player; np++) { - cgoto(np, i, STAT_NAME_COL); + cgoto(np, n, STAT_NAME_COL); outstr(np, Buf, STAT_NAME_LEN); } # ifdef MONITOR for (np = Monitor; np < End_monitor; np++) { - cgoto(np, i, STAT_NAME_COL); + cgoto(np, n, STAT_NAME_COL); outstr(np, Buf, STAT_NAME_LEN); } # endif - } + } else + fdset[i].fd = -1; /* Erase the last player */ - i = STAT_PLAY_ROW + 1 + Nplayer; + n = STAT_PLAY_ROW + 1 + Nplayer; for (np = Player; np < End_player; np++) { - cgoto(np, i, STAT_NAME_COL); + cgoto(np, n, STAT_NAME_COL); ce(np); } # ifdef MONITOR for (np = Monitor; np < End_monitor; np++) { - cgoto(np, i, STAT_NAME_COL); + cgoto(np, n, STAT_NAME_COL); ce(np); } } @@ -766,50 +768,34 @@ zap(pp, was_player) End_monitor--; if (pp != End_monitor) { memcpy(pp, End_monitor, sizeof (PLAYER)); + fdset[i] = fdset[End_monitor - Monitor + MAXPL + 3]; + fdset[End_monitor - Monitor + MAXPL + 3].fd = -1; (void) sprintf(Buf, "%5.5s %-10.10s %c", " ", pp->p_ident->i_name, pp->p_ident->i_team); - i = STAT_MON_ROW + 1 + (pp - Player); + n = STAT_MON_ROW + 1 + (pp - Player); for (np = Player; np < End_player; np++) { - cgoto(np, i, STAT_NAME_COL); + cgoto(np, n, STAT_NAME_COL); outstr(np, Buf, STAT_NAME_LEN); } for (np = Monitor; np < End_monitor; np++) { - cgoto(np, i, STAT_NAME_COL); + cgoto(np, n, STAT_NAME_COL); outstr(np, Buf, STAT_NAME_LEN); } - } + } else + fdset[i].fd = -1; /* Erase the last monitor */ - i = STAT_MON_ROW + 1 + (End_monitor - Monitor); + n = STAT_MON_ROW + 1 + (End_monitor - Monitor); for (np = Player; np < End_player; np++) { - cgoto(np, i, STAT_NAME_COL); + cgoto(np, n, STAT_NAME_COL); ce(np); } for (np = Monitor; np < End_monitor; np++) { - cgoto(np, i, STAT_NAME_COL); + cgoto(np, n, STAT_NAME_COL); ce(np); } - } # endif - - FD_CLR(savefd, &Fds_mask); - if (Num_fds == savefd + 1) { - Num_fds = Socket; -# ifdef INTERNET - if (Test_socket > Socket) - Num_fds = Test_socket; -# endif - for (np = Player; np < End_player; np++) - if (np->p_fd > Num_fds) - Num_fds = np->p_fd; -# ifdef MONITOR - for (np = Monitor; np < End_monitor; np++) - if (np->p_fd > Num_fds) - Num_fds = np->p_fd; -# endif - Num_fds++; - } } /* @@ -830,15 +816,15 @@ rand_num(range) * FALSE. */ static int -havechar(pp) +havechar(pp, i) PLAYER *pp; + int i; { if (pp->p_ncount < pp->p_nchar) return TRUE; - if (!FD_ISSET(pp->p_fd, &Have_inp)) + if (!(fdset[i].revents & POLLIN)) return FALSE; - FD_CLR(pp->p_fd, &Have_inp); check_again: errno = 0; if ((pp->p_nchar = read(pp->p_fd, pp->p_cbuf, sizeof pp->p_cbuf)) <= 0) @@ -909,7 +895,7 @@ send_stats() if (errno == EINTR) return; # ifdef LOG - syslog(LOG_ERR, "accept: %m"); + syslog(LOG_WARNING, "accept: %m"); # else warn("accept"); # endif @@ -918,7 +904,7 @@ send_stats() fp = fdopen(s, "w"); if (fp == NULL) { # ifdef LOG - syslog(LOG_ERR, "fdopen: %m"); + syslog(LOG_WARNING, "fdopen: %m"); # else warn("fdopen"); # endif diff --git a/hunt/huntd/extern.c b/hunt/huntd/extern.c index e25ba83..d11b0ca 100644 --- a/hunt/huntd/extern.c +++ b/hunt/huntd/extern.c @@ -1,4 +1,4 @@ -/* $NetBSD: extern.c,v 1.2 1997/10/10 16:33:24 lukem Exp $ */ +/* $NetBSD: extern.c,v 1.3 2002/09/20 20:54:16 mycroft Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold @@ -7,7 +7,7 @@ #include #ifndef lint -__RCSID("$NetBSD: extern.c,v 1.2 1997/10/10 16:33:24 lukem Exp $"); +__RCSID("$NetBSD: extern.c,v 1.3 2002/09/20 20:54:16 mycroft Exp $"); #endif /* not lint */ # include "hunt.h" @@ -20,10 +20,8 @@ char Buf[BUFSIZ]; /* general scribbling buffer */ char Maze[HEIGHT][WIDTH2]; /* the maze */ char Orig_maze[HEIGHT][WIDTH2]; /* the original maze */ -fd_set Fds_mask; /* mask for the file descriptors */ -fd_set Have_inp; /* which file descriptors have input */ +struct pollfd fdset[3+MAXPL+MAXMON]; int Nplayer = 0; /* number of players */ -int Num_fds; /* number of maximum file descriptor */ int Socket; /* main socket */ int Status; /* stat socket */ int See_over[NASCII]; /* lookup table for determining whether diff --git a/hunt/huntd/faketalk.c b/hunt/huntd/faketalk.c index 3f140cf..42b8123 100644 --- a/hunt/huntd/faketalk.c +++ b/hunt/huntd/faketalk.c @@ -1,4 +1,4 @@ -/* $NetBSD: faketalk.c,v 1.4 1997/10/11 08:13:48 lukem Exp $ */ +/* $NetBSD: faketalk.c,v 1.7 2002/09/20 20:54:16 mycroft Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold @@ -11,10 +11,11 @@ #include #ifndef lint -__RCSID("$NetBSD: faketalk.c,v 1.4 1997/10/11 08:13:48 lukem Exp $"); +__RCSID("$NetBSD: faketalk.c,v 1.7 2002/09/20 20:54:16 mycroft Exp $"); #endif /* not lint */ #include "bsd.h" +#include "hunt.h" #if defined(TALK_43) || defined(TALK_42) @@ -26,7 +27,6 @@ __RCSID("$NetBSD: faketalk.c,v 1.4 1997/10/11 08:13:48 lukem Exp $"); # include # include # include -# include "hunt.h" # include "talk_ctl.h" # define TRUE 1 @@ -43,17 +43,17 @@ __RCSID("$NetBSD: faketalk.c,v 1.4 1997/10/11 08:13:48 lukem Exp $"); extern char *my_machine_name; extern char *First_arg, *Last_arg; +extern char **environ; static void do_announce __P((char *)); SIGNAL_TYPE exorcise __P((int)); - /* * exorcise - disspell zombies */ SIGNAL_TYPE exorcise(dummy) - int dummy __attribute__((unused)); + int dummy __attribute__((__unused__)); { (void) wait(0); } @@ -73,7 +73,6 @@ faketalk() struct sockaddr_in des; /* address of destination */ char *a; const char *b; - extern char **environ; (void) signal(SIGCHLD, exorcise); @@ -124,7 +123,7 @@ faketalk() # else warn("falktalk: socket"); # endif - _exit(-1); + _exit(1); } if (connect(service, (struct sockaddr *) &des, sizeof(des)) != 0) { @@ -133,7 +132,7 @@ faketalk() # else warn("faketalk: connect"); # endif - _exit(-1); + _exit(1); } if ((f = fdopen(service, "r")) == NULL) { # ifdef LOG @@ -141,7 +140,7 @@ faketalk() # else warn("faketalk: fdopen"); # endif - _exit(-2); + _exit(2); } (void) fgets(buf, BUFSIZ, f); @@ -190,7 +189,6 @@ do_announce(s) char *s; { CTL_RESPONSE response; - extern struct sockaddr_in ctl_addr; get_remote_name(s); /* setup his_machine_addr, msg.r_name */ @@ -225,6 +223,7 @@ do_announce(s) p_error("send delete remote"); } #else +void faketalk() { return; diff --git a/hunt/huntd/hunt.h b/hunt/huntd/hunt.h index 0153dab..77a4cf8 100644 --- a/hunt/huntd/hunt.h +++ b/hunt/huntd/hunt.h @@ -1,4 +1,4 @@ -/* $NetBSD: hunt.h,v 1.5 1998/09/13 15:27:28 hubertf Exp $ */ +/* $NetBSD: hunt.h,v 1.7 2002/09/20 20:54:17 mycroft Exp $ */ /* * Hunt @@ -21,7 +21,7 @@ # endif # include # include -# include +# include # ifdef INTERNET # include # include @@ -82,6 +82,7 @@ # define MAXMON 1 # else # define MAXPL 17 +# define MAXMON 0 # endif # define SHORTLEN 2 /* sizeof (network short) */ # define LONGLEN 4 /* sizeof (network long) */ @@ -348,8 +349,8 @@ extern char Buf[BUFSIZ], Maze[HEIGHT][WIDTH2], Orig_maze[HEIGHT][WIDTH2]; extern char *Sock_name; extern const char *Driver; -extern int Nplayer, Num_fds, Socket, Status; -extern fd_set Fds_mask, Have_inp; +extern int Nplayer, Socket, Status; +extern struct pollfd fdset[]; # ifdef INTERNET extern u_short Test_port; @@ -393,8 +394,8 @@ extern FLAG no_beep; void add_shot __P((int, int, int, char, int, PLAYER *, int, char)); int answer __P((void)); -void bad_con __P((void)); -void bad_ver __P((void)); +void bad_con __P((void)) __attribute__((__noreturn__)); +void bad_ver __P((void)) __attribute__((__noreturn__)); int broadcast_vec __P((int, struct sockaddr **)); void ce __P((PLAYER *)); void cgoto __P((PLAYER *, int, int)); @@ -453,6 +454,6 @@ char translate __P((char)); SIGNAL_TYPE cleanup __P((int)) __attribute__((__noreturn__)); SIGNAL_TYPE intr __P((int)); SIGNAL_TYPE sigalrm __P((int)); -SIGNAL_TYPE sigemt __P((int)); -SIGNAL_TYPE sigterm __P((int)); +SIGNAL_TYPE sigemt __P((int)) __attribute__((__noreturn__)); +SIGNAL_TYPE sigterm __P((int)) __attribute__((__noreturn__)); SIGNAL_TYPE tstp __P((int)); diff --git a/hunt/huntd/huntd.6.in b/hunt/huntd/huntd.6.in index 169419a..a6eb8f2 100644 --- a/hunt/huntd/huntd.6.in +++ b/hunt/huntd/huntd.6.in @@ -1,4 +1,4 @@ -.\" $NetBSD: huntd.6,v 1.3 1998/01/09 08:03:42 perry Exp $ +.\" $NetBSD: huntd.6,v 1.6 2002/09/26 18:32:02 wiz Exp $ .\" .\" Hunt .\" Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold @@ -8,93 +8,94 @@ .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" -.TH HUNTD 6 "21 August 1986" -.UC 4 -.SH NAME -huntd \- hunt daemon, back-end for hunt game -.SH SYNOPSIS -\fB@sbindir@/huntd\fP [ \fB\-s\fP ] [ \fB\-p\fP port ] -.SH DESCRIPTION -.PP -.I huntd +.Dd April 4, 2001 +.Dt HUNTD 6 +.Sh NAME +.Nm huntd +.Nd hunt daemon, back-end for hunt game +.Sh SYNOPSIS +.Nm +.Op Fl s +.Op Fl p Ar port +.Sh DESCRIPTION +.Nm controls the multi-player -.IR hunt (6) +.Xr hunt 6 game. When it starts up, it tries to notify all members of the -.I hunt-players +.Em hunt-players mailing list (see -.IR sendmail (8)) +.Xr sendmail 8 ) by faking a -.IR talk (1) -request from user ``Hunt Game''. -.PP +.Xr talk 1 +request from user +.Dq Hunt Game . +.Pp The -.B \-s +.Fl s option is for running -.I huntd +.Nm forever (server mode). This is similar to running it under the control of -.I inetd -(see below), -but it consumes a process table entry when no one is playing. -.PP +.Xr inetd 8 +(see below), but it consumes a process table entry when no one is playing. +.Pp The -.B \-p -option changes the udp port number used to rendezvous with the player +.Fl p +option changes the UDP port number used to rendezvous with the player process and thus allows for private games of hunt. This option turns off the notification of players on the -.I hunt-players +.Em hunt-players mailing list. -.SH INETD -.PP +.Ss INETD To run -.I huntd +.Nm from -.IR inetd , -you'll need to put the -.I hunt +.Xr inetd 8 , +you'll need to +put the +.Nm hunt service in -.BR /etc/services : -.IP +.Pa /etc/services : +.Bd -literal hunt 26740/udp # multi-player/multi-host mazewars -.LP -and add a line in -.BR /etc/inetd.conf : -.IP -hunt dgram udp wait nobody @sbindir@/huntd HUNT -.LP -except for Suns which use -.BR /etc/servers : -.IP -hunt udp @sbindir@/huntd -.LP -Do not use any of the command line options \(em if you want -.I inetd +.Ed +and +add the following line to +.Pa /etc/inetd.conf : +.Bd -literal -offset indent -compact +hunt dgram udp wait nobody @sbindir@/huntd huntd +.Ed +Do not use any of the command line options; if you want +.Xr inetd 8 to start up -.I huntd -on a private port, change the port listed in -.BR /etc/services . -.SH "NETWORK RENDEZVOUS" +.Nm +on a private port, change the port listed for +.Nm hunt +in +.Pa /etc/services . +.Sh NETWORK RENDEZVOUS When -.IR hunt (6) +.Xr hunt 6 starts up, it broadcasts on the local area net (using the broadcast address for each interface) to find a -.I hunt +.Nm hunt game in progress. If a -.I huntd +.Nm hears the request, it sends back the port number for the -.I hunt +.Nm hunt process to connect to. Otherwise, the -.I hunt +.Nm hunt process starts up a -.I huntd -on the local machine and trys to rendezvous with it. -.SH "SEE ALSO" -hunt(6), talk(1), sendmail(8) -.SH AUTHORS +.Nm +on the local machine and tries to rendezvous with it. +.Sh SEE ALSO +.Xr talk 1 , +.Xr hunt 6 , +.Xr sendmail 8 +.Sh AUTHORS Conrad Huang, Ken Arnold, and Greg Couch; .br University of California, San Francisco, Computer Graphics Lab -.\"SH BUGS diff --git a/hunt/huntd/terminal.c b/hunt/huntd/terminal.c index 8766687..8db22e6 100644 --- a/hunt/huntd/terminal.c +++ b/hunt/huntd/terminal.c @@ -1,4 +1,4 @@ -/* $NetBSD: terminal.c,v 1.2 1997/10/10 16:34:05 lukem Exp $ */ +/* $NetBSD: terminal.c,v 1.3 2002/05/26 00:12:13 wiz Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold @@ -7,16 +7,12 @@ #include #ifndef lint -__RCSID("$NetBSD: terminal.c,v 1.2 1997/10/10 16:34:05 lukem Exp $"); +__RCSID("$NetBSD: terminal.c,v 1.3 2002/05/26 00:12:13 wiz Exp $"); #endif /* not lint */ -#if __STDC__ #include -#else -#include -#endif -# include "hunt.h" -# define TERM_WIDTH 80 /* Assume terminals are 80-char wide */ +#include "hunt.h" +#define TERM_WIDTH 80 /* Assume terminals are 80-char wide */ /* * cgoto: @@ -110,22 +106,12 @@ ref(pp) * Send a command to the given user */ void -#if __STDC__ sendcom(PLAYER *pp, int command, ...) -#else -sendcom(pp, command, va_alist) - PLAYER *pp; - int command; - va_dcl -#endif { va_list ap; int arg1, arg2; -#if __STDC__ + va_start(ap, command); -#else - va_start(ap); -#endif (void) putc(command, pp->p_output); switch (command & 0377) { case MOVE: diff --git a/include/signal.h b/include/signal.h index 6b5eba9..ba31c1c 100644 --- a/include/signal.h +++ b/include/signal.h @@ -1,4 +1,35 @@ -/* signal.h - bsd-games wrapper for */ +/* signal.h - bsd-games wrapper for . + * + * Copyright (c) 1997, 1998, 2000 Joseph Samuel Myers. + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ + +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +#pragma GCC system_header +#endif #include diff --git a/include/stdio.h b/include/stdio.h index c9a0802..32a4b71 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -1,5 +1,39 @@ -/* stdio.h - bsd-games wrapper for */ +/* stdio.h - bsd-games wrapper for . + * + * Copyright (c) 1998, 1999, 2000 Joseph Samuel Myers. + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +#pragma GCC system_header +#endif + +#include #include_next +#ifndef HAVE_fgetln extern char *fgetln(FILE *stream, size_t *len); +#endif diff --git a/include/stdlib.h b/include/stdlib.h index 1c18766..bdbed6f 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -1,5 +1,39 @@ -/* stdlib.h - bsd-games wrapper for */ +/* stdlib.h - bsd-games wrapper for . + * + * Copyright (c) 1998, 1999, 2000 Joseph Samuel Myers. + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +#pragma GCC system_header +#endif + +#include #include_next +#ifndef HAVE_getloadavg extern int getloadavg(double loadavg[], int nelem); +#endif diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h index c0f5c5c..138eaa8 100644 --- a/include/sys/cdefs.h +++ b/include/sys/cdefs.h @@ -1,11 +1,42 @@ -/* cdefs.h - bsd-games wrapper for */ +/* cdefs.h - bsd-games wrapper for . + * + * Copyright (c) 1997, 1998, 1999, 2000 Joseph Samuel Myers. + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ + +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +#pragma GCC system_header +#endif #include_next #ifndef __RCSID -#define __RCSID(arg) static const char rcsid[] __attribute__((unused)) = arg +#define __RCSID(arg) static const char rcsid[] __attribute__((__unused__)) = arg #endif #ifndef __COPYRIGHT -#define __COPYRIGHT(arg) static const char copyright[] __attribute__((unused)) = arg +#define __COPYRIGHT(arg) static const char copyright[] __attribute__((__unused__)) = arg #endif diff --git a/include/sys/ttydefaults.h b/include/sys/ttydefaults.h index 92da697..1966aa7 100644 --- a/include/sys/ttydefaults.h +++ b/include/sys/ttydefaults.h @@ -1,4 +1,35 @@ -/* ttydefaults.h - bsd-games wrapper for */ +/* ttydefaults.h - bsd-games wrapper for . + * + * Copyright (c) 1997, 1998, 2000 Joseph Samuel Myers. + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ + +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +#pragma GCC system_header +#endif #include diff --git a/include/termios.h b/include/termios.h index 7bca609..80d5514 100644 --- a/include/termios.h +++ b/include/termios.h @@ -1,4 +1,35 @@ -/* termios.h - bsd-games wrapper for */ +/* termios.h - bsd-games wrapper for . + * + * Copyright (c) 1998, 2000 Joseph Samuel Myers. + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ + +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +#pragma GCC system_header +#endif #include_next diff --git a/lib/Makefrag b/lib/Makefrag index 23d1f60..94731b8 100644 --- a/lib/Makefrag +++ b/lib/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for lib +# +# Copyright (c) 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. # No special rules needed, but we need these dummy targets diff --git a/lib/fgetln.c b/lib/fgetln.c index 4d3b3dd..fb5e061 100644 --- a/lib/fgetln.c +++ b/lib/fgetln.c @@ -1,8 +1,37 @@ -/* fgetln.c - bsd-games implementation of fgetln */ +/* lib/fgetln.c - bsd-games implementation of fgetln. + * + * Copyright (c) 1997, 1998, 1999, 2000 Joseph Samuel Myers. + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ #include #include +#include +#ifndef HAVE_fgetln char * fgetln(FILE *stream, size_t *len) { @@ -34,3 +63,4 @@ fgetln(FILE *stream, size_t *len) *len = strlen(buf); return buf; } +#endif /* !defined(HAVE_fgetln) */ diff --git a/lib/getloadavg.c b/lib/getloadavg.c index 6050731..fa76b1a 100644 --- a/lib/getloadavg.c +++ b/lib/getloadavg.c @@ -1,8 +1,36 @@ -/* getloadavg.c - bsd-games implementation of getloadavg */ +/* lib/getloadavg.c - bsd-games implementation of getloadavg. + * + * Copyright (c) 1998, 1999 Joseph Samuel Myers. + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ #include #include +#ifndef HAVE_getloadavg int getloadavg(double loadavg[], int nelem) { @@ -24,3 +52,4 @@ getloadavg(double loadavg[], int nelem) loadavg[i] = load_averages[i]; return nc; } +#endif diff --git a/mille/Makefrag b/mille/Makefrag index 2a0f3f8..4cd62ba 100644 --- a/mille/Makefrag +++ b/mille/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for mille +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. mille_DIRS := $(GAMESDIR) $(MAN6DIR) diff --git a/mille/comp.c b/mille/comp.c index ef39525..b184e6b 100644 --- a/mille/comp.c +++ b/mille/comp.c @@ -1,4 +1,4 @@ -/* $NetBSD: comp.c,v 1.5 1997/10/12 00:53:45 lukem Exp $ */ +/* $NetBSD: comp.c,v 1.8 1999/09/30 18:01:32 jsm Exp $ */ /* * Copyright (c) 1982, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)comp.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: comp.c,v 1.5 1997/10/12 00:53:45 lukem Exp $"); +__RCSID("$NetBSD: comp.c,v 1.8 1999/09/30 18:01:32 jsm Exp $"); #endif #endif /* not lint */ diff --git a/mille/extern.c b/mille/extern.c index 555710e..81039ff 100644 --- a/mille/extern.c +++ b/mille/extern.c @@ -1,4 +1,4 @@ -/* $NetBSD: extern.c,v 1.5 1997/10/12 00:53:55 lukem Exp $ */ +/* $NetBSD: extern.c,v 1.6 1999/09/08 21:17:50 jsm Exp $ */ /* * Copyright (c) 1982, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)extern.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: extern.c,v 1.5 1997/10/12 00:53:55 lukem Exp $"); +__RCSID("$NetBSD: extern.c,v 1.6 1999/09/08 21:17:50 jsm Exp $"); #endif #endif /* not lint */ diff --git a/mille/init.c b/mille/init.c index b4e6673..99d7a55 100644 --- a/mille/init.c +++ b/mille/init.c @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.7 1997/10/12 00:53:59 lukem Exp $ */ +/* $NetBSD: init.c,v 1.8 1999/09/30 18:01:32 jsm Exp $ */ /* * Copyright (c) 1982, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: init.c,v 1.7 1997/10/12 00:53:59 lukem Exp $"); +__RCSID("$NetBSD: init.c,v 1.8 1999/09/30 18:01:32 jsm Exp $"); #endif #endif /* not lint */ diff --git a/mille/mille.6 b/mille/mille.6 index 0fb7ac7..b2f5c0e 100644 --- a/mille/mille.6 +++ b/mille/mille.6 @@ -1,4 +1,4 @@ -.\" $NetBSD: mille.6,v 1.6 1997/10/12 00:54:03 lukem Exp $ +.\" $NetBSD: mille.6,v 1.8 2002/09/26 16:12:41 wiz Exp $ .\" .\" Copyright (c) 1983, 1993 .\" The Regents of the University of California. All rights reserved. @@ -57,12 +57,14 @@ This card is placed in the `P' slot in your hand. .IP D Discard a card from your hand. To indicate which card, type the number of the card in the hand -(or \*(lqP\*(rq for the just-picked card) followed by a or . -The is required to allow recovery from typos +(or \*(lqP\*(rq for the just-picked card) followed +by a \*[Lt]RETURN\*[Gt] or \*[Lt]SPACE\*[Gt]. +The \*[Lt]RETURN or \*[Lt]SPACE\*[Gt] is required to allow recovery from typos which can be very expensive, like discarding safeties. .IP U Use a card. -The card is again indicated by its number, followed by a or . +The card is again indicated by its number, +followed by a \*[Lt]RETURN\*[Gt] or \*[Lt]SPACE\*[Gt]. .IP O Toggle ordering the hand. By default off, if turned on it will sort the cards in your hand appropriately. @@ -70,14 +72,14 @@ This is not recommended for the impatient on slow terminals. .IP Q Quit the game. This will ask for confirmation, just to be sure. -Hitting (or ) is equivalent. +Hitting \*[Lt]DELETE\*[Gt] (or \*[Lt]RUBOUT\*[Gt]) is equivalent. .IP S Save the game in a file. If the game was started from a file, you will be given an opportunity to save it on the same file. If you don't wish to, or you did not start from a file, you will be asked for the file name. -If you type a without a name, +If you type a \*[Lt]RETURN\*[Gt] without a name, the save will be terminated and the game resumed. .IP R Redraw the screen from scratch. @@ -193,9 +195,11 @@ All the Hazard and Remedy Cards are played here, except the .I "Speed Limit" and .I "End of Limit" -cards. Only the top card is displayed, as it is the only effective one. +cards. +Only the top card is displayed, as it is the only effective one. .BR SPEED : -The Speed pile. The +The Speed pile. +The .I "Speed Limit" and .I "End of Limit" @@ -209,8 +213,9 @@ The total of the numbers shown here is the distance traveled so far. The first pick alternates between the two players. Each turn usually starts with a pick from the deck. The player then plays a card, or if this is not possible or desirable, -discards one. Normally, a play or discard of a single card -constitutes a turn. If the card played is a safety, however, +discards one. +Normally, a play or discard of a single card constitutes a turn. +If the card played is a safety, however, the same player takes another turn immediately. .PP This repeats until one of the players reaches 700 points or the deck runs out. @@ -252,7 +257,8 @@ played by your opponent. .RB "\ \ \ \ " "Out of Gas" is played on your opponent's .I Go -card. They must then play a +card. +They must then play a .I Gasoline card, and then a .I Go @@ -261,7 +267,8 @@ card before they can play any more mileage. .RB "\ \ \ \ " "Flat Tire" is played on your opponent's .I Go -card. They must then play a +card. +They must then play a .I "Spare Tire" card, and then a .I Go @@ -271,7 +278,8 @@ card before they can play any more mileage. .RB "\ \ \ \ " "Accident" is played on your opponent's .I Go -card. They must then play a +card. +They must then play a .I Repairs card, and then a .I Go @@ -289,7 +297,8 @@ prevents your opponent from playing both .I Stop and .I "Speed Limit" -cards on you. It also acts as a permanent +cards on you. +It also acts as a permanent .I Go card for the rest of the hand, so you can play mileage as long as there is not a Hazard card on top of your Battle pile. @@ -334,9 +343,10 @@ If an opponent plays a Hazard card, and you have the corresponding Safety in your hand, you play it immediately, even .I before -you draw. This immediately removes the Hazard card from your Battle pile, -and protects you from that card for the rest of the game. This -gives you more points (see \*(lqScoring\*(rq below). +you draw. +This immediately removes the Hazard card from your Battle pile, +and protects you from that card for the rest of the game. +This gives you more points (see \*(lqScoring\*(rq below). .PP .BR Scoring : Scores are totaled at the end of each hand, diff --git a/mille/mille.c b/mille/mille.c index 36e9112..3b1ff7b 100644 --- a/mille/mille.c +++ b/mille/mille.c @@ -1,4 +1,4 @@ -/* $NetBSD: mille.c,v 1.6 1997/10/12 00:54:07 lukem Exp $ */ +/* $NetBSD: mille.c,v 1.12 2001/12/06 12:12:34 blymn Exp $ */ /* * Copyright (c) 1982, 1993 @@ -43,15 +43,12 @@ __COPYRIGHT("@(#) Copyright (c) 1982, 1993\n\ #if 0 static char sccsid[] = "@(#)mille.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: mille.c,v 1.6 1997/10/12 00:54:07 lukem Exp $"); +__RCSID("$NetBSD: mille.c,v 1.12 2001/12/06 12:12:34 blymn Exp $"); #endif #endif /* not lint */ # include "mille.h" # include -# ifdef attron -# include -# endif attron /* * @(#)mille.c 1.3 (Berkeley) 5/10/83 @@ -81,7 +78,7 @@ main(ac, av) break; default: printf("usage: milles [ restore_file ]\n"); - exit(-1); + exit(1); /* NOTREACHED */ } Play = PLAYER; @@ -103,7 +100,7 @@ main(ac, av) # else srandom(0); # endif - crmode(); + cbreak(); noecho(); signal(SIGINT, rub); for (;;) { @@ -146,7 +143,7 @@ main(ac, av) */ void rub(dummy) - int dummy __attribute__((unused)); + int dummy __attribute__((__unused__)); { (void)signal(SIGINT, SIG_IGN); if (getyn(REALLYPROMPT)) diff --git a/mille/mille.h b/mille/mille.h index 51961dd..968d080 100644 --- a/mille/mille.h +++ b/mille/mille.h @@ -1,4 +1,4 @@ -/* $NetBSD: mille.h,v 1.9 1998/09/13 15:27:29 hubertf Exp $ */ +/* $NetBSD: mille.h,v 1.11 1999/09/30 18:01:32 jsm Exp $ */ /* * Copyright (c) 1982, 1993 diff --git a/mille/misc.c b/mille/misc.c index 6971d06..11e47eb 100644 --- a/mille/misc.c +++ b/mille/misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: misc.c,v 1.7 1998/07/26 16:11:40 mycroft Exp $ */ +/* $NetBSD: misc.c,v 1.10 2002/05/26 00:12:13 wiz Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,18 +38,14 @@ #if 0 static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: misc.c,v 1.7 1998/07/26 16:11:40 mycroft Exp $"); +__RCSID("$NetBSD: misc.c,v 1.10 2002/05/26 00:12:13 wiz Exp $"); #endif #endif /* not lint */ #include #include -#if __STDC__ -#include -#else -#include -#endif +#include #include "mille.h" #ifndef unctrl @@ -57,10 +53,6 @@ __RCSID("$NetBSD: misc.c,v 1.7 1998/07/26 16:11:40 mycroft Exp $"); #endif -# ifdef attron -# include -# endif attron - /* * @(#)misc.c 1.2 (Berkeley) 3/28/83 */ @@ -68,24 +60,14 @@ __RCSID("$NetBSD: misc.c,v 1.7 1998/07/26 16:11:40 mycroft Exp $"); #define NUMSAFE 4 bool -#if __STDC__ error(const char *str, ...) -#else -error(str, va_alist) - const char *str; - va_dcl -#endif { va_list ap; -#if __STDC__ va_start(ap, str); -#else - va_start(ap); -#endif wmove(Score, ERR_Y, ERR_X); vwprintw(Score, str, ap); - clrtoeol(); + wclrtoeol(Score); putchar('\07'); refresh(); va_end(ap); diff --git a/mille/move.c b/mille/move.c index 2086784..d3f3a16 100644 --- a/mille/move.c +++ b/mille/move.c @@ -1,4 +1,4 @@ -/* $NetBSD: move.c,v 1.7 1997/10/12 00:54:21 lukem Exp $ */ +/* $NetBSD: move.c,v 1.12 1999/10/01 17:06:01 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: move.c,v 1.7 1997/10/12 00:54:21 lukem Exp $"); +__RCSID("$NetBSD: move.c,v 1.12 1999/10/01 17:06:01 jsm Exp $"); #endif #endif /* not lint */ @@ -49,10 +49,6 @@ __RCSID("$NetBSD: move.c,v 1.7 1997/10/12 00:54:21 lukem Exp $"); #include "unctrl.h" #endif -# ifdef attron -# include -# endif attron - /* * @(#)move.c 1.2 (Berkeley) 3/28/83 */ diff --git a/mille/print.c b/mille/print.c index 5fea390..4d0f71a 100644 --- a/mille/print.c +++ b/mille/print.c @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.6 1997/10/12 00:54:24 lukem Exp $ */ +/* $NetBSD: print.c,v 1.10 2000/04/27 17:49:15 thorpej Exp $ */ /* * Copyright (c) 1982, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: print.c,v 1.6 1997/10/12 00:54:24 lukem Exp $"); +__RCSID("$NetBSD: print.c,v 1.10 2000/04/27 17:49:15 thorpej Exp $"); #endif #endif /* not lint */ @@ -89,7 +89,7 @@ prboard() pp = &Player[PLAYER]; for (i = 0; i < HAND_SZ; i++) show_card(i + 6, temp, pp->hand[i], &pp->sh_hand[i]); - mvprintw(6, COMP_STRT + CARD_STRT, "%2d", Topcard - Deck); + mvprintw(6, COMP_STRT + CARD_STRT, "%2ld", (long)(Topcard - Deck)); show_card(8, COMP_STRT + CARD_STRT, Discard, &Sh_discard); if (End == 1000) { move(EXT_Y, EXT_X); @@ -122,7 +122,11 @@ static char Score_fmt[] = "%4d"; void prscore(for_real) - bool for_real; +#ifdef EXTRAP + bool for_real; +#else + bool for_real __attribute__((__unused__)); +#endif { PLAY *pp; int x; diff --git a/mille/save.c b/mille/save.c index d608a67..271057c 100644 --- a/mille/save.c +++ b/mille/save.c @@ -1,4 +1,4 @@ -/* $NetBSD: save.c,v 1.6 1997/10/12 00:54:32 lukem Exp $ */ +/* $NetBSD: save.c,v 1.10 1999/09/09 17:30:20 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,22 +38,18 @@ #if 0 static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: save.c,v 1.6 1997/10/12 00:54:32 lukem Exp $"); +__RCSID("$NetBSD: save.c,v 1.10 1999/09/09 17:30:20 jsm Exp $"); #endif #endif /* not lint */ +#include + #include "mille.h" #ifndef unctrl #include "unctrl.h" #endif -# ifdef attron -# include -# endif attron - -#include - /* * @(#)save.c 1.2 (Berkeley) 3/28/83 */ @@ -85,7 +81,7 @@ over: leaveok(Board, FALSE); refresh(); sp = buf; - while ((*sp = readch()) != '\n') { + while ((*sp = readch()) != '\n' && *sp != '\r') { if (*sp == killchar()) goto over; else if (*sp == erasechar()) { diff --git a/mille/types.c b/mille/types.c index 579dd0f..772ddbc 100644 --- a/mille/types.c +++ b/mille/types.c @@ -1,4 +1,4 @@ -/* $NetBSD: types.c,v 1.6 1997/10/12 00:54:40 lukem Exp $ */ +/* $NetBSD: types.c,v 1.7 1999/09/30 18:01:32 jsm Exp $ */ /* * Copyright (c) 1982, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)types.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: types.c,v 1.6 1997/10/12 00:54:40 lukem Exp $"); +__RCSID("$NetBSD: types.c,v 1.7 1999/09/30 18:01:32 jsm Exp $"); #endif #endif /* not lint */ diff --git a/monop/Makefile.bsd b/monop/Makefile.bsd index 1030635..795a1da 100644 --- a/monop/Makefile.bsd +++ b/monop/Makefile.bsd @@ -1,21 +1,25 @@ -# $NetBSD: Makefile,v 1.18 1998/09/12 19:05:48 wrstuden Exp $ +# $NetBSD: Makefile,v 1.22 2002/03/05 21:30:41 thorpej Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 +.include + PROG= monop SRCS= monop.c cards.c execute.c getinp.c houses.c jail.c misc.c morg.c \ print.c prop.c rent.c roll.c spec.c trade.c MAN= monop.6 HIDEGAME=hidegame CLEANFILES+=initdeck cards.pck +.if ${MKSHARE} != "no" FILES=cards.pck FILESDIR=/usr/share/games +.endif -monop: cards.pck +realall: ${FILES} initdeck: initdeck.c ${HOST_LINK.c} -o initdeck ${.CURDIR}/initdeck.c cards.pck: initdeck - ${.OBJDIR}/initdeck ${.CURDIR}/cards.inp + ./initdeck ${.CURDIR}/cards.inp .include diff --git a/monop/Makefrag b/monop/Makefrag index b8afd34..a3a42eb 100644 --- a/monop/Makefrag +++ b/monop/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for monop +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. monop_CLEANFILES := cards.pck monop_DIRS := $(GAMESDIR) $(MAN6DIR) $(shell dirname $(MONOP_CARDSFILE)) diff --git a/monop/cards.c b/monop/cards.c index c347569..b8372f5 100644 --- a/monop/cards.c +++ b/monop/cards.c @@ -1,4 +1,4 @@ -/* $NetBSD: cards.c,v 1.5 1998/08/30 09:19:39 veego Exp $ */ +/* $NetBSD: cards.c,v 1.12 2002/08/12 02:38:13 itojun Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,24 +38,26 @@ #if 0 static char sccsid[] = "@(#)cards.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: cards.c,v 1.5 1998/08/30 09:19:39 veego Exp $"); +__RCSID("$NetBSD: cards.c,v 1.12 2002/08/12 02:38:13 itojun Exp $"); #endif #endif /* not lint */ -# include "monop.ext" -# include "pathnames.h" +#include +#include +#include "monop.ext" +#include "pathnames.h" /* * These routine deal with the card decks */ -# define GOJF 'F' /* char for get-out-of-jail-free cards */ +#define GOJF 'F' /* char for get-out-of-jail-free cards */ -# ifndef DEV -static char *cardfile = _PATH_CARDS; -# else -static char *cardfile = "cards.pck"; -# endif +#ifndef DEV +static const char *cardfile = _PATH_CARDS; +#else +static const char *cardfile = "cards.pck"; +#endif static FILE *deckf; @@ -69,36 +71,51 @@ static void printmes __P((void)); void init_decks() { + int32_t nc; if ((deckf=fopen(cardfile, "r")) == NULL) { file_err: perror(cardfile); exit(1); } - if (fread(deck, sizeof (DECK), 2, deckf) != 2) + + /* read number of community chest cards... */ + if (fread(&nc, sizeof(nc), 1, deckf) != 1) goto file_err; + CC_D.num_cards = be32toh(nc); + /* ... and number of community chest cards. */ + if (fread(&nc, sizeof(nc), 1, deckf) != 1) + goto file_err; + CH_D.num_cards = be32toh(nc); set_up(&CC_D); set_up(&CH_D); } + /* * This routine sets up the offset pointers for the given deck. */ static void set_up(dp) -DECK *dp; { + DECK *dp; +{ + int r1, r2; + int i; - int r1, r2; - int i; - - dp->offsets = (long *) calloc(sizeof (long), dp->num_cards); - if (fread(dp->offsets, sizeof(long), dp->num_cards, deckf) != (size_t)dp->num_cards) { + dp->offsets = (u_int64_t *) calloc(dp->num_cards, sizeof (u_int64_t)); + if (dp->offsets == NULL) + err(1, NULL); + if (fread(dp->offsets, sizeof(u_int64_t), dp->num_cards, deckf) != + (size_t)dp->num_cards) { perror(cardfile); exit(1); } + /* convert offsets from big-endian byte order */ + for (i = 0; i < dp->num_cards; i++) + BE64TOH(dp->offsets[i]); dp->last_card = 0; dp->gojf_used = FALSE; for (i = 0; i < dp->num_cards; i++) { - long temp; + u_int64_t temp; r1 = roll(1, dp->num_cards) - 1; r2 = roll(1, dp->num_cards) - 1; @@ -107,26 +124,26 @@ DECK *dp; { dp->offsets[r1] = temp; } } + /* * This routine draws a card from the given deck */ void get_card(dp) -DECK *dp; + DECK *dp; { - - char type_maj, type_min; - int num; - int i, per_h, per_H, num_h, num_H; - OWN *op; + char type_maj, type_min; + int num; + int i, per_h, per_H, num_h, num_H; + OWN *op; do { - fseek(deckf, dp->offsets[dp->last_card], 0); + fseek(deckf, dp->offsets[dp->last_card], SEEK_SET); dp->last_card = ++(dp->last_card) % dp->num_cards; type_maj = getc(deckf); } while (dp->gojf_used && type_maj == GOJF); type_min = getc(deckf); - num = getw(deckf); + num = ntohl(getw(deckf)); printmes(); switch (type_maj) { case '+': /* get money */ @@ -195,7 +212,9 @@ DECK *dp; num_h += op->sqr->desc->houses; } num = per_h * num_h + per_H * num_H; - printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num); + printf( + "You had %d Houses and %d Hotels, so that cost you $%d\n", + num_h, num_H, num); if (num == 0) lucky(""); else @@ -213,9 +232,9 @@ DECK *dp; * This routine prints out the message on the card */ static void -printmes() { - - char c; +printmes() +{ + char c; printline(); fflush(stdout); diff --git a/monop/cards.inp b/monop/cards.inp index 1867e87..4b6aa81 100644 --- a/monop/cards.inp +++ b/monop/cards.inp @@ -93,7 +93,7 @@ Take a Walk on the Board Walk. (Advance To Board Walk) %% MF24 -Advance to Illinos Ave. +Advance to Illinois Ave. %% MF0 Advance to Go diff --git a/monop/deck.h b/monop/deck.h index 5516623..3969af8 100644 --- a/monop/deck.h +++ b/monop/deck.h @@ -1,4 +1,4 @@ -/* $NetBSD: deck.h,v 1.3 1995/03/23 08:34:36 cgd Exp $ */ +/* $NetBSD: deck.h,v 1.5 1999/08/21 10:40:03 simonb Exp $ */ /* * Copyright (c) 1980, 1993 @@ -35,16 +35,18 @@ * @(#)deck.h 8.1 (Berkeley) 5/31/93 */ -# define bool char +#include -# define CC_D deck[0] -# define CH_D deck[1] +#define bool char + +#define CC_D deck[0] +#define CH_D deck[1] struct dk_st { /* deck description structure */ int num_cards; /* number of cards in deck */ int last_card; /* number of last card picked */ bool gojf_used; /* set if gojf card out of deck */ - long *offsets; /* offests for start of cards */ + u_int64_t *offsets; /* offsets for start of cards */ }; typedef struct dk_st DECK; diff --git a/monop/execute.c b/monop/execute.c index 3e9aa0a..2eb9aa8 100644 --- a/monop/execute.c +++ b/monop/execute.c @@ -1,4 +1,4 @@ -/* $NetBSD: execute.c,v 1.5 1998/09/11 13:54:08 hubertf Exp $ */ +/* $NetBSD: execute.c,v 1.8 2001/08/29 18:23:44 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)execute.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: execute.c,v 1.5 1998/09/11 13:54:08 hubertf Exp $"); +__RCSID("$NetBSD: execute.c,v 1.8 2001/08/29 18:23:44 jsm Exp $"); #endif #endif /* not lint */ @@ -49,8 +49,9 @@ __RCSID("$NetBSD: execute.c,v 1.5 1998/09/11 13:54:08 hubertf Exp $"); #include #include #include +#include -# define SEGSIZE 8192 +#define SEGSIZE 8192 typedef struct stat STAT; typedef struct tm TIME; @@ -66,9 +67,8 @@ static void show_move __P((void)); */ void execute(com_num) -int com_num; + int com_num; { - new_play = FALSE; /* new_play is true if fixing */ (*func[com_num])(); notify(); @@ -78,15 +78,15 @@ int com_num; else if (num_doub) printf("%s rolled doubles. Goes again\n", cur_p->name); } + /* * This routine moves a piece around. */ void do_move() { - - int r1, r2; - bool was_jail; + int r1, r2; + bool was_jail; new_play = was_jail = FALSE; printf("roll is %d, %d\n", r1=roll(1, 6), r2=roll(1, 6)); @@ -111,15 +111,15 @@ do_move() ret: return; } + /* * This routine moves a normal move */ void move(rl) -int rl; + int rl; { - - int old_loc; + int old_loc; old_loc = cur_p->loc; cur_p->loc = (cur_p->loc + rl) % N_SQRS; @@ -129,14 +129,14 @@ int rl; } show_move(); } + /* * This routine shows the results of a move */ static void show_move() { - - SQUARE *sqp; + SQUARE *sqp; sqp = &board[cur_p->loc]; printf("That puts you on %s\n", sqp->name); @@ -172,18 +172,18 @@ show_move() rent(sqp); } } + /* * This routine saves the current game for use at a later date */ void save() { - - char *sp; - int outf, num; - time_t t; - struct stat sb; - char *start, *end; + char *sp; + int outf, num; + time_t t; + struct stat sb; + char *start, *end; printf("Which file do you wish to save it in? "); sp = buf; @@ -219,14 +219,14 @@ save() close(outf); printf("[%s]\n", buf); } + /* * This routine restores an old game from a file */ void restore() { - - char *sp; + char *sp; printf("Which file do you wish to restore from? "); for (sp = buf; (*sp=getchar()) != '\n'; sp++) @@ -234,20 +234,20 @@ restore() *sp = '\0'; rest_f(buf); } + /* * This does the actual restoring. It returns TRUE if the * backup was successful, else false. */ int rest_f(file) -char *file; + const char *file; { - - char *sp; - int inf, num; - char buf[80]; - char *start, *end; - STAT sbuf; + char *sp; + int inf, num; + char buf[80]; + char *start, *end; + STAT sbuf; if ((inf=open(file, O_RDONLY)) < 0) { perror(file); diff --git a/monop/getinp.c b/monop/getinp.c index cbb8dc4..0c4cf32 100644 --- a/monop/getinp.c +++ b/monop/getinp.c @@ -1,4 +1,4 @@ -/* $NetBSD: getinp.c,v 1.6 1997/10/12 17:45:10 christos Exp $ */ +/* $NetBSD: getinp.c,v 1.10 2003/01/06 13:04:55 wiz Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)getinp.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: getinp.c,v 1.6 1997/10/12 17:45:10 christos Exp $"); +__RCSID("$NetBSD: getinp.c,v 1.10 2003/01/06 13:04:55 wiz Exp $"); #endif #endif /* not lint */ @@ -47,27 +47,26 @@ __RCSID("$NetBSD: getinp.c,v 1.6 1997/10/12 17:45:10 christos Exp $"); #include #include "monop.ext" -# define LINE 70 +#define LINE 70 static char buf[257]; -static int comp __P((char *)); +static int comp __P((const char *)); int getinp(prompt, list) -char *prompt, *list[]; + const char *prompt, *const list[]; { - - int i, n_match, match = 0; - char *sp; - int c; + int i, n_match, match = 0; + char *sp; + int c; for (;;) { inter: - printf(prompt); + printf("%s", prompt); for (sp = buf; (c=getchar()) != '\n'; ) { *sp = c; - if (c == -1) /* check for interupted system call */ + if (c == -1) /* check for interrupted system call */ goto inter; else if (sp != buf || *sp != ' ') sp++; @@ -85,7 +84,7 @@ inter: printf(""); } else - printf(list[i]); + printf("%s", list[i]); if (list[i+1]) printf(", "); else @@ -106,16 +105,17 @@ inter: if (n_match == 1) return match; else if (buf[0] != '\0') - printf("Illegal response: \"%s\". Use '?' to get list of valid answers\n", buf); + printf("Illegal response: \"%s\". " + "Use '?' to get list of valid answers\n", buf); } } static int comp(s1) -char *s1; + const char *s1; { - - char *sp, *tsp, c; + const char *sp, *tsp; + char c; if (buf[0] != '\0') for (sp = buf, tsp = s1; *sp; ) { diff --git a/monop/houses.c b/monop/houses.c index bda0ad7..27dacc7 100644 --- a/monop/houses.c +++ b/monop/houses.c @@ -1,4 +1,4 @@ -/* $NetBSD: houses.c,v 1.4 1997/10/12 17:45:11 christos Exp $ */ +/* $NetBSD: houses.c,v 1.6 1999/09/08 21:17:51 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,14 +38,14 @@ #if 0 static char sccsid[] = "@(#)houses.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: houses.c,v 1.4 1997/10/12 17:45:11 christos Exp $"); +__RCSID("$NetBSD: houses.c,v 1.6 1999/09/08 21:17:51 jsm Exp $"); #endif #endif /* not lint */ #include "monop.ext" -static char *names[N_MON+2], - cur_prop[80]; +static const char *names[N_MON+2]; +static char cur_prop[80]; static MON *monops[N_MON]; @@ -58,12 +58,11 @@ static void list_cur __P((MON *)); void buy_houses() { - int num_mon; - MON *mp; - OWN *op; - bool good,got_morg; - int i,p; + MON *mp; + OWN *op; + bool good,got_morg; + int i,p; over: num_mon = 0; @@ -103,7 +102,9 @@ over: else { names[num_mon++] = "done"; names[num_mon--] = 0; - if ((p=getinp("Which property do you wish to buy houses for? ", names)) == num_mon) + if ((p = getinp( + "Which property do you wish to buy houses for? ", + names)) == num_mon) return; buy_h(monops[p]); goto over; @@ -112,15 +113,14 @@ over: static void buy_h(mnp) -MON *mnp; + MON *mnp; { - - int i; - MON *mp; - int price; - short input[3],temp[3]; - int tot; - PROP *pp; + int i; + MON *mp; + int price; + short input[3],temp[3]; + int tot; + PROP *pp; mp = mnp; price = mp->h_cost * 50; @@ -172,12 +172,11 @@ err: printf("That makes the spread too wide. Try again\n"); void sell_houses() { - - int num_mon; - MON *mp; - OWN *op; - bool good; - int p; + int num_mon; + MON *mp; + OWN *op; + bool good; + int p; over: num_mon = 0; @@ -205,7 +204,9 @@ over: else { names[num_mon++] = "done"; names[num_mon--] = 0; - if ((p=getinp("Which property do you wish to sell houses from? ", names)) == num_mon) + if ((p = getinp( + "Which property do you wish to sell houses from? ", + names)) == num_mon) return; sell_h(monops[p]); notify(); @@ -215,15 +216,14 @@ over: static void sell_h(mnp) -MON *mnp; + MON *mnp; { - - int i; - MON *mp; - int price; - short input[3],temp[3]; - int tot; - PROP *pp; + int i; + MON *mp; + int price; + short input[3],temp[3]; + int tot; + PROP *pp; mp = mnp; price = mp->h_cost * 25; @@ -247,7 +247,9 @@ over: input[i] = get_int(cur_prop); temp[i] = pp->houses - input[i]; if (temp[i] < 0) { - printf("That's too many. The most you can sell is %d\n", pp->houses); + printf( + "That's too many. The most you can sell is %d\n", + pp->houses); goto over; } } @@ -272,11 +274,10 @@ err: printf("That makes the spread too wide. Try again\n"); static void list_cur(mp) -MON *mp; + MON *mp; { - - int i; - SQUARE *sqp; + int i; + SQUARE *sqp; for (i = 0; i < mp->num_in; i++) { sqp = mp->sq[i]; diff --git a/monop/initdeck.c b/monop/initdeck.c index f1e36c4..ffdf5b0 100644 --- a/monop/initdeck.c +++ b/monop/initdeck.c @@ -1,4 +1,4 @@ -/* $NetBSD: initdeck.c,v 1.5 1997/10/12 17:45:12 christos Exp $ */ +/* $NetBSD: initdeck.c,v 1.14 2001/07/22 13:34:01 wiz Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,6 +33,7 @@ * SUCH DAMAGE. */ +#ifdef __NetBSD__ #include #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ @@ -43,48 +44,78 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ #if 0 static char sccsid[] = "@(#)initdeck.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: initdeck.c,v 1.5 1997/10/12 17:45:12 christos Exp $"); +__RCSID("$NetBSD: initdeck.c,v 1.14 2001/07/22 13:34:01 wiz Exp $"); #endif #endif /* not lint */ +#endif /* __NetBSD__ */ #include #include +#include +#include #include "deck.h" +#ifndef u_int32_t +#define u_int32_t unsigned int +#endif + +static u_int32_t +h2nl(u_int32_t h) +{ + unsigned char c[4]; + u_int32_t rv; + + c[0] = (h >> 24) & 0xff; + c[1] = (h >> 16) & 0xff; + c[2] = (h >> 8) & 0xff; + c[3] = (h >> 0) & 0xff; + memcpy(&rv, c, sizeof rv); + + return (rv); +} + /* * This program initializes the card files for monopoly. * It reads in a data file with Com. Chest cards, followed by - * the Chance card. The two are seperated by a line of "%-". - * All other cards are seperated by lines of "%%". In the front + * the Chance card. The two are separated by a line of "%-". + * All other cards are separated by lines of "%%". In the front * of the file is the data for the decks in the same order. * This includes the seek pointer for the start of each card. * All cards start with their execution code, followed by the * string to print, terminated with a null byte. */ -# define TRUE 1 -# define FALSE 0 +#define TRUE 1 +#define FALSE 0 -# define bool char -# define reg register +#define bool char -char *infile = "cards.inp", /* input file */ - *outfile = "cards.pck"; /* "packed" file */ +const char *infile = "cards.inp", /* input file */ + *outfile = "cards.pck"; /* "packed" file */ DECK deck[2]; FILE *inf, *outf; /* initdeck.c */ -int main __P((int, char *[])); -static void getargs __P((int, char *[])); -static void count __P((void)); -static void putem __P((void)); +int main(int, char *[]); +static void getargs(int, char *[]); +static void fwrite_be_offt(off_t, FILE *); +static void count(void); +static void putem(void); int main(ac, av) -int ac; -char *av[]; { + int ac; + char *av[]; +{ + int i, nc; + + /* sanity test */ + if (sizeof(int) != 4) { + fprintf(stderr, "sizeof(int) != 4\n"); + exit(1); + } getargs(ac, av); if ((inf = fopen(infile, "r")) == NULL) { @@ -95,35 +126,64 @@ char *av[]; { /* * allocate space for pointers. */ - CC_D.offsets = (long *)calloc(CC_D.num_cards + 1, sizeof (long)); - CH_D.offsets = (long *)calloc(CH_D.num_cards + 1, sizeof (long)); - fseek(inf, 0L, 0); + CC_D.offsets = calloc(CC_D.num_cards + 1, /* sizeof (off_t) */ 8); + CH_D.offsets = calloc(CH_D.num_cards + 1, /* sizeof (off_t) */ 8); + if (CC_D.offsets == NULL || CH_D.offsets == NULL) { + fprintf(stderr, "out of memory\n"); + exit(1); + } + fseek(inf, 0L, SEEK_SET); if ((outf = fopen(outfile, "w")) == NULL) { perror(outfile); - exit(0); + exit(1); } - fwrite(deck, sizeof (DECK), 2, outf); - fwrite(CC_D.offsets, sizeof (long), CC_D.num_cards, outf); - fwrite(CH_D.offsets, sizeof (long), CH_D.num_cards, outf); + /* + * these fields will be overwritten after the offsets are calculated, + * so byte-order doesn't matter yet. + */ + fwrite(&nc, sizeof(nc), 1, outf); + fwrite(&nc, sizeof(nc), 1, outf); + fwrite(CC_D.offsets, /* sizeof (off_t) */ 8, CC_D.num_cards, outf); + fwrite(CH_D.offsets, /* sizeof (off_t) */ 8, CH_D.num_cards, outf); + + /* + * write out the cards themselves (calculating the offsets). + */ putem(); fclose(inf); - fseek(outf, 0, 0L); - fwrite(deck, sizeof (DECK), 2, outf); - fwrite(CC_D.offsets, sizeof (long), CC_D.num_cards, outf); - fwrite(CH_D.offsets, sizeof (long), CH_D.num_cards, outf); + fseek(outf, 0, SEEK_SET); + + /* number of community chest cards first... */ + nc = h2nl(CC_D.num_cards); + fwrite(&nc, sizeof(nc), 1, outf); + /* ... then number of chance cards. */ + nc = h2nl(CH_D.num_cards); + fwrite(&nc, sizeof(nc), 1, outf); + + /* dump offsets in big-endian byte order */ + for (i = 0; i < CC_D.num_cards; i++) + fwrite_be_offt(CC_D.offsets[i], outf); + for (i = 0; i < CH_D.num_cards; i++) + fwrite_be_offt(CH_D.offsets[i], outf); + + fflush(outf); + if (ferror(outf)) { + perror(outfile); + exit(1); + } fclose(outf); - printf("There were %d com. chest and %d chance cards\n", CC_D.num_cards, CH_D.num_cards); + printf("There were %d com. chest and %d chance cards\n", + CC_D.num_cards, CH_D.num_cards); exit(0); } static void getargs(ac, av) -int ac; -char *av[]; + int ac; + char *av[]; { - if (ac > 1) infile = av[1]; if (ac > 2) @@ -136,10 +196,9 @@ char *av[]; static void count() { - - reg bool newline; - reg DECK *in_deck; - reg int c; + bool newline; + DECK *in_deck; + int c; newline = TRUE; in_deck = &CC_D; @@ -154,17 +213,17 @@ count() newline = (c == '\n'); in_deck->num_cards++; } + /* * put strings in the file */ static void putem() { - - reg bool newline; - reg DECK *in_deck; - reg int c; - reg int num; + bool newline; + DECK *in_deck; + int c; + int num; in_deck = &CC_D; CC_D.num_cards = 1; @@ -174,7 +233,7 @@ putem() putc(getc(inf), outf); for (num = 0; (c=getc(inf)) != '\n'; ) num = num * 10 + (c - '0'); - putw(num, outf); + putw(h2nl(num), outf); newline = FALSE; while ((c=getc(inf)) != EOF) if (newline && c == '%') { @@ -191,7 +250,7 @@ putem() putc(c = getc(inf), outf); for (num = 0; (c=getc(inf)) != EOF && c != '\n'; ) num = num * 10 + (c - '0'); - putw(num, outf); + putw(h2nl(num), outf); } else { putc(c, outf); @@ -199,3 +258,23 @@ putem() } putc('\0', outf); } + +/* + * fwrite_be_offt: + * Write out the off paramater as a 64 bit big endian number + */ + +static void +fwrite_be_offt(off, f) + off_t off; + FILE *f; +{ + int i; + unsigned char c[8]; + + for (i = 7; i >= 0; i--) { + c[i] = off & 0xff; + off >>= 8; + } + fwrite(c, sizeof(c), 1, f); +} diff --git a/monop/jail.c b/monop/jail.c index 8c03e9b..8aa5360 100644 --- a/monop/jail.c +++ b/monop/jail.c @@ -1,4 +1,4 @@ -/* $NetBSD: jail.c,v 1.4 1997/10/12 17:45:14 christos Exp $ */ +/* $NetBSD: jail.c,v 1.5 1999/08/21 10:40:03 simonb Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)jail.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: jail.c,v 1.4 1997/10/12 17:45:14 christos Exp $"); +__RCSID("$NetBSD: jail.c,v 1.5 1999/08/21 10:40:03 simonb Exp $"); #endif #endif /* not lint */ @@ -51,7 +51,6 @@ __RCSID("$NetBSD: jail.c,v 1.4 1997/10/12 17:45:14 christos Exp $"); void card() { - if (cur_p->loc != JAIL) { printf("But you're not IN Jail\n"); return; @@ -64,28 +63,28 @@ card() cur_p->loc = 10; /* just visiting */ cur_p->in_jail = 0; } + /* * This routine returns the players get-out-of-jail-free card * to a deck. */ void ret_card(plr) -PLAY *plr; + PLAY *plr; { - plr->num_gojf--; if (CC_D.gojf_used) CC_D.gojf_used = FALSE; else CH_D.gojf_used = FALSE; } + /* * This routine deals with paying your way out of jail. */ void pay() { - if (cur_p->loc != JAIL) { printf("But you're not IN Jail\n"); return; @@ -95,18 +94,19 @@ pay() cur_p->in_jail = 0; printf("That cost you $50\n"); } + /* * This routine deals with a move in jail */ int move_jail(r1, r2) -int r1, r2; + int r1, r2; { - if (r1 != r2) { printf("Sorry, that doesn't get you out\n"); if (++(cur_p->in_jail) == 3) { - printf("It's your third turn and you didn't roll doubles. You have to pay $50\n"); + printf("It's your third turn and you didn't roll " + "doubles. You have to pay $50\n"); cur_p->money -= 50; moveit: cur_p->loc = 10; @@ -126,7 +126,6 @@ moveit: void printturn() { - if (cur_p->loc != JAIL) return; printf("(This is your "); diff --git a/monop/misc.c b/monop/misc.c index 9c68520..f06ae32 100644 --- a/monop/misc.c +++ b/monop/misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: misc.c,v 1.6 1997/10/12 17:45:15 christos Exp $ */ +/* $NetBSD: misc.c,v 1.10 2001/01/16 02:41:17 cgd Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,13 +38,13 @@ #if 0 static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: misc.c,v 1.6 1997/10/12 17:45:15 christos Exp $"); +__RCSID("$NetBSD: misc.c,v 1.10 2001/01/16 02:41:17 cgd Exp $"); #endif #endif /* not lint */ -# include "monop.ext" -# include -# include +#include "monop.ext" +#include +#include /* * This routine executes a truncated set of commands until a @@ -52,10 +52,9 @@ __RCSID("$NetBSD: misc.c,v 1.6 1997/10/12 17:45:15 christos Exp $"); */ int getyn(prompt) -char *prompt; + const char *prompt; { - - int com; + int com; for (;;) if ((com=getinp(prompt, yn)) < 2) @@ -63,13 +62,13 @@ char *prompt; else (*func[com-2])(); } + /* * This routine tells the player if he's out of money. */ void notify() { - if (cur_p->money < 0) printf("That leaves you $%d in debt\n", -cur_p->money); else if (cur_p->money == 0) @@ -79,30 +78,30 @@ notify() told_em = TRUE; } } + /* * This routine switches to the next player */ void next_play() { - - player = ++player % num_play; + player = (player + 1) % num_play; cur_p = &play[player]; num_doub = 0; } + /* * This routine gets an integer from the keyboard after the * given prompt. */ int get_int(prompt) -char *prompt; + const char *prompt; { - - int num; - char *sp; - int c; - char buf[257]; + int num; + char *sp; + int c; + char buf[257]; for (;;) { inter: @@ -124,18 +123,18 @@ inter: printf("I can't understand that\n"); } } + /* * This routine sets the monopoly flag from the list given. */ void set_ownlist(pl) -int pl; + int pl; { - - int num; /* general counter */ - MON *orig; /* remember starting monop ptr */ - OWN *op; /* current owned prop */ - OWN *orig_op; /* origianl prop before loop */ + int num; /* general counter */ + MON *orig; /* remember starting monop ptr */ + OWN *op; /* current owned prop */ + OWN *orig_op; /* origianl prop before loop */ op = play[pl].own_list; #ifdef DEBUG @@ -150,7 +149,8 @@ int pl; #ifdef DEBUG printf(" case UTIL:\n"); #endif - for (num = 0; op && op->sqr->type == UTIL; op = op->next) + for (num = 0; op && op->sqr->type == UTIL; + op = op->next) num++; play[pl].num_util = num; #ifdef DEBUG @@ -161,10 +161,13 @@ int pl; #ifdef DEBUG printf(" case RR:\n"); #endif - for (num = 0; op && op->sqr->type == RR; op = op->next) { + for (num = 0; op && op->sqr->type == RR; + op = op->next) { #ifdef DEBUG printf("iter: %d\n", num); - printf("op = %d, op->sqr = %d, op->sqr->type = %d\n", op, op->sqr, op->sqr->type); + printf("op = %d, op->sqr = %d, " + "op->sqr->type = %d\n", op, op->sqr, + op->sqr->type); #endif num++; } @@ -197,15 +200,19 @@ int pl; printf("num = %d\n"); #endif if (orig == 0) { - printf("panic: bad monopoly descriptor: orig = %p\n", orig); + printf("panic: bad monopoly descriptor: " + "orig = %p\n", orig); printf("player # %d\n", pl+1); printhold(pl); printf("orig_op = %p\n", orig_op); - printf("orig_op->sqr->type = %d (PRPTY)\n", op->sqr->type); + printf("orig_op->sqr->type = %d (PRPTY)\n", + op->sqr->type); printf("orig_op->next = %p\n", op->next); - printf("orig_op->sqr->desc = %p\n", op->sqr->desc); + printf("orig_op->sqr->desc = %p\n", + op->sqr->desc); printf("op = %p\n", op); - printf("op->sqr->type = %d (PRPTY)\n", op->sqr->type); + printf("op->sqr->type = %d (PRPTY)\n", + op->sqr->type); printf("op->next = %p\n", op->next); printf("op->sqr->desc = %p\n", op->sqr->desc); printf("num = %d\n", num); @@ -221,16 +228,16 @@ int pl; } } } + /* * This routine sets things up as if it is a new monopoly */ void is_monop(mp, pl) -MON *mp; -int pl; + MON *mp; + int pl; { - - int i; + int i; mp->owner = pl; mp->num_own = mp->num_in; @@ -238,49 +245,50 @@ int pl; mp->sq[i]->desc->monop = TRUE; mp->name = mp->mon_n; } + /* * This routine sets things up as if it is no longer a monopoly */ void is_not_monop(mp) -MON *mp; + MON *mp; { - - int i; + int i; mp->owner = -1; for (i = 0; i < mp->num_in; i++) mp->sq[i]->desc->monop = FALSE; mp->name = mp->not_m; } + /* * This routine gives a list of the current player's routine */ void -list() +list() { - printhold(player); } + /* * This routine gives a list of a given players holdings */ void -list_all() +list_all() { + int pl; - int pl; - - while ((pl=getinp("Whose holdings do you want to see? ", name_list)) < num_play) + while ((pl = getinp("Whose holdings do you want to see? ", name_list)) + < num_play) printhold(pl); } + /* * This routine gives the players a chance before it exits. */ void quit() { - putchar('\n'); if (getyn("Do you all really want to quit? ") == 0) exit(0); diff --git a/monop/monop.6.in b/monop/monop.6.in index 07e5262..d44b542 100644 --- a/monop/monop.6.in +++ b/monop/monop.6.in @@ -1,4 +1,4 @@ -.\" $NetBSD: monop.6,v 1.8 1995/03/23 08:34:50 cgd Exp $ +.\" $NetBSD: monop.6,v 1.13 2002/09/26 18:32:03 wiz Exp $ .\" .\" Copyright (c) 1980 The Regents of the University of California. .\" All rights reserved. @@ -40,10 +40,10 @@ .Nm monop .Nd Monopoly game .Sh SYNOPSIS -.Nm @gamesdir@/monop +.Nm .Op Ar file .Sh DESCRIPTION -.Nm Monop +.Nm is reminiscent of the Parker Brother's game Monopoly, and monitors a game between 1 to 9 users. It is assumed that the rules of Monopoly are known. @@ -53,8 +53,7 @@ no auction is held and the property remains unowned. .Nm The game, in effect, lends the player money, so it is possible to buy something which you cannot afford. -However, as soon as a person goes into debt, -he must +However, as soon as a person goes into debt, he must .Dq fix the problem , .Em i.e. , make himself solvent, before play can continue. @@ -65,7 +64,7 @@ which puts the property back on the board, unowned. .Pp Any time that the response to a question is a .Em string , -e.g., a name, place or person, you can type +e.g., a name, place or person, you can type .Sq Ic ? to get a list of valid answers. It is not possible to input a negative number, nor is it ever necessary. @@ -73,7 +72,8 @@ It is not possible to input a negative number, nor is it ever necessary. .Em A Summary of Commands : .Bl -tag -width item .It Ic quit -quit game: This allows you to quit the game. It asks you if you're sure. +quit game: This allows you to quit the game. +It asks you if you're sure. .It Ic print print board: This prints out the current board. The columns have the following meanings (column headings are the same for the @@ -87,13 +87,13 @@ commands): .It Name The first ten characters of the name of the square .It Own -The +The .Em number of the owner of the property. .It Price The cost of the property (if any) .It Mg -This field has a +This field has a .Sq * in it if the property is mortgaged .It \&# @@ -101,11 +101,14 @@ If the property is a Utility or Railroad, this is the number of such owned by the owner. If the property is land, this is the number of houses on it. .It Rent -Current rent on the property. If it is not owned, there is no rent. +Current rent on the property. +If it is not owned, there is no rent. .El .It Ic where where players are: Tells you where all the players are. -A `*' indicates the current player. +A +.Sq * +indicates the current player. .It Ic own holdings List your own holdings, .Em i.e. , @@ -113,7 +116,7 @@ money, get-out-of-jail-free cards, and property. .It Ic holdings holdings list: Look at anyone's holdings. It will ask you whose holdings you wish to look at. -When you are finished, type +When you are finished, type .Sq Ic done . .It Ic mortgage mortgage property: @@ -134,7 +137,7 @@ it asks you to re-input things. sell houses: Sets up a list of monopolies from which you can sell houses. It operates in an analogous manner to -.Ic buy. +.Ic buy . .It Ic card card for jail: Use a get-out-of-jail-free card to get out of jail. @@ -158,7 +161,7 @@ save game: Save the current game in a file for later play. You can continue play after saving, either by adding the file in which you saved the game after the -.Nm monop +.Nm command, or by using the .Ic restore command (see below). @@ -169,13 +172,14 @@ restore game: Read in a previously saved game from a file. It leaves the file intact. .It Ic roll -Roll the dice and move forward to your new location. -If you simply hit the key instead of a command, -it is the same as typing +Roll the dice and move forward to your new location. +If you simply hit the +.Aq RETURN +key instead of a command, it is the same as typing .Ic roll . .El .Sh AUTHOR -Ken Arnold +.An Ken Arnold .Sh FILES .Bl -tag -width @monop_cardsfile@ -compact .It Pa @monop_cardsfile@ diff --git a/monop/monop.c b/monop/monop.c index 64e8e1e..c1cfa21 100644 --- a/monop/monop.c +++ b/monop/monop.c @@ -1,4 +1,4 @@ -/* $NetBSD: monop.c,v 1.5 1998/09/11 13:54:08 hubertf Exp $ */ +/* $NetBSD: monop.c,v 1.12 2001/09/18 18:15:49 wiz Exp $ */ /* * Copyright (c) 1980, 1993 @@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ #if 0 static char sccsid[] = "@(#)monop.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: monop.c,v 1.5 1998/09/11 13:54:08 hubertf Exp $"); +__RCSID("$NetBSD: monop.c,v 1.12 2001/09/18 18:15:49 wiz Exp $"); #endif #endif /* not lint */ @@ -64,9 +64,9 @@ static void do_quit __P((int)); */ int main(ac, av) -int ac; -char *av[]; { - + int ac; + char *av[]; +{ /* Revoke setgid privileges */ setregid(getgid(), getgid()); @@ -95,20 +95,20 @@ char *av[]; { /*ARGSUSED*/ static void do_quit(n) - int n __attribute__((unused)); + int n __attribute__((__unused__)); { quit(); } + /* * This routine gets the names of the players */ static void getplayers() { - - char *sp; - int i, j; - char buf[257]; + char *sp; + int i, j; + char buf[257]; blew_it: for (;;) { @@ -119,6 +119,8 @@ blew_it: break; } cur_p = play = (PLAY *) calloc(num_play, sizeof (PLAY)); + if (play == NULL) + err(1, NULL); for (i = 0; i < num_play; i++) { over: printf("Player %d's name: ", i + 1); @@ -127,7 +129,10 @@ over: if (sp == buf) goto over; *sp++ = '\0'; - strcpy(name_list[i]=play[i].name=(char *)calloc(1,sp-buf),buf); + name_list[i] = play[i].name = (char *)calloc(1, sp - buf); + if (name_list[i] == NULL) + err(1, NULL); + strcpy(play[i].name, buf); play[i].money = 1500; } name_list[i++] = "done"; @@ -136,25 +141,28 @@ over: for (j = i + 1; j < num_play; j++) if (strcasecmp(name_list[i], name_list[j]) == 0) { if (i != num_play - 1) - printf("Hey!!! Some of those are IDENTICAL!! Let's try that again....\n"); + printf("Hey!!! Some of those are " + "IDENTICAL!! Let's try that " + "again....\n"); else - printf("\"done\" is a reserved word. Please try again\n"); + printf("\"done\" is a reserved word. " + "Please try again\n"); for (i = 0; i < num_play; i++) free(play[i].name); free(play); goto blew_it; } } + /* * This routine figures out who goes first */ static void init_players() { - - int i, rl, cur_max; - bool over = 0; - int max_pl = 0; + int i, rl, cur_max; + bool over = 0; + int max_pl = 0; again: putchar('\n'); @@ -177,15 +185,15 @@ again: cur_p = &play[max_pl]; printf("%s (%d) goes first\n", cur_p->name, max_pl + 1); } + /* - * This routine initalizes the monopoly structures. + * This routine initializes the monopoly structures. */ static void init_monops() { - - MON *mp; - int i; + MON *mp; + int i; for (mp = mon; mp < &mon[N_MON]; mp++) { mp->name = mp->not_m; diff --git a/monop/monop.def b/monop/monop.def index 54ecd6c..4bca637 100644 --- a/monop/monop.def +++ b/monop/monop.def @@ -1,4 +1,4 @@ -/* $NetBSD: monop.def,v 1.4 1997/10/12 17:45:18 christos Exp $ */ +/* $NetBSD: monop.def,v 1.6 1999/09/08 21:17:52 jsm Exp $ */ /*- * Copyright (c) 1980, 1993 @@ -35,16 +35,16 @@ * @(#)monop.def 5.5 (Berkeley) 5/31/93 */ -# include "deck.h" -# include "monop.h" +#include "deck.h" +#include "monop.h" bool fixing, /* set if fixing up debt */ trading, /* set if in process of trading */ told_em, /* set if told user he's out of debt */ spec; /* set if moving by card to RR or UTIL */ -char *name_list[MAX_PL+2], /* list of players' names */ - *comlist[] = { /* list of normal commands */ +const char *name_list[MAX_PL+2], /* list of players' names */ + *const comlist[] = { /* list of normal commands */ "quit", /* 0 */ "print", /* 1 */ "where", /* 2 */ "own holdings", /* 3 */ "holdings", /* 4 */ "mortgage", /* 5 */ @@ -56,14 +56,14 @@ char *name_list[MAX_PL+2], /* list of players' names */ "", /* 16 */ 0 }, - *yn[] = { /* list of commands for yes/no answers */ + *const yn[] = { /* list of commands for yes/no answers */ "yes", /* 0 */ "no", /* 1 */ "quit", /* 2 */ "print", /* 3 */ "where", /* 4 */ "own holdings", /* 5 */ "holdings", /* 6 */ 0 }, - *lucky_mes[] = { /* "got lucky" messages */ + *const lucky_mes[] = { /* "got lucky" messages */ "You lucky stiff", "You got lucky", "What a lucky person!", "You must have a 4-leaf clover", "My, my! Aren't we lucky!", "Luck smiles upon you", @@ -80,7 +80,7 @@ int player, /* current player number */ num_luck = sizeof lucky_mes / sizeof (char *); /* list of command functions */ -void (*func[]) __P((void)) = { /* array of function calls for commands */ +void (*const func[]) __P((void)) = { /* array of function calls for commands */ quit, /* quit game |* 0 *| */ printboard, /* print board |* 1 *| */ where, /* where players are |* 2 *| */ diff --git a/monop/monop.ext b/monop/monop.ext index a83fee4..5903f3d 100644 --- a/monop/monop.ext +++ b/monop/monop.ext @@ -1,4 +1,4 @@ -/* $NetBSD: monop.ext,v 1.3 1997/10/12 17:45:19 christos Exp $ */ +/* $NetBSD: monop.ext,v 1.4 1999/09/08 21:17:52 jsm Exp $ */ /*- * Copyright (c) 1980, 1993 @@ -40,11 +40,11 @@ extern bool trading, spec, fixing, told_em; -extern char *yn[], *comlist[], *name_list[], *lucky_mes[]; +extern const char *const yn[], *const comlist[], *name_list[], *const lucky_mes[]; extern int num_play, player, num_doub, num_luck; -extern void (*func[]) __P((void)); +extern void (*const func[]) __P((void)); extern DECK deck[2]; diff --git a/monop/monop.h b/monop/monop.h index 2cba53c..23896e7 100644 --- a/monop/monop.h +++ b/monop/monop.h @@ -1,4 +1,4 @@ -/* $NetBSD: monop.h,v 1.6 1997/10/12 17:45:20 christos Exp $ */ +/* $NetBSD: monop.h,v 1.10 1999/09/30 18:01:32 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -35,48 +35,49 @@ * @(#)monop.h 8.1 (Berkeley) 5/31/93 */ -# include -# include -# include +#include +#include +#include +#include -# define bool char +#define bool char -# define TRUE (1) -# define FALSE (0) +#define TRUE (1) +#define FALSE (0) -# define N_MON 8 /* number of monopolies */ -# define N_PROP 22 /* number of normal property squares */ -# define N_RR 4 /* number of railroads */ -# define N_UTIL 2 /* number of utilities */ -# define N_SQRS 40 /* number of squares on board */ -# define MAX_PL 9 /* maximum number of players */ -# define MAX_PRP (N_PROP+N_RR+N_UTIL) /* max # ownable property */ +#define N_MON 8 /* number of monopolies */ +#define N_PROP 22 /* number of normal property squares */ +#define N_RR 4 /* number of railroads */ +#define N_UTIL 2 /* number of utilities */ +#define N_SQRS 40 /* number of squares on board */ +#define MAX_PL 9 /* maximum number of players */ +#define MAX_PRP (N_PROP+N_RR+N_UTIL) /* max # ownable property */ /* square type numbers */ -# define PRPTY 0 /* normal property */ -# define RR 1 /* railroad */ -# define UTIL 2 /* water works - electric co */ -# define SAFE 3 /* safe spot */ -# define CC 4 /* community chest */ -# define CHANCE 5 /* chance (surprise!!!) */ -# define INC_TAX 6 /* Income tax */ -# define GOTO_J 7 /* Go To Jail! */ -# define LUX_TAX 8 /* Luxury tax */ -# define IN_JAIL 9 /* In jail */ +#define PRPTY 0 /* normal property */ +#define RR 1 /* railroad */ +#define UTIL 2 /* water works - electric co */ +#define SAFE 3 /* safe spot */ +#define CC 4 /* community chest */ +#define CHANCE 5 /* chance (surprise!!!) */ +#define INC_TAX 6 /* Income tax */ +#define GOTO_J 7 /* Go To Jail! */ +#define LUX_TAX 8 /* Luxury tax */ +#define IN_JAIL 9 /* In jail */ -# define JAIL 40 /* JAIL square number */ +#define JAIL 40 /* JAIL square number */ -# define lucky(str) printf("%s%s\n",str,lucky_mes[roll(1,num_luck)-1]) -# define printline() printf("------------------------------\n") -# define sqnum(sqp) (sqp - board) -# define swap(A1,A2) if ((A1) != (A2)) { \ +#define lucky(str) printf("%s%s\n",str,lucky_mes[roll(1,num_luck)-1]) +#define printline() printf("------------------------------\n") +#define sqnum(sqp) (sqp - board) +#define swap(A1,A2) if ((A1) != (A2)) { \ (A1) ^= (A2); \ (A2) ^= (A1); \ (A1) ^= (A2); \ } struct sqr_st { /* structure for square */ - char *name; /* place name */ + const char *name; /* place name */ short owner; /* owner number */ short type; /* place type */ struct prp_st *desc; /* description struct */ @@ -86,13 +87,13 @@ struct sqr_st { /* structure for square */ typedef struct sqr_st SQUARE; struct mon_st { /* monopoly description structure */ - char *name; /* monop. name (color) */ + const char *name; /* monop. name (color) */ short owner; /* owner of monopoly */ short num_in; /* # in monopoly */ short num_own; /* # owned (-1: not poss. monop)*/ short h_cost; /* price of houses */ - char *not_m; /* name if not monopoly */ - char *mon_n; /* name if a monopoly */ + const char *not_m; /* name if not monopoly */ + const char *mon_n; /* name if a monopoly */ unsigned char sqnums[3]; /* Square numbers (used to init)*/ SQUARE *sq[3]; /* list of squares in monop */ }; @@ -146,10 +147,10 @@ void do_move __P((void)); void move __P((int)); void save __P((void)); void restore __P((void)); -int rest_f __P((char *)); +int rest_f __P((const char *)); /* getinp.c */ -int getinp __P((char *, char *[])); +int getinp __P((const char *, const char *const [])); /* houses.c */ void buy_houses __P((void)); @@ -163,10 +164,10 @@ int move_jail __P((int, int )); void printturn __P((void)); /* misc.c */ -int getyn __P((char *)); +int getyn __P((const char *)); void notify __P((void)); void next_play __P((void)); -int get_int __P((char *)); +int get_int __P((const char *)); void set_ownlist __P((int)); void is_monop __P((MON *, int)); void is_not_monop __P((MON *)); diff --git a/monop/morg.c b/monop/morg.c index e7f37f3..2c74f91 100644 --- a/monop/morg.c +++ b/monop/morg.c @@ -1,4 +1,4 @@ -/* $NetBSD: morg.c,v 1.6 1998/08/30 09:19:39 veego Exp $ */ +/* $NetBSD: morg.c,v 1.8 1999/09/08 21:17:52 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,18 +38,18 @@ #if 0 static char sccsid[] = "@(#)morg.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: morg.c,v 1.6 1998/08/30 09:19:39 veego Exp $"); +__RCSID("$NetBSD: morg.c,v 1.8 1999/09/08 21:17:52 jsm Exp $"); #endif #endif /* not lint */ -# include "monop.ext" +#include "monop.ext" /* * These routines deal with mortgaging. */ -static char *names[MAX_PRP+2], - *morg_coms[] = { +static const char *names[MAX_PRP+2], + *const morg_coms[] = { "quit", /* 0 */ "print", /* 1 */ "where", /* 2 */ @@ -87,19 +87,21 @@ static void fix_ex __P((int)); void mortgage() { - - int prop; + int prop; for (;;) { if (set_mlist() == 0) { if (got_houses) - printf("You can't mortgage property with houses on it.\n"); + printf("You can't mortgage property with " + "houses on it.\n"); else - printf("You don't have any un-mortgaged property.\n"); + printf("You don't have any un-mortgaged " + "property.\n"); return; } if (num_good == 1) { - printf("Your only mortageable property is %s\n",names[0]); + printf("Your only mortageable property is %s\n", + names[0]); if (getyn("Do you want to mortgage it? ") == 0) m(square[0]); return; @@ -111,14 +113,14 @@ mortgage() notify(); } } + /* * This routine sets up the list of mortgageable property */ static int set_mlist() { - - OWN *op; + OWN *op; num_good = 0; for (op = cur_p->own_list; op; op = op->next) @@ -134,21 +136,22 @@ set_mlist() names[num_good--] = 0; return num_good; } + /* * This routine actually mortgages the property. */ static void m(prop) -int prop; + int prop; { - - int price; + int price; price = board[prop].cost/2; board[prop].desc->morg = TRUE; printf("That got you $%d\n",price); cur_p->money += price; } + /* * This routine is the command level repsponse to the unmortgage * command. It gets the list of mortgaged property and asks which are @@ -157,8 +160,7 @@ int prop; void unmortgage() { - - int prop; + int prop; for (;;) { if (set_umlist() == 0) { @@ -171,20 +173,21 @@ unmortgage() unm(square[0]); return; } - prop = getinp("Which property do you want to unmortgage? ",names); + prop = getinp("Which property do you want to unmortgage? ", + names); if (prop == num_good) return; unm(square[prop]); } } + /* * This routine sets up the list of mortgaged property */ static int set_umlist() { - - OWN *op; + OWN *op; num_good = 0; for (op = cur_p->own_list; op; op = op->next) @@ -196,15 +199,15 @@ set_umlist() names[num_good--] = 0; return num_good; } + /* * This routine actually unmortgages the property */ static void unm(prop) -int prop; + int prop; { - - int price; + int price; price = board[prop].cost/2; board[prop].desc->morg = FALSE; @@ -213,6 +216,7 @@ int prop; cur_p->money -= price; set_umlist(); } + /* * This routine forces the indebted player to fix his * financial woes. @@ -220,20 +224,19 @@ int prop; void force_morg() { - told_em = fixing = TRUE; while (cur_p->money <= 0) fix_ex(getinp("How are you going to fix it up? ",morg_coms)); fixing = FALSE; } + /* * This routine is a special execute for the force_morg routine */ static void fix_ex(com_num) -int com_num; + int com_num; { - told_em = FALSE; (*func[com_num])(); notify(); diff --git a/monop/print.c b/monop/print.c index 0b921d7..5f0dcd2 100644 --- a/monop/print.c +++ b/monop/print.c @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.4 1997/10/12 17:45:22 christos Exp $ */ +/* $NetBSD: print.c,v 1.6 1999/09/08 21:17:52 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,15 +38,15 @@ #if 0 static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: print.c,v 1.4 1997/10/12 17:45:22 christos Exp $"); +__RCSID("$NetBSD: print.c,v 1.6 1999/09/08 21:17:52 jsm Exp $"); #endif #endif /* not lint */ -# include "monop.ext" +#include "monop.ext" -static char *header = "Name Own Price Mg # Rent"; +static const char *header = "Name Own Price Mg # Rent"; -static void printmorg __P((SQUARE *)); +static void printmorg __P((const SQUARE *)); /* * This routine prints out the current board @@ -54,8 +54,7 @@ static void printmorg __P((SQUARE *)); void printboard() { - - int i; + int i; printf("%s\t%s\n", header, header); for (i = 0; i < N_SQRS/2; i++) { @@ -64,14 +63,14 @@ printboard() printsq(i+N_SQRS/2, TRUE); } } + /* * This routine lists where each player is. */ void where() { - - int i; + int i; printf("%s Player\n", header); for (i = 0; i < num_play; i++) { @@ -82,18 +81,18 @@ where() putchar('\n'); } } + /* * This routine prints out an individual square */ void printsq(sqn, eoln) -int sqn; -bool eoln; + int sqn; + bool eoln; { - - int rnt; - PROP *pp; - SQUARE *sqp; + int rnt; + PROP *pp; + SQUARE *sqp; sqp = &board[sqn]; printf("%-10.10s", sqp->name); @@ -156,39 +155,40 @@ bool eoln; printmorg(sqp); rnt = 25; rnt <<= play[sqp->owner].num_rr - 1; - printf("%d %4d", play[sqp->owner].num_rr, 25 << (play[sqp->owner].num_rr - 1)); + printf("%d %4d", play[sqp->owner].num_rr, + 25 << (play[sqp->owner].num_rr - 1)); break; } if (eoln) putchar('\n'); } + /* * This routine prints out the mortgage flag. */ static void printmorg(sqp) -SQUARE *sqp; + const SQUARE *sqp; { - if (sqp->desc->morg) printf(" * "); else printf(" "); } + /* * This routine lists the holdings of the player given */ void printhold(pl) -int pl; + int pl; { - - OWN *op; - PLAY *pp; + OWN *op; + PLAY *pp; pp = &play[pl]; - printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl], pl+1, - pp->money + prop_worth(pp)); + printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl], + pl + 1, pp->money + prop_worth(pp)); printf("\t$%d", pp->money); if (pp->num_gojf) { printf(", %d get-out-of-jail-free card", pp->num_gojf); diff --git a/monop/prop.c b/monop/prop.c index cf85318..c1a016f 100644 --- a/monop/prop.c +++ b/monop/prop.c @@ -1,4 +1,4 @@ -/* $NetBSD: prop.c,v 1.4 1997/10/12 17:45:23 christos Exp $ */ +/* $NetBSD: prop.c,v 1.7 2001/01/16 02:41:17 cgd Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)prop.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: prop.c,v 1.4 1997/10/12 17:45:23 christos Exp $"); +__RCSID("$NetBSD: prop.c,v 1.7 2001/01/16 02:41:17 cgd Exp $"); #endif #endif /* not lint */ @@ -53,29 +53,30 @@ static int value __P((SQUARE *)); */ void buy(player, sqrp) -int player; -SQUARE *sqrp; + int player; + SQUARE *sqrp; { - trading = FALSE; sqrp->owner = player; add_list(player, &(play[player].own_list), cur_p->loc); } + /* * This routine adds an item to the list. */ void add_list(plr, head, op_sqr) -int plr; -OWN **head; -int op_sqr; + int plr; + OWN **head; + int op_sqr; { - - int val; - OWN *tp, *last_tp; - OWN *op; + int val; + OWN *tp, *last_tp; + OWN *op; op = (OWN *)calloc(1, sizeof (OWN)); + if (op == NULL) + errx(1, "out of memory"); op->sqr = &board[op_sqr]; val = value(op->sqr); last_tp = NULL; @@ -94,17 +95,17 @@ int op_sqr; if (!trading) set_ownlist(plr); } + /* * This routine deletes property from the list. */ void del_list(plr, head, op_sqr) -int plr; -OWN **head; -short op_sqr; + int plr; + OWN **head; + short op_sqr; { - - OWN *op, *last_op; + OWN *op, *last_op; switch (board[op_sqr].type) { case PRPTY: @@ -130,16 +131,16 @@ short op_sqr; free(op); } } + /* * This routine calculates the value for sorting of the * given square. */ static int value(sqp) -SQUARE *sqp; + SQUARE *sqp; { - - int sqr; + int sqr; sqr = sqnum(sqp); switch (sqp->type) { @@ -158,6 +159,7 @@ SQUARE *sqp; return 8 + (sqp->desc) - prop; } } + /* * This routine accepts bids for the current peice * of property. @@ -165,11 +167,10 @@ SQUARE *sqp; void bid() { - - static bool in[MAX_PL]; - int i, num_in, cur_max; - char buf[80]; - int cur_bid; + static bool in[MAX_PL]; + int i, num_in, cur_max; + char buf[80]; + int cur_bid; printf("\nSo it goes up for auction. Type your bid after your name\n"); for (i = 0; i < num_play; i++) @@ -178,7 +179,7 @@ bid() cur_max = 0; num_in = num_play; while (num_in > 1 || (cur_max == 0 && num_in > 0)) { - i = ++i % num_play; + i = (i + 1) % num_play; if (in[i]) { do { (void)sprintf(buf, "%s: ", name_list[i]); @@ -189,7 +190,8 @@ bid() break; } else if (cur_bid <= cur_max) { - printf("You must bid higher than %d to stay in\n", cur_max); + printf("You must bid higher than %d " + "to stay in\n", cur_max); printf("(bid of 0 drops you out)\n"); } } while (cur_bid != 0 && cur_bid <= cur_max); @@ -198,25 +200,26 @@ bid() } if (cur_max != 0) { while (!in[i]) - i = ++i % num_play; + i = (i + 1) % num_play; printf("It goes to %s (%d) for $%d\n",play[i].name,i+1,cur_max); buy(i, &board[cur_p->loc]); play[i].money -= cur_max; } else - printf("Nobody seems to want it, so we'll leave it for later\n"); + printf("Nobody seems to want it, so we'll leave it for " + "later\n"); } + /* * This routine calculates the value of the property * of given player. */ int prop_worth(plp) -PLAY *plp; + PLAY *plp; { - - OWN *op; - int worth; + OWN *op; + int worth; worth = 0; for (op = plp->own_list; op; op = op->next) { diff --git a/monop/rent.c b/monop/rent.c index 0269d17..c7b0cc9 100644 --- a/monop/rent.c +++ b/monop/rent.c @@ -1,4 +1,4 @@ -/* $NetBSD: rent.c,v 1.4 1997/10/12 17:45:24 christos Exp $ */ +/* $NetBSD: rent.c,v 1.5 1999/08/21 10:40:04 simonb Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,23 +38,22 @@ #if 0 static char sccsid[] = "@(#)rent.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: rent.c,v 1.4 1997/10/12 17:45:24 christos Exp $"); +__RCSID("$NetBSD: rent.c,v 1.5 1999/08/21 10:40:04 simonb Exp $"); #endif #endif /* not lint */ -#include "monop.ext" +#include "monop.ext" /* * This routine has the player pay rent */ void rent(sqp) -SQUARE *sqp; + SQUARE *sqp; { - - int rnt = 0; - PROP *pp; - PLAY *plp; + int rnt = 0; + PROP *pp; + PLAY *plp; plp = &play[sqp->owner]; printf("Owned by %s\n", plp->name); diff --git a/monop/roll.c b/monop/roll.c index a0e9e1c..75578ee 100644 --- a/monop/roll.c +++ b/monop/roll.c @@ -1,4 +1,4 @@ -/* $NetBSD: roll.c,v 1.6 1997/10/12 17:45:25 christos Exp $ */ +/* $NetBSD: roll.c,v 1.8 2002/06/02 22:17:37 wiz Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)roll.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: roll.c,v 1.6 1997/10/12 17:45:25 christos Exp $"); +__RCSID("$NetBSD: roll.c,v 1.8 2002/06/02 22:17:37 wiz Exp $"); #endif #endif /* not lint */ @@ -49,18 +49,15 @@ __RCSID("$NetBSD: roll.c,v 1.6 1997/10/12 17:45:25 christos Exp $"); * This routine rolls ndie nside-sided dice. */ -# define reg register - -# if defined(pdp11) -# define MAXRAND 32767L +#if defined(pdp11) +#define MAXRAND 32767L int roll(ndie, nsides) -int ndie, nsides; + int ndie, nsides; { - - long tot; - unsigned n, r; + long tot; + unsigned n, r; tot = 0; n = ndie; @@ -69,14 +66,14 @@ int ndie, nsides; return (int) ((tot * (long) nsides) / ((long) MAXRAND + 1)) + ndie; } -# else +#else int roll(ndie, nsides) -int ndie, nsides; { - - int tot, r; - double num_sides; + int ndie, nsides; +{ + int tot, r; + double num_sides; num_sides = nsides; tot = 0; @@ -84,4 +81,4 @@ int ndie, nsides; { tot += (r = rand()) * (num_sides / RAND_MAX) + 1; return tot; } -# endif +#endif diff --git a/monop/spec.c b/monop/spec.c index b5f6839..702faaa 100644 --- a/monop/spec.c +++ b/monop/spec.c @@ -1,4 +1,4 @@ -/* $NetBSD: spec.c,v 1.4 1997/10/12 17:45:26 christos Exp $ */ +/* $NetBSD: spec.c,v 1.6 1999/09/08 21:17:52 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,23 +38,23 @@ #if 0 static char sccsid[] = "@(#)spec.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: spec.c,v 1.4 1997/10/12 17:45:26 christos Exp $"); +__RCSID("$NetBSD: spec.c,v 1.6 1999/09/08 21:17:52 jsm Exp $"); #endif #endif /* not lint */ -# include "monop.ext" +#include "monop.ext" -static char *perc[] = { +static const char *const perc[] = { "10%", "ten percent", "%", "$200", "200", 0 }; void inc_tax() { /* collect income tax */ + int worth, com_num; - int worth, com_num; - - com_num = getinp("Do you wish to lose 10%% of your total worth or $200? ", perc); + com_num = getinp("Do you wish to lose 10%% of your total worth or " + "$200? ", perc); worth = cur_p->money + prop_worth(cur_p); printf("You were worth $%d", worth); worth /= 10; @@ -80,14 +80,12 @@ inc_tax() void goto_jail() { /* move player to jail */ - cur_p->loc = JAIL; } void lux_tax() { /* landing on luxury tax */ - printf("You lose $75\n"); cur_p->money -= 75; } @@ -95,13 +93,11 @@ lux_tax() void cc() { /* draw community chest card */ - get_card(&CC_D); } void chance() { /* draw chance card */ - get_card(&CH_D); } diff --git a/monop/trade.c b/monop/trade.c index 59c9899..a13d8ac 100644 --- a/monop/trade.c +++ b/monop/trade.c @@ -1,4 +1,4 @@ -/* $NetBSD: trade.c,v 1.4 1997/10/12 17:45:27 christos Exp $ */ +/* $NetBSD: trade.c,v 1.7 1999/09/30 18:01:32 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)trade.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: trade.c,v 1.4 1997/10/12 17:45:27 christos Exp $"); +__RCSID("$NetBSD: trade.c,v 1.7 1999/09/30 18:01:32 jsm Exp $"); #endif #endif /* not lint */ @@ -53,7 +53,7 @@ struct trd_st { /* how much to give to other player */ typedef struct trd_st TRADE; -static char *plist[MAX_PRP+2]; +static const char *plist[MAX_PRP+2]; static int used[MAX_PRP]; @@ -68,8 +68,7 @@ static void move_em __P((TRADE *, TRADE *)); void trade() { - - int tradee, i; + int tradee, i; trading = TRUE; for (i = 0; i < 2; i++) { @@ -101,20 +100,20 @@ over: if (getyn("Is the trade ok? ") == 0) do_trade(); } + /* * This routine gets the list of things to be trader for the * player, and puts in the structure given. */ static void get_list(struct_no, play_no) -int struct_no, play_no; + int struct_no, play_no; { - - int sn, pn; - PLAY *pp; - int numin, prop, num_prp; - OWN *op; - TRADE *tp; + int sn, pn; + PLAY *pp; + int numin, prop, num_prp; + OWN *op; + TRADE *tp; for (numin = 0; numin < MAX_PRP; numin++) used[numin] = FALSE; @@ -155,16 +154,16 @@ once_more: } } } + /* * This routine sets up the list of tradable property. */ static int set_list(the_list) -OWN *the_list; + OWN *the_list; { - - int i; - OWN *op; + int i; + OWN *op; i = 0; for (op = the_list; op; op = op->next) @@ -174,17 +173,17 @@ OWN *the_list; plist[i--] = 0; return i; } + /* * This routine summates the trade. */ static void summate() { - - bool some; - int i; - TRADE *tp; - OWN *op; + bool some; + int i; + TRADE *tp; + OWN *op; for (i = 0; i < 2; i++) { tp = &trades[i]; @@ -205,26 +204,26 @@ summate() printf("\t-- Nothing --\n"); } } + /* * This routine actually executes the trade. */ static void do_trade() { - move_em(&trades[0], &trades[1]); move_em(&trades[1], &trades[0]); } + /* * This routine does a switch from one player to another */ static void move_em(from, to) -TRADE *from, *to; + TRADE *from, *to; { - - PLAY *pl_fr, *pl_to; - OWN *op; + PLAY *pl_fr, *pl_to; + OWN *op; pl_fr = &play[from->trader]; pl_to = &play[to->trader]; @@ -240,16 +239,16 @@ TRADE *from, *to; } set_ownlist(to->trader); } + /* * This routine lets a player resign */ void resign() { - - int i, new_own; - OWN *op; - SQUARE *sqp; + int i, new_own; + OWN *op; + SQUARE *sqp; if (cur_p->money <= 0) { switch (board[cur_p->loc].type) { diff --git a/morse/Makefile.bsd b/morse/Makefile.bsd index 0f28e4f..390a224 100644 --- a/morse/Makefile.bsd +++ b/morse/Makefile.bsd @@ -1,9 +1,10 @@ -# $NetBSD: Makefile,v 1.3 1995/03/23 08:35:22 cgd Exp $ +# $NetBSD: Makefile,v 1.6 2002/09/18 06:16:40 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 -PROG= morse -NOMAN= noman -HIDEGAME=hidegame +NOMAN= # defined + +PROG= morse +HIDEGAME= hidegame .include diff --git a/morse/Makefrag b/morse/Makefrag index f8167ab..eca21c7 100644 --- a/morse/Makefrag +++ b/morse/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for morse +# +# Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. morse_DIRS := $(GAMESDIR) $(MAN6DIR) @@ -8,6 +34,3 @@ morse_install: morse_all $(INSTALL_BINARY) morse/morse $(INSTALL_PREFIX)$(GAMESDIR)/morse $(HIDE_GAME) morse $(INSTALL_MANUAL) bcd.6 morse.6 - -morse_check: morse_all - echo "Eat at Joe's" | morse/morse diff --git a/morse/morse.c b/morse/morse.c index e8022ce..8ac966c 100644 --- a/morse/morse.c +++ b/morse/morse.c @@ -1,4 +1,4 @@ -/* $NetBSD: morse.c,v 1.4 1997/10/10 16:38:40 lukem Exp $ */ +/* $NetBSD: morse.c,v 1.10 2000/07/03 03:57:42 matt Exp $ */ /* * Copyright (c) 1988, 1993 @@ -43,16 +43,22 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1993\n\ #if 0 static char sccsid[] = "@(#)morse.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: morse.c,v 1.4 1997/10/10 16:38:40 lukem Exp $"); +__RCSID("$NetBSD: morse.c,v 1.10 2000/07/03 03:57:42 matt Exp $"); #endif #endif /* not lint */ #include #include +#include +#include #include -static char - *digit[] = { +#define MORSE_COLON "--..--" +#define MORSE_PERIOD ".-.-.-" + + +static const char + *const digit[] = { "-----", ".----", "..---", @@ -64,7 +70,7 @@ static char "---..", "----.", }, - *alph[] = { + *const alph[] = { ".-", "-...", "-.-.", @@ -95,9 +101,11 @@ static char int main __P((int, char *[])); void morse __P((int)); -void show __P((char *)); +void decode __P((const char *)); +void show __P((const char *)); static int sflag; +static int dflag; int main(argc, argv) @@ -105,32 +113,119 @@ main(argc, argv) char **argv; { int ch; - char *p; + char *s, *p; /* Revoke setgid privileges */ setregid(getgid(), getgid()); - while ((ch = getopt(argc, argv, "s")) != -1) + while ((ch = getopt(argc, argv, "ds")) != -1) switch((char)ch) { + case 'd': + dflag = 1; + break; case 's': sflag = 1; break; case '?': default: - fprintf(stderr, "usage: morse [string ...]"); + fprintf(stderr, "usage: morse [-ds] [string ...]\n"); exit(1); } argc -= optind; argv += optind; - if (*argv) - do { - for (p = *argv; *p; ++p) - morse((int)*p); - } while (*++argv); - else while ((ch = getchar()) != EOF) - morse(ch); - exit(0); + if (dflag) { + if (*argv) { + do { + s=strchr(*argv, ','); + + if (s) + *s='\0'; + + decode(*argv); + } while (*++argv); + }else{ + char buf[1024]; + + while (fgets(buf, 1024, stdin)) { + s=buf; + + while (*s && isspace(*s)) + s++; + + if (*s) { + p=strtok(s, " \n\t"); + + while (p) { + s=strchr(p, ','); + + if (s) + *s='\0'; + + decode(p); + p=strtok(NULL, " \n\t"); + } + } + } + } + putchar('\n'); + }else{ + if (*argv) + do { + for (p = *argv; *p; ++p) + morse((int)*p); + } while (*++argv); + else while ((ch = getchar()) != EOF) + morse(ch); + } + + return 0; +} + +void +decode(s) + const char *s; +{ + if (strcmp(s, MORSE_COLON) == 0){ + putchar(','); + } else if (strcmp(s, MORSE_PERIOD) == 0){ + putchar('.'); + } else { + int found; + const char *const *a; + int size; + int i; + + found=0; + a=digit; + size=sizeof(digit)/sizeof(digit[0]); + for (i=0; i + PROG= phantasia SRCS= fight.c gamesupport.c interplayer.c io.c main.c misc.c phantglobs.c @@ -10,22 +12,35 @@ HIDEGAME=hidegame SETGIDGAME=yes USETBL= MAN= phantasia.6 -CLEANFILES+=map setup setup.o host_phantglobs.o -all: setup phantasia +FILESDIR=/var/games/phantasia +FILESOWN=games +FILESGRP=games +FILESMODE=0660 +ALLFILES=gold lastdead mess monsters void motd characs scoreboard +FILES=gold lastdead mess monsters void motd +# don't overwrite existing characters or scorefile +.for file in characs scoreboard +.if !exists(${DESTDIR}/${FILESDIR}/${file}) +FILES+=${file} +.endif +.endfor -setup: host_phantglobs.o setup.o monsters.asc ${LIBM} - ${HOST_CC} host_phantglobs.o setup.o -o ${.TARGET} -lm +CLEANFILES+=map setup setup.lo host_phantglobs.lo ${ALLFILES} -host_phantglobs.o: ${.CURDIR}/phantglobs.c - ${HOST_COMPILE.c} -o host_phantglobs.o ${.CURDIR}/phantglobs.c +realall: ${FILES} -setup.o: ${.CURDIR}/setup.c - ${HOST_COMPILE.c} ${.CURDIR}/setup.c - -afterinstall: +${FILES}: setup ./setup -m ${.CURDIR}/monsters.asc - chown games:games ${DESTDIR}/var/games/phantasia/* + +setup: host_phantglobs.lo setup.lo monsters.asc ${LIBM} + ${HOST_LINK.c} host_phantglobs.lo setup.lo -o ${.TARGET} -lm + +host_phantglobs.lo: ${.CURDIR}/phantglobs.c + ${HOST_COMPILE.c} -o host_phantglobs.lo ${.CURDIR}/phantglobs.c + +setup.lo: ${.CURDIR}/setup.c + ${HOST_COMPILE.c} -o setup.lo ${.CURDIR}/setup.c # Make Phantasia map. Change the map commands reflect your installation. # PLOTDEVICE is used for plotting the map. Change as appropriate. diff --git a/phantasia/fight.c b/phantasia/fight.c index 3fb9c6b..14094e4 100644 --- a/phantasia/fight.c +++ b/phantasia/fight.c @@ -1,4 +1,4 @@ -/* $NetBSD: fight.c,v 1.4 1998/08/30 09:19:39 veego Exp $ */ +/* $NetBSD: fight.c,v 1.7 2000/04/27 00:30:53 jdc Exp $ */ /* * fight.c Phantasia monster fighting routines @@ -10,18 +10,14 @@ void encounter(particular) int particular; { - bool firsthit = Player.p_blessing; /* set if player gets the - * first hit */ - int flockcnt = 1; /* how many time flocked */ + volatile bool firsthit = Player.p_blessing; /* set if player gets + * the first hit */ + volatile int flockcnt = 1; /* how many time flocked */ /* let others know what we are doing */ Player.p_status = S_MONSTER; writerecord(&Player, Fileloc); -#if __GNUC__ - (void)&firsthit; /* XXX shut up gcc */ -#endif - #ifdef SYS5 flushinp(); #endif @@ -396,7 +392,7 @@ monsthits() /* takes some of the player's strength */ inflict = ROLL(1.0, (Circle - 1.0) / 2.0); inflict = MIN(Player.p_strength, inflict); - mvprintw(Lines++, 0, "%s sapped %0.f of your strength!", + mvprintw(Lines++, 0, "%s sapped %.0f of your strength!", Enemyname, inflict); Player.p_strength -= inflict; Player.p_might -= inflict; @@ -549,7 +545,7 @@ monsthits() mvprintw(Lines++, 0, "%s flew away, and left you to contend with one of its friends.", Enemyname); - Whichmonster = 55 + (drandom() > 0.5) ? 22 : 0; + Whichmonster = 55 + ((drandom() > 0.5) ? 22 : 0); longjmp(Fightenv, 0); /* NOTREACHED */ @@ -844,7 +840,7 @@ callmonster(which) which = MIN(which, 99); /* make sure within range */ /* fill structure */ - fseek(Monstfp, (long) which * (long) SZ_MONSTERSTRUCT, 0); + fseek(Monstfp, (long) which * (long) SZ_MONSTERSTRUCT, SEEK_SET); fread((char *) &Curmonster, SZ_MONSTERSTRUCT, 1, Monstfp); /* handle some special monsters */ @@ -869,7 +865,7 @@ callmonster(which) Curmonster.m_energy = Player.p_might * 30.0; Curmonster.m_type = SM_MORGOTH; Curmonster.m_speed = Player.p_speed * 1.1 - + (Player.p_specialtype == SC_EXVALAR) ? Player.p_speed : 0.0; + + ((Player.p_specialtype == SC_EXVALAR) ? Player.p_speed : 0.0); Curmonster.m_flock = 0.0; Curmonster.m_treasuretype = 0; Curmonster.m_experience = 0.0; @@ -879,7 +875,7 @@ callmonster(which) /* pick another name */ { which = (int) ROLL(0.0, 100.0); - fseek(Monstfp, (long) which * (long) SZ_MONSTERSTRUCT, 0); + fseek(Monstfp, (long) which * (long) SZ_MONSTERSTRUCT, SEEK_SET); fread(&Othermonster, SZ_MONSTERSTRUCT, 1, Monstfp); strcpy(Curmonster.m_name, Othermonster.m_name); } diff --git a/phantasia/gamesupport.c b/phantasia/gamesupport.c index b0ce0d8..6c6d804 100644 --- a/phantasia/gamesupport.c +++ b/phantasia/gamesupport.c @@ -1,4 +1,4 @@ -/* $NetBSD: gamesupport.c,v 1.4 1997/10/13 02:18:16 lukem Exp $ */ +/* $NetBSD: gamesupport.c,v 1.6 1999/09/08 21:57:19 jsm Exp $ */ /* * gamesupport.c - auxiliary routines for support of Phantasia @@ -13,7 +13,7 @@ changestats(ingameflag) static char flag[2] = /* for printing values of bools */ {'F', 'T'}; struct player *playerp; /* pointer to structure to alter */ - char *prompt; /* pointer to prompt string */ + const char *prompt; /* pointer to prompt string */ int c; /* input */ int today; /* day of year of today */ int temp; /* temporary variable */ @@ -443,7 +443,7 @@ monstlist() int count = 0; /* count in file */ puts(" #) Name Str Brain Quick Energy Exper Treas Type Flock%\n"); - fseek(Monstfp, 0L, 0); + fseek(Monstfp, 0L, SEEK_SET); while (fread((char *) &Curmonster, SZ_MONSTERSTRUCT, 1, Monstfp) == 1) printf("%2d) %-20.20s%4.0f %4.0f %2.0f %5.0f %5.0f %2d %2d %3.0f\n", count++, Curmonster.m_name, Curmonster.m_strength, Curmonster.m_brains, @@ -468,7 +468,7 @@ scorelist() void activelist() { - fseek(Playersfp, 0L, 0); + fseek(Playersfp, 0L, SEEK_SET); printf("Current characters on file are:\n\n"); while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1) @@ -492,7 +492,7 @@ purgeoldplayers() today = localtime(<ime)->tm_yday; for (;;) { - fseek(Playersfp, loc, 0); + fseek(Playersfp, loc, SEEK_SET); if (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) != 1) break; @@ -543,7 +543,7 @@ enterscore() strcpy(sbuf.sb_type, descrtype(&Player, TRUE)); } /* update entry */ - fseek(fp, loc, 0); + fseek(fp, loc, SEEK_SET); fwrite((char *) &sbuf, SZ_SCORESTRUCT, 1, fp); fclose(fp); } diff --git a/phantasia/interplayer.c b/phantasia/interplayer.c index e603364..993c162 100644 --- a/phantasia/interplayer.c +++ b/phantasia/interplayer.c @@ -1,4 +1,4 @@ -/* $NetBSD: interplayer.c,v 1.3 1997/10/13 02:18:22 lukem Exp $ */ +/* $NetBSD: interplayer.c,v 1.6 1999/09/18 19:38:52 jsm Exp $ */ /* * interplayer.c - player to player routines for Phantasia @@ -12,7 +12,7 @@ checkbattle() long foeloc = 0L; /* location in file of person to fight */ Users = 0; - fseek(Playersfp, 0L, 0); + fseek(Playersfp, 0L, SEEK_SET); while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1) { if (Other.p_status != S_OFF @@ -356,7 +356,7 @@ checktampered() long loc = 0L; /* location in energy void file */ /* first check for energy voids */ - fseek(Energyvoidfp, 0L, 0); + fseek(Energyvoidfp, 0L, SEEK_SET); while (fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp) == 1) if (Enrgyvoid.ev_active && Enrgyvoid.ev_x == Player.p_x @@ -508,7 +508,7 @@ tampered(what, arg1, arg2) addstr("You made to position of Valar!\n"); Player.p_specialtype = SC_VALAR; Player.p_lives = 5; - fseek(Playersfp, 0L, 0); + fseek(Playersfp, 0L, SEEK_SET); loc = 0L; while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1) /* search for existing valar */ @@ -545,7 +545,7 @@ userlist(ingameflag) mvaddstr(8, 0, "You cannot see anyone.\n"); return; } - fseek(Playersfp, 0L, 0); + fseek(Playersfp, 0L, SEEK_SET); mvaddstr(8, 0, "Name X Y Lvl Type Login Status\n"); @@ -607,7 +607,7 @@ throneroom() if (Player.p_specialtype < SC_KING) /* not already king -- assumes crown */ { - fseek(Playersfp, 0L, 0); + fseek(Playersfp, 0L, SEEK_SET); while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1) if (Other.p_specialtype == SC_KING && Other.p_status != S_NOTUSED) /* found old king */ @@ -643,7 +643,7 @@ throneroom() fclose(fp); /* clear all energy voids; retain location of holy grail */ - fseek(Energyvoidfp, 0L, 0); + fseek(Energyvoidfp, 0L, SEEK_SET); fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp); fp = fopen(_PATH_VOID, "w"); fwrite((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, fp); @@ -656,7 +656,7 @@ void dotampered() { short tamper; /* value for tampering with other players */ - char *option; /* pointer to option description */ + const char *option; /* pointer to option description */ double temp1 = 0.0, temp2 = 0.0; /* other tampering values */ int ch; /* input */ long loc; /* location in energy void file */ @@ -718,7 +718,7 @@ dotampered() /* collect taxes */ { fread((char *) &temp1, sizeof(double), 1, fp); - fseek(fp, 0L, 0); + fseek(fp, 0L, SEEK_SET); /* clear out value */ temp2 = 0.0; fwrite((char *) &temp2, sizeof(double), 1, fp); @@ -765,7 +765,7 @@ dotampered() if (Player.p_palantir) /* need a palantir to seek */ { - fseek(Energyvoidfp, 0L, 0); + fseek(Energyvoidfp, 0L, SEEK_SET); fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp); temp1 = distance(Player.p_x, Enrgyvoid.ev_x, Player.p_y, Enrgyvoid.ev_y); temp1 += ROLL(-temp1 / 10.0, temp1 / 5.0); /* add some error */ @@ -865,10 +865,10 @@ writevoid(vp, loc) long loc; { - fseek(Energyvoidfp, loc, 0); + fseek(Energyvoidfp, loc, SEEK_SET); fwrite((char *) vp, SZ_VOIDSTRUCT, 1, Energyvoidfp); fflush(Energyvoidfp); - fseek(Energyvoidfp, 0L, 0); + fseek(Energyvoidfp, 0L, SEEK_SET); } long @@ -876,7 +876,7 @@ allocvoid() { long loc = 0L; /* location of new energy void */ - fseek(Energyvoidfp, 0L, 0); + fseek(Energyvoidfp, 0L, SEEK_SET); while (fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp) == 1) if (Enrgyvoid.ev_active) loc += SZ_VOIDSTRUCT; diff --git a/phantasia/io.c b/phantasia/io.c index 1db8c39..d2f182e 100644 --- a/phantasia/io.c +++ b/phantasia/io.c @@ -1,4 +1,4 @@ -/* $NetBSD: io.c,v 1.3 1997/10/13 02:18:25 lukem Exp $ */ +/* $NetBSD: io.c,v 1.5 1999/09/08 21:45:29 jsm Exp $ */ /* * io.c - input/output routines for Phantasia @@ -153,7 +153,7 @@ interrupt() int getanswer(choices, def) - char *choices; + const char *choices; bool def; { int ch; /* input */ @@ -238,7 +238,7 @@ getanswer(choices, def) void catchalarm(dummy) - int dummy __attribute__((unused)); + int dummy __attribute__((__unused__)); { longjmp(Timeoenv, 1); } diff --git a/phantasia/phantasia.6 b/phantasia/phantasia.6 index 05b9f48..c79ca17 100644 --- a/phantasia/phantasia.6 +++ b/phantasia/phantasia.6 @@ -1,285 +1,272 @@ -.\" $NetBSD: phantasia.6,v 1.3 1997/01/07 12:20:38 tls Exp $ +.\" $NetBSD: phantasia.6,v 1.9 2002/09/26 18:32:03 wiz Exp $ .\" -.de sh -.br -.ne 5 -.PP -\fB\\$1\fR -.PP -.. -.TH PHANTASIA 6 "June 1, 1994" -.UC 4 -.SH NAME -phantasia \- an interterminal fantasy game -.SH SYNOPSIS -phantasia [ \-HSabmpsx ] -.SH DESCRIPTION -.I Phantasia -is a role playing game -which allows players to roll up characters of various types to fight -monsters and other players. +.Dd April 1, 2001 +.Dt PHANTASIA 6 +.Os +.Sh NAME +.Nm phantasia +.Nd an interterminal fantasy game +.Sh SYNOPSIS +.Nm +.Op Fl abHmpSsx +.Sh DESCRIPTION +.Nm +is a role playing game which allows players to roll up characters of +various types to fight monsters and other players. Progression of characters is based upon gaining experience from fighting monsters (and other players). -.PP +.Pp Most of the game is menu driven and self-explanatory (more or less). The screen is cursor updated, so be sure to set up the -.B TERM +.Ev TERM variable in your environment. -.PP +.Pp The options provide for a variety of functions to support the game. They are: -.PP -.TP .5i -.B \-s -Invokes -.I phantasia -without header information. -.TP .5i -.B \-m -Get a monster listing. -.TP .5i -.B \-a +.Pp +.Bl -tag -width aaa -offset indent +.It Fl a Get a listing of all character names on file. -.TP .5i -.B \-x -Examine/change a particular character on file. -.TP .5i -.B \-H -Print header only. -.TP .5i -.B \-p -Purge old characters. -.TP .5i -.B \-b +.It Fl b Show scoreboard of top characters per login. -.TP .5i -.B \-S -Turn on wizard options, if allowed, if running as ``root''. -.PP +.It Fl H +Print header only. +.It Fl m +Get a monster listing. +.It Fl p +Purge old characters. +.It Fl S +Turn on wizard options, if allowed, if running as +.Dq root . +.It Fl s +Invokes +.Nm +without header information. +.It Fl x +Examine/change a particular character on file. +.El +.Pp The characters are saved on a common file, in order to make the game -interactive between players. The characters are given a password -in order to retrieve them later. Only characters above -.B level -zero are saved. Characters unused for awhile will be purged. +interactive between players. +The characters are given a password in order to retrieve them later. +Only characters above +.Em level +zero are saved. +Characters unused for awhile will be purged. Characters are only placed on the scoreboard when they die. -.SH AUTHOR -Edward Estes, AT&T Information Systems, Skokie, IL -.SH PARTICULARS -.sh "Normal Play" +.Sh AUTHOR +.An Edward Estes , +AT\*[Am]T Information Systems, Skokie, IL +.Sh PARTICULARS +.Ss Normal Play A number of the player's more important statistics are almost always displayed on the screen, with maximums (where applicable) in parentheses. -.PP -The character is placed randomly near the center of a cartesian +.Pp +The character is placed randomly near the center of a Cartesian system. Most commands are selected with a single letter or digit. For example, one may move by hitting 'W', 'S', 'N', or 'E', (lower case may also be used, at no time is the game case dependent). One may also use 'H', 'J', 'K', 'L', for movement, similar to -.IR vi (1). +.Xr vi 1 . To move to a specific (x, y) coordinate, use the -.B move -('1') command. The distance a character can move is calculated by +.Ic move +('1') command. +The distance a character can move is calculated by 1 plus 1.5 per -.B level. +.Em level . Moving in a compass direction will move the player the maximum allowed distance in that direction. -.PP +.Pp A player may see who else is playing by using the -.B players -('2') option. One may see the coordinates of those who are the same +.Ic players +('2') option. +One may see the coordinates of those who are the same distance or closer to the origin as he/she. -.B Kings, +.Em Kings , and -.B council of the wise -can see and can be seen by everyone. A -.B palantir +.Em council of the wise +can see and can be seen by everyone. +A +.Em palantir removes these restrictions. -.PP +.Pp One can talk to other players with the -.B talk -('3') option. In general, this is a line or so of text. To remove a current -message, just type when prompted for a message. -.PP +.Ic talk +('3') option. +In general, this is a line or so of text. +To remove a current +message, just type +.Aq return +when prompted for a message. +.Pp The -.B stats +.Ic stats ('4') option shows additional characteristics of a player. -.PP +.Pp One may leave the game either with the -.B quit +.Ic quit ('5') option. -.PP -One may rest by default. Resting lets one regain maximum -.B energy level, +.Pp +One may rest by default. +Resting lets one regain maximum +.Em energy level , and also lets one find -.B mana +.Em mana (more is found for larger levels and further distances from the origin). -.PP +.Pp One may call a monster by hitting '9' or 'C'. -.PP +.Pp Use 'X' to examine other players. -.PP +.Pp One may quit or execute a sub-shell by hitting interrupt. Quitting during battle results in death for obvious reasons. -.PP +.Pp Several other options become available as the player progresses in -.B level +.Em level and -.B magic, -or to other stations in the game ( -.B valar, council of the wise, king -). +.Em magic , +or to other stations in the game +.Em ( valar , +.Em council of the wise , +.Em king ) . These are described elsewhere. In general, a control-L will force the redrawing of the screen. -.PP +.Pp Other things which may happen are more or less self-explanatory. -.sh "Fighting Monsters" -A player has several options while fighting monsters. They are as follows: -.TP 1.5i -.B melee +.Ss Fighting Monsters +A player has several options while fighting monsters. +They are as follows: +.Bl -tag -width skirmish -offset indent +.It Ic melee Inflicts damage on the monster, based upon -.B strength. +.Em strength . Also decreases the monster's -.B strength +.Em strength some. -.TP 1.5i -.B skirmish +.It Ic skirmish Inflicts a little less damage than -.B melee, +.Ic melee , but decreases the monster's -.B quickness +.Em quickness instead. -.TP 1.5i -.B evade -Attempt to run away. Success is based upon both the player's and -the monster's -.B brains +.It Ic evade +Attempt to run away. +Success is based upon both the player's and the monster's +.Em brains and -.B quickness. -.TP 1.5i -.B spell +.Em quickness . +.It Ic spell Several options for throwing spells (described elsewhere). -.TP 1.5i -.B nick +.It Ic nick Hits the monster one plus the player's -.B sword, +.Em sword , and gives the player 10% of the monster's -.B experience. +.Em experience . Decreases the monster's -.B experience +.Em experience an amount proportional to the amount granted. This also increases the monster's quickness. Paralyzed monsters wake up very fast when nicked. -.TP 1.5i -.B luckout -This is essentially a battle of wits with the monster. Success is based -upon the player's and the monster's -.B brains. +.It Ic luckout +This is essentially a battle of wits with the monster. +Success is based upon the player's and the monster's +.Em brains . The player gets credit for slaying the monster if he/she succeeds. Otherwise, nothing happens, and the chance to -.B luckout +.Ic luckout is lost. -.sh "Character Statistics" -.TP 1.5i -.B strength +.El +.Ss Character Statistics +.Bl -tag -width quickness -offset indent +.It Em strength determines how much damage a character can inflict. -.TP 1.5i -.B quickness -determines how many chances a character gets to make decisions while -fighting. -.TP 1.5i -.B energy level +.It Em quickness +determines how many chances a character gets to make decisions while fighting. +.It Em energy level specifies how much damage a character may endure before dying. -.TP 1.5i -.B magic level +.It Em magic level determines which spells a character may throw, and how effective those spells will be. -.TP 1.5i -.B brains +.It Em brains basically, the character's intelligence; used for various fighting options and spells. -.TP 1.5i -.B mana +.It Em mana used as a power source for throwing spells. -.TP 1.5i -.B experience +.It Em experience gained by fighting monsters and other characters. -.TP 1.5i -.B level +.It Em level indicative of how much experience a character has accumulated; progresses geometrically as -.B experience +.Em experience increases. -.TP 1.5i -.B poison +.It Em poison sickness which degrades a character's performance (affects -.B energy level +.Em energy level and -.B strength -). -.TP 1.5i -.B sin +.Em strength ) . +.It Em sin accumulated as a character does certain nasty things; used only rarely in normal play of the game. -.TP 1.5i -.B age +.It Em age of player; roughly equivalent to number of turns. As -.B age +.Em age increases, many personal statistics degenerate. -.sh "Character Types" +.El +.Ss Character Types Character statistics are rolled randomly from the above list, according -to character type. The types are as follows: -.TP 1.5i -.B magic user +to character type. +The types are as follows: +.Bl -tag -width "experimento" -offset indent +.It Em magic user strong in -.B magic level +.Em magic level and -.B brains -, weak in other areas. Must rely on wits and magic to survive. -.TP 1.5i -.B fighter +.Em brains , +weak in other areas. +Must rely on wits and magic to survive. +.It Em fighter good in -.B strength +.Em strength and -.B energy level -, fairly good in other areas. This adds up to a well-equipped fighter. -.TP 1.5i -.B elf +.Em energy level , +fairly good in other areas. +This adds up to a well-equipped fighter. +.It Em elf very high -.B quickness +.Em quickness and above average -.B magic level +.Em magic level are -.B elves +.Em elves selling points. -.TP 1.5i -.B dwarf +.It Em dwarf very high -.B strength +.Em strength and -.B energy level -, but with a tendency to be rather slow and not too bright. -.TP 1.5i -.B halfling +.Em energy level , +but with a tendency to be rather slow and not too bright. +.It Em halfling rather quick and smart, with high -.B energy level -, but poor in -.B magic +.Em energy level , +but poor in +.Em magic and -.B strength. +.Em strength . Born with some -.B experience. -.TP 1.5i -.B experimento -very mediocre in all areas. However, the -.B experimento +.Em experience . +.It Em experimento +very mediocre in all areas. +However, the +.Em experimento may be placed almost anywhere within the playing grid. -.PP +.El +.Pp The possible ranges for starting statistics are summarized in the following table. -.PP .TS l c c c c c c l c c c c c c. @@ -292,16 +279,26 @@ Dwarf 50-70 25-30 25-45 60-100 20-40 2-5 Halfling 20-25 34 25-45 55-90 40-75 1-4 Experimento 25 27 100 35 25 2 .TE -.PP +.\" .Bl -column "Experimento" "Strength" "Quick" "xxxxxx" "Energy" "Brains" "Magic" +.\" .It Sy Charactertype Strength Quick Mana Energy Brains Magic +.\" .It "Magic User" 10-15 30-35 50-100 30-45 60-85 5-9 +.\" .It Fighter 40-55 30-35 30-50 45-70 25-45 3-6 +.\" .It Elf 35-45 32-38 45-90 30-50 40-65 4-7 +.\" .It Dwarf 50-70 25-30 25-45 60-100 20-40 2-5 +.\" .It Halfling 20-25 34 25-45 55-90 40-75 1-4 +.\" .It Experimento 25 27 100 35 25 2 +.\" .El +.Pp Not only are the starting characteristics different for the different character types, the characteristics progress at different rates for the different types as the character goes up in -.B level. Experimentoes' +.Em level . +.Em Experimentoes Ns ' characteristics progress randomly as one of the other types. The progression as characters increase in -.B level +.Em level is summarized in the following table. -.PP +.Pp .TS l c c c c c l n n n n n. @@ -313,914 +310,887 @@ Elf 2.5 65 25 4.0 2.0 Dwarf 5 30 35 2.5 1 Halfling 2.0 30 30 4.5 1 .TE -.PP +.Pp The character type also determines how much gold a player may carry, how long until -.B rings +.Em rings can overcome the player, and how much -.B poison +.Em poison the player can withstand. -.sh "Spells" +.Ss Spells During the course of the game, the player may exercise his/her -magic powers. These cases are described below. -.TP 1.5i -.B cloak -.I magic level necessary: +magic powers. +These cases are described below. +.Bl -tag -width "all or nothing" -offset indent +.It Ic cloak +.Em magic level necessary : 20 (plus level 7) .br -.I mana used: +.Em mana used : 35 plus 3 per rest period .br -Used during normal play. Prevents monsters from finding the character, -as well as hiding the player from other players. His/her coordinates -show up as '?' in the -.B players -option. Players cannot collect -.B mana, +Used during normal play. +Prevents monsters from finding the character, +as well as hiding the player from other players. +His/her coordinates show up as '?' in the +.Ic players +option. +Players cannot collect +.Em mana , find trading posts, or discover the -.B grail -while cloaked. Calling a monster uncloaks, as well as choosing -this option while cloaked. -.br -.TP 1.5i -.B teleport -.I magic level necessary: +.Em grail +while cloaked. +Calling a monster uncloaks, as well as choosing this option while cloaked. +.It Ic teleport +.Em magic level necessary : 40 (plus level 12) .br -.I mana used: +.Em mana used : 30 per 75 moved .br -Used during normal play. Allows the player too move with much more freedom -than with the -.B move -option, at the price of expending mana. The maximum distance possible -to move is based upon -.B level +Used during normal play. +Allows the player to move with much more freedom than with the +.Ic move +option, at the price of expending mana. +The maximum distance possible to move is based upon +.Em level and -.B magic level. -.TP 1.5i -.B power blast -.I magic level necessary: +.Em magic level . +.It Ic power blast +.Em magic level necessary : none .br -.I mana used: +.Em mana used : 5 times -.B level +.Em level .br -Used during inter-terminal battle. Damage is based upon -.B magic level +Used during inter-terminal battle. +Damage is based upon +.Em magic level and -.B strength. +.Em strength . Hits much harder than a normal hit. -.TP 1.5i -.B all or nothing -.I magic level necessary: +.It Ic all or nothing +.Em magic level necessary : none .br -.I mana used: +.Em mana used : 1 .br Used while combating monsters. -Has a 25% chance of working. If it works it hits the monster just enough -to kill it. If it fails, it doesn't hit the monster, and doubles the -monster's -.B quickness +Has a 25% chance of working. +If it works it hits the monster just enough to kill it. +If it fails, it doesn't hit the monster, and doubles the monster's +.Em quickness and -.B strength. +.Em strength . Paralyzed monsters wake up much quicker as a result of this spell. -.TP 1.5i -.B magic bolt -.I magic level necessary: +.It Ic magic bolt +.Em magic level necessary : 5 .br -.I mana used: +.Em mana used : variable .br -Used while combating monsters. Hits the monster based upon the amount +Used while combating monsters. +Hits the monster based upon the amount of -.B mana +.Em mana expended and -.B magic level. +.Em magic level . Guaranteed to hit at least 10 per -.B mana. -.TP 1.5i -.B force field -.I magic level necessary: +.Em mana . +.It Ic force field +.Em magic level necessary : 15 .br -.I mana used: +.Em mana used : 30 .br -Used during monster combat. Throws up a shield to protect from damage. +Used during monster combat. +Throws up a shield to protect from damage. The shield is added to actual energy level, and is a fixed number, based -upon maximum energy. Normally, damage occurs first to the shield, and -then to the players actual -.B energy level. -.TP 1.5i -.B transform -.I magic level necessary: +upon maximum energy. +Normally, damage occurs first to the shield, and then to the players actual +.Em energy level . +.It Ic transform +.Em magic level necessary : 25 .br -.I mana used: +.Em mana used : 50 .br -Used during monster combat. Transforms the monster randomly into one -of the 100 monsters from the monster file. -.TP 1.5i -.B increase might -.I magic level necessary: +Used during monster combat. +Transforms the monster randomly into one of the 100 monsters from +the monster file. +.It Ic increase might +.Em magic level necessary : 35 .br -.I mana used: +.Em mana used : 75 .br -Used during combat with monsters. Increases strength up to a maximum. -.TP 1.5i -.B invisibility -.I magic level necessary: +Used during combat with monsters. +Increases strength up to a maximum. +.It Ic invisibility +.Em magic level necessary : 45 .br -.I mana used: +.Em mana used : 90 .br -Used while fighting monsters. Makes it harder for the monster to hit, -by temporarily increasing the player's -.B quickness. +Used while fighting monsters. +Makes it harder for the monster to hit, by temporarily increasing the player's +.Em quickness . This spell may be thrown several times, but a maximum level will be reached. -.TP 1.5i -.B transport -.I magic level necessary: +.It Ic transport +.Em magic level necessary : 60 .br -.I mana used: +.Em mana used : 125 .br -Used during monster combat. Transports the monster away from the -player. Success is base upon player's -.B magic +Used during monster combat. +Transports the monster away from the player. +Success is based upon player's +.Em magic and -.B brains, +.Em brains , and the monster's -.B experience. -If it fails the player is transported instead. 60% of the time, the monster -will drop any treasure it was carrying. -.TP 1.5i -.B paralyze -.I magic level necessary: +.Em experience . +If it fails the player is transported instead. +60% of the time, the monster will drop any treasure it was carrying. +.It Ic paralyze +.Em magic level necessary : 75 .br -.I mana used: +.Em mana used : 150 .br -Used during monster combat. "Freezes" the monster by putting its -.B quickness -slightly negative. The monster will slowly wake up. Success is based -upon player's -.B magic +Used during monster combat. +.Dq Freezes +the monster by putting its +.Em quickness +slightly negative. +The monster will slowly wake up. +Success is based upon player's +.Em magic and the monster's -.B experience. +.Em experience . If it fails, nothing happens. -.TP 1.5i -.B specify -.I magic level necessary: +.It Ic specify +.Em magic level necessary : none .br -.I mana used: +.Em mana used : 1000 .br Used during monster combat only by -.B valar +.Em valar or -.B council of the wise. +.Em council of the wise . Allows the player to pick which monster to fight. -.sh "Monsters" -Monsters get bigger as one moves farther from the origin (0,0). Rings of -distance 125 from the origin determine the size. A monster's -.B experience, energy level, +.El +.Ss Monsters +Monsters get bigger as one moves farther from the origin (0,0). +Rings of distance 125 from the origin determine the size. +A monster's +.Em experience , +.Em energy level , and -.B brains +.Em brains are multiplied by the size. -.B Strength -is increase 50% per size over one, and -.B quickness +.Em Strength +is increased 50% per size over one, and +.Em quickness remains the same, regardless of size. -.PP -Also, nastier monsters are found as one progress farther out -from the origin. Monsters also may flock. The percent chance of that -happening is designated as -.B flock% -in the monster listing. Monsters outside the first ring +.Pp +Also, nastier monsters are found as one progress farther out from the origin. +Monsters also may flock. +The percent chance of that happening is designated as +.Em flock% +in the monster listing. +Monsters outside the first ring may carry treasure, as determined by their treasure type. Flocking monsters, and bigger monsters increase the chances of treasure. -.PP +.Pp Certain monsters have special abilities; they are as follows: -.TP 1.5i -.B Unicorn +.Bl -tag -width "Assorted Faeries" +.It Em Unicorn can only be subdued if the player is in possession of a -.B virgin. -.TP 1.5i -.B Modnar +.Em virgin . +.It Em Modnar has random characteristics, including treasure type. -.TP 1.5i -.B Mimic -will pick another name from the list of monsters in order to -confuse. -.TP 1.5i -.B Dark Lord -very nasty person. Does not like to be hit (especially nicked), +.It Em Mimic +will pick another name from the list of monsters in order to confuse. +.It Em Dark Lord +very nasty person. +Does not like to be hit (especially nicked), and many spells do not work well (or at all) against him. One can always -.B evade +.Em evade from the -.B Dark Lord. -.TP 1.5i -.B Leanan-Sidhe -also a very nasty person. She will permanently sap -.B strength +.Em Dark Lord . +.It Em Leanan-Sidhe +also a very nasty person. +She will permanently sap +.Em strength from someone. -.TP 1.5i -.B Saruman +.It Em Saruman wanders around with -.B Wormtongue -, who can steal a -.B palantir. +.Em Wormtongue , +who can steal a +.Em palantir . Also, -.B Saruman -may turn a player's gems into gold pieces, -or scramble her/his stats. -.TP 1.5i -.B Thaumaturgist +.Em Saruman +may turn a player's gems into gold pieces, or scramble her/his stats. +.It Em Thaumaturgist can transport a player. -.TP 1.5i -.B Balrog +.It Em Balrog inflicts damage by taking away -.B experience -, not -.B energy. -.TP 1.5i -.B Vortex +.Em experience , +not +.Em energy . +.It Em Vortex may take some -.B mana. -.TP 1.5i -.B Nazgul +.Em mana . +.It Em Nazgul may try to steal a -.B ring +.Em ring or neutralize part of one's -.B brains. -.TP 1.5i -.B Tiamat +.Em brains . +.It Em Tiamat may take half a player's -.B gold +.Em gold and -.B gems +.Em gems and escape. -.TP 1.5i -.B Kobold +.It Em Kobold may get nasty and steal one gold piece and run away. -.TP 1.5i -.B Shelob +.It Em Shelob may bite, inflicting the equivalent of one -.B poison. -.TP 1.5i -.B Assorted Faeries +.Em poison . +.It Em Assorted Faeries These are killed if attacking someone carrying -.B holy water. +.Em holy water . These are -.B Cluricaun, Fir Darrig, Fachan, -.B Ghille Dhu, Bogle, Killmoulis, +.Em Cluricaun , Fir Darrig , Fachan , +.Em Ghille Dhu , Bogle , Killmoulis , and -.B Bwca. -.TP 1.5i -.B Lamprey +.Em Bwca . +.It Em Lamprey may bite, inflicting 1/2 of a -.B poison. -.TP 1.5i -.B Shrieker +.Em poison . +.It Em Shrieker will call one of its (much bigger) buddies if picked upon. -.TP 1.5i -.B Bonnacon +.It Em Bonnacon will become bored with battle, fart, and run off. -.TP 1.5i -.B Smeagol +.It Em Smeagol will try to steal a -.B ring +.Em ring from a player, if given the chance. -.TP 1.5i -.B Succubus +.It Em Succubus may inflict damage through a -.B force field. +.Ic force field . This subtracts from -.B energy level +.Em energy level instead of any shield the player may have thrown up. This is a very easy way to die. -.TP 1.5i -.B Cerberus -loves metal and will steal all the metal treasures from -a player if able. -.TP 1.5i -.B Ungoliant -can bite and poison. This inflicts five -.B poisons -, and also takes one from the player's -.B quickness. -.TP 1.5i -.B Jabberwock +.It Em Cerberus +loves metal and will steal all the metal treasures from a player if able. +.It Em Ungoliant +can bite and poison. +This inflicts five +.Em poisons , +and also takes one from the player's +.Em quickness . +.It Em Jabberwock may tire of battle, and leave after calling one of his friends -( -.B Jubjub Bird +.Em ( Jubjub Bird or -.B Bandersnatch -). -.TP 1.5i -.B Morgoth +.Em Bandersnatch ) . +.It Em Morgoth actually -.B Modnar -, but reserved for -.B council of the wise, valar, +.Em Modnar , +but reserved for +.Em council of the wise , valar , and -.B ex-valar. +.Em ex-valar . Fights with -.B Morgoth -end when either he or the player dies. His characteristics -are calculated based upon the player's. The player is given -the chance to ally with him. No magic, except -.B force field +.Em Morgoth +end when either he or the player dies. +His characteristics are calculated based upon the player's. +The player is given the chance to ally with him. +No magic, except +.Ic force field works when battling -.B Morgoth. -.TP 1.5i -.B Troll +.Em Morgoth . +.It Em Troll may regenerate its -.B energy +.Em energy and -.B strength +.Em strength while in battle. -.TP 1.5i -.B Wraith +.It Em Wraith may make a player blind. -.sh "Treasures" +.El +.Ss Treasures The various treasure types are as follows: -.TP 1.5i -.B Type zero -.I none -.TP 1.5i -.B Type one -.I power booster +.Bl -tag -width "type twelve/thirteen" +.It Type zero +none +.It Type one +.Em power booster \- adds mana. .br -.I druid +.Em druid \- adds experience. .br -.I holy orb +.Em holy orb \- subtracts 0.25 sin. .TP 1.5i -.B Type two -.I amulet +.It Type two +.Em amulet \- protects from cursed treasure. .br -.I holy water +.Em holy water \- kills -.B assorted faeries. +.Em assorted faeries . .br -.I hermit +.Em hermit \- reduces sin by 25% and adds some mana. -.TP 1.5i -.B Type three -.I shield +.It Type three +.Em shield \- adds to maximum -.B energy level +.Em energy level . .br -.I virgin +.Em virgin \- used to subdue a -.B unicorn -, or to give much -.B experience +.Em unicorn , +or to give much +.Em experience (and some -.B sin -). +.Em sin ) . .br -.I athelas +.Em athelas \- subtracts one -.B poison. -.TP 1.5i -.B Type four (scrolls) -.I shield +.Em poison . +.It Type four (scrolls) +.Em shield \- throws a bigger than normal -.B force field. +.Ic force field . .br -.I invisible +.Em invisible \- temporarily puts the finder's -.B quickness +.Em quickness to one million. .br -.I ten fold strength +.Em ten fold strength \- multiplies finder's strength by ten. .br -.I pick monster +.Em pick monster \- allows finder to pick next monster to battle. .br -.I general knowledge +.Em general knowledge \- adds to finder's -.B brains +.Em brains and -.B magic level. -.PP +.Em magic level . +.Pp All the scrolls except -.B general knowledge -automatically call a monster. These preserve any -spells that were already in effect, but are only in +.Em general knowledge +automatically call a monster. +These preserve any spells that were already in effect, but are only in effect while in battle. -.TP 1.5i -.B Type five -.I dagger +.It Type five +.Em dagger \- adds to -.B strength. +.Em strength . .br -.I armour +.Em armour \- same as a -.B shield, +.Em shield , but bigger. .br -.I tablet -\- adds brains. -.TP 1.5i -.B Type six -.I priest -\- rests to maximum; adds -.B mana, brains; -and halves -.B sin. -.br -.I Robin Hood -\- increases -.B shield -and adds permanently to -.B strength. -.br -.I axe -\- like -.B dagger, -but bigger. -.TP 1.5i -.B Type seven -.I charm -\- protects from cursed treasure (used before -.B amulet -); used in conjunction with -.B blessing -to battle -.B Dark Lord. -.br -.I Merlyn +.Em tablet \- adds -.B brains, magic, -and -.B mana. +.Em brains . +.It Type six +.Em priest +\- rests to maximum; adds +.Em mana , brains ; +and halves +.Em sin . .br -.I war hammer -\- like an -.B axe, +.Em Robin Hood +\- increases +.Em shield +and adds permanently to +.Em strength . +.br +.Em axe +\- like +.Em dagger , but bigger. -.TP 1.5i -.B Type eight -.I healing potion +.It Type seven +.Em charm +\- protects from cursed treasure (used before +.Em amulet ) ; +used in conjunction with +.Em blessing +to battle +.Em Dark Lord . +.br +.Em Merlyn +\- adds +.Em brains , magic , +and +.Em mana . +.br +.Em war hammer +\- like an +.Em axe , +but bigger. +.It Type eight +.Em healing potion \- sets -.B poison +.Em poison to -2, or subtracts two from -.B poison, +.Em poison , whichever is better. .br -.I transporter +.Em transporter \- allows finder to move anywhere. .br -.I sword +.Em sword \- like a -.B war hammer -, but bigger. -.TP 1.5i -.B Type nine -.I golden crown +.Em war hammer , +but bigger. +.It Type nine +.Em golden crown \- allows the player to become -.B king, +.Em king , by going to (0,0). .br -.I blessing +.Em blessing \- cuts -.B sin +.Em sin to 1/3, adds -.B mana, -rests to max., kills -.B Dark Lord +.Em mana , +rests to maximum, kills +.Em Dark Lord with a -.B charm, +.Em charm , and gives bearer first hit on all monsters. .br -.I quicksilver -\- adds to -.B quickness. -.TP 1.5i -.B Type ten -.I elven boots +.Em quicksilver +\- adds to +.Em quickness . +.It Type ten +.Em elven boots \- adds permanently to -.B quickness. -.TP 1.5i -.B Type eleven -.I palantir +.Em quickness . +.It Type eleven +.Em palantir \- allows one to see all the other players; used by -.B council of the wise +.Em council of the wise to seek the -.B grail. -.TP 1.5i -.B Type twelve/thirteen -.I ring +.Em grail . +.It Type twelve/thirteen +.Em ring \- allows one to hit much harder in battle, etc. -.PP +.El +.Pp Any treasure type 10-13 monsters may instead carry a type nine treasure. -.PP +.Pp A monster may also be carrying -.B gold +.Em gold or -.B gems. +.Em gems . These are used at -.B trading posts -to buy things. A -.B gem -is worth 1000 gold pieces. Too much -.B gold -will slow a player down. One may carry 1000 plus 200 per -.B level -of -.B gold. +.Em trading posts +to buy things. A -.B gem +.Em gem +is worth 1000 gold pieces. +Too much +.Em gold +will slow a player down. +One may carry 1000 plus 200 per +.Em level +of +.Em gold . +A +.Em gem weighs one half a gold piece. Monsters of treasure type 7 or higher may carry -.B gems. -.PP +.Em gems . +.Pp The chance of a cursed treasure is based upon treasure type. The more valuable treasures have a greater chance of being cursed. A cursed treasure knocks -.B energy level +.Em energy level very low, and adds 0.25 -.B poison. -.sh "Rings" -.B Rings +.Em poison . +.Ss Rings +.Em Rings are only carried by -.B nazguls +.Em nazguls and -.B Dark Lord. +.Em Dark Lords . They come in four different flavors. All -.B rings +.Em rings rest the player to maximum and cause him/her to hit much harder in battle with monsters (assuming one has chosen to use the -.B ring +.Em ring for battle.) -.PP +.Pp Two types of -.B rings +.Em rings are cursed and come either from -.B nazguls +.Em nazguls or -.B Dark Lord. +.Em Dark Lord . After a few times of using these types, the player falls under the control of the -.B ring, +.Em ring , and strange, random things will occur. Eventually, the player dies, and gives his/her name to a monster on the file. Dying before the -.B ring +.Em ring is used up also renames the monster. -.PP +.Pp The two remaining types of -.B rings +.Em rings are much more benign. The one from a -.B nazgul +.Em nazgul is good for a limited number of battle rounds, and will save the player from death if it was being used when he/she died. The one from -.B Dark Lord +.Em Dark Lord is the same, except that it never is used up. -.B rings +.Em rings disappear after saving someone from death. In general, cursed -.B rings +.Em rings occur much more often than normal ones. It is usually not a good idea to pick one up. The only way to get rid of a -.B ring +.Em ring is to have a monster steal it. -.sh "King" +.Ss King A player may become -.B king by finding a -.I crown -and going to (0,0). Players must have a -.B level +.Em king +by finding a +.Em crown +and going to (0,0). +Players must have a +.Em level in the range of 10 to 1000 to be able to find a -.I crown. +.Em crown . When a player with one or more -.I crowns +.Em crowns reaches -.B level +.Em level 1000, the -.I crowns +.Em crowns are converted to -.I gold. -.PP -Once a player is king, he/she may do certain things while in -the Lord's Chamber (0,0). These are exercised with the -.B decree +.Em gold . +.Pp +Once a player is king, he/she may do certain things while in +the Lord's Chamber (0,0). +These are exercised with the +.Ic decree ('0') option. -.TP 1.5i -.I transport -This is done to another player. It randomly moves the affected -player about. A -.B charm -protects from transports. -.TP 1.5i -.I curse -This is done to another player. It is analogous to cursed treasure, -but worse. It inflicts two -.B poison, -knocks -.B energy level -very low, and degrades the maximum energy. It also -removes a -.B cloak. +.Bl -tag -width "collect taxes" +.It Ic transport +This is done to another player. +It randomly moves the affected player about. A -.B blessing +.Em charm +protects from transports. +.It Ic curse +This is done to another player. +It is analogous to cursed treasure, but worse. +It inflicts two +.Em poison , +knocks +.Em energy level +very low, and degrades the maximum energy. +It also removes a +.Em cloak . +A +.Em blessing protects from king's curses. -.TP 1.5i -.I energy void +.It Ic energy void The king may put a number of these scattered about his/her kingdom as he/she pleases. If a player hits one, he/she loses -.B mana, energy, +.Em mana , energy , and -.B gold. +.Em gold . The energy void disappears after being hit. -.TP 1.5i -.I bestow -This is also done to another player. The king may -wish to reward one or more loyal subjects by sharing his/her -riches ( -.B gold -). Or it is a convenient way to dispose of some unwanted -deadweight. -.TP 1.5i -.I collect taxes +.It Ic bestow +This is also done to another player. +The king may wish to reward one or more loyal subjects by sharing his/her +riches +.Em ( gold ) . +Or it is a convenient way to dispose of some unwanted deadweight. +.It Ic collect taxes Everyone pays 7% tax on all -.B gold +.Em gold and -.B gems +.Em gems acquired, regardless of the existence of a -.B king. +.Em king . The king collects the accrued taxes with this option. -.PP +.El +.Pp The -.B king -may also -.B teleport +.Em king +may also +.Ic teleport anywhere for free by using the origin as a starting place. -.sh "Council of the Wise, Valar" -.pl +0.5 +.Ss Council of the Wise, Valar A player automatically becomes a member of the -.B council of the wise -upon reaching level 3000. Members of the council cannot have -.B rings. +.Em council of the wise +upon reaching level 3000. +Members of the council cannot have +.Em rings . Members of the council have a few extra options which they can exercise. -These are exercised -.B intervene +These are exercised with the +.Ic intervene ('8') option. All -.B intervene +.Ic intervene options cost 1000 mana. One -.B intervene +.Ic intervene option is to -.I heal -another player. This is just a quick way for that player to be rested +.Ic heal +another player. +This is just a quick way for that player to be rested to maximum and lose a little -.B poison. +.Em poison . The main purpose in life for members of the council is to seek the -.B Holy Grail. +.Em Holy Grail . This is done with a -.B palantir +.Em palantir under the -.I seek grail -option. The distance cited by the seek is accurate within 10%, in order +.Ic seek grail +option. +The distance cited by the seek is accurate within 10%, in order not to make it too easy to find the grail. A player must have infinitesimally small -.B sin, +.Em sin , or else it's all over upon finding the grail. In order to help members of the council on their quest, they may -.I teleport +.Ic teleport with greater ease. -.pl -0.5 -.sp 1 -.fM -.ne 1i -.PP +.Pp Upon finding the grail, the player advances to position of -.B valar. +.Em valar . He/she may then exercise more and niftier options under -.I intervention. +.Ic intervention . These include all of the council members' options plus the ability to move other players about, bless them, and throw monsters at them. A -.BR valar 's +.Em valar Ns 's blessing has the same effect as the treasure -.I blessing, +.Em blessing , except that the affected player does not get his/her -.I blessing +.Em blessing flag set. All -.I intervention -options which affect other players age the player -who uses them. -.B Valars +.Ic intervention +options which affect other players age the player who uses them. +.Em Valars are essentially immortal, but are actually given five lives. If these are used up, the player is left to die, and becomes an -.B ex-valar. -A -.B valar +.Em ex-valar . +A +.Em valar cannot -.I move, teleport, +.Ic move , teleport , or call monsters. (An exception to this is if the -.I valar +.Em valar finds a -.I transporter. +.Em transporter . ) This is to allow him/her to dispose of excess -.I gold. +.Em gold . Any monsters which a -.B valar +.Em valar encounters are based upon his/her size. Only one valar may exist at a time. The current valar is replaced when another player finds the grail. The valar is then bumped back to the council of the wise. -.sh "Wizard" +.Ss Wizard The -.I wizard +.Em wizard is usually the owner of the game, and the one who maintains the associated files. The -.I wizard +.Em wizard is granted special powers within the game, if it is invoked -with the '\-S' option. +with the +.Fl S +option. Otherwise, the -.I wizard +.Em wizard plays no different from other players. The -.I wizard +.Em wizard abilities are outlined below. -.TP -.I change players -When examining a player, (game invoked with '-x', or use 'X' from within game), -the -.I wizard +.Bl -tag -width "super character type" +.It Ic change players +When examining a player, (game invoked with +.Fl x , +or use 'X' from within game), the +.Em wizard may also change the player. -.TP -.I intervention +.It Ic intervention The -.I wizard +.Em wizard may do all the -.I intervention -options. One extra option, -.I vaporize, +.Ic intervention +options. +One extra option, +.Ic vaporize , is added to kill any offensive players. -.TP -.I super character type -An extra character type is added. This character starts with the +.It Ic super character type +An extra character type is added. +This character starts with the maximum possible in all statistics, selected from the other character types. A -.B super +.Em super character's statistics also progress at the maximum possible rate, selected from the other character types. -.sh "Special Places" +.El +.Ss Special Places Certain regions of the playing grid have different names. In general, this is only to give the player some idea of -his/her present location. Some special places do exist. -.TP 1.5i -.I Trading Posts -These are located at |x| == |y| == n*n*100 for n = 1, 2...1000. +his/her present location. +Some special places do exist. +.Bl -tag -width "Trading Posts" +.It Em Trading Posts +These are located at |x| == |y| == n*n*100 for n = 1, 2, ..., 1000. Trading posts farther out have more things for sale. -Be careful about cheating the merchants there, as they have short -tempers. +Be careful about cheating the merchants there, as they have short tempers. Merchants are dishonest about 5% of the time. -.TP 1.5i -.I Lord's Chamber -This is located at (0,0). Only players with -.B crowns +.It Em Lord's Chamber +This is located at (0,0). +Only players with +.Em crowns may enter. -.TP 1.5i -.I Point of No Return +.It Em Point of \&No Return This is located beyond 1.2e+6 in any direction. The only way to return from here is a -.B transporter +.Em transporter or to have a -.B valar +.Em valar relocate the player. -.TP 1.5i -.I Dead Marshes -This is a band located fairly distant from the origin. The first -fourteen monsters (water monsters) can normally only be found here. -.TP 1.5i -.I Valhala +.It Em Dead Marshes +This is a band located fairly distant from the origin. +The first fourteen monsters (water monsters) can normally only be found here. +.It Em Valhala This place is where the -.B valar -resides. It is associated with no particular coordinate on the -playing grid. -.sh "Miscellaneous" +.Em valar +resides. +It is associated with no particular coordinate on the playing grid. +.El +.Ss Miscellaneous Once a player reaches -.B level +.Em level 5, the game will start to time out waiting for input. This is to try to keep the game a bit faster paced. -.PP +.Pp A -.I guru +.Em guru will never be disgusted with your -.B sins +.Em sins if they are less than one. -.PP +.Pp A -.I medic +.Em medic wants half of a player's -.B gold -to be happy. Offering more than one has, or a negative amount -will anger the -.I medic, +.Em gold +to be happy. +Offering more than one has, or a negative amount will anger the +.Em medic , who will make the player worse (add one -.B poison -). -.PP +.Em poison ) . +.Pp The -.B Holy Grail +.Em Holy Grail does little for those who are not ready to behold it. Whenever anyone finds it, it moves. It is always located within 1e+6 in any compass direction of the origin. -.PP +.Pp There is a maximum amount of -.B mana +.Em mana and -.B charms +.Em charms a player may posses, based upon -.B level. -.I Quicksilver +.Em level . +.Em Quicksilver is always limited to to a maximum of 99. -.PP -.I Books +.Pp +.Em Books bought at a -.B trading post -increase -.B brains, +.Em trading post +increase +.Em brains , based upon the number bought. It is unwise, however to buy more than 1/10 of one's -.B level +.Em level in books at a time. -.PP +.Pp Players over level 10000 are automatically retired. -.PP +.Pp A -.I blindness +.Em blindness goes away in random time. -.PP +.Pp Players with -.I crowns +.Em crowns are identified with a '*' before their character type. -.sh "Inter-terminal Battle" +.Ss Inter-terminal Battle When two player's coordinates correspond, they may engage in battle. In general, the player with the highest -.B quickness +.Em quickness gets the first hit. -If the two players are severely mis-matched, the stronger player +If the two players are severely mismatched, the stronger player is drastically handicapped for the battle. In order to protect from being stuck in an infinite loop, -the player waiting for response may time out. Options for battle are: -.TP 1.5i -.I fight +the player waiting for response may time out. +Options for battle are: +.Bl -tag -width "power blast" +.It Ic fight Inflicts damage upon other person. -.TP 1.5i -.I run away -Escape from battle. Has a 75% chance of working. -.TP 1.5i -.I power blast +.It Ic run away +Escape from battle. +Has a 75% chance of working. +.It Ic power blast Battle spell. -.TP 1.5i -.I luckout -One-time chance to try to win against the foe. Has a 10% chance of working. -.PP +.It Ic luckout +One-time chance to try to win against the foe. +Has a 10% chance of working. +.El +.Pp Sometimes waits for the other player may be excessive, because -he/she may be battling a monster. Upon slaying a player in battle -the winner gets the other's -.B experience +he/she may be battling a monster. +Upon slaying a player in battle the winner gets the other's +.Em experience and treasures. -.B Rings +.Em Rings do not work for inter-terminal battle. -.SH BUGS +.Sh BUGS All screen formats assume at least 24 lines by at least 80 columns. No provisions are made for when any of the data items get too big for the allotted space on the screen. diff --git a/phantasia/phantdefs.h b/phantasia/phantdefs.h index 9bb83f7..0f3e078 100644 --- a/phantasia/phantdefs.h +++ b/phantasia/phantdefs.h @@ -1,4 +1,4 @@ -/* $NetBSD: phantdefs.h,v 1.2 1995/03/24 03:59:28 cgd Exp $ */ +/* $NetBSD: phantdefs.h,v 1.4 2001/09/16 16:34:25 wiz Exp $ */ /* * phantdefs.h - important constants for Phantasia @@ -28,7 +28,7 @@ #define S_INBATTLE 4 /* playing - in battle */ #define S_MONSTER 5 /* playing - fighting monster */ #define S_TRADING 6 /* playing - at a trading post */ -#define S_HUNGUP 7 /* error occured with character */ +#define S_HUNGUP 7 /* error occurred with character */ /* tampered constants */ #define T_OFF 0 /* nothing */ diff --git a/phantasia/phantglobs.c b/phantasia/phantglobs.c index 399de14..5876988 100644 --- a/phantasia/phantglobs.c +++ b/phantasia/phantglobs.c @@ -1,4 +1,4 @@ -/* $NetBSD: phantglobs.c,v 1.4 1998/07/27 01:12:35 mycroft Exp $ */ +/* $NetBSD: phantglobs.c,v 1.5 1999/09/08 21:17:54 jsm Exp $ */ /* * phantglobs.c - globals for Phantasia @@ -30,7 +30,7 @@ jmp_buf Timeoenv; /* used for timing out waiting for input */ long Fileloc; /* location in file of player statistics */ const char *Login; /* pointer to login of player */ -char *Enemyname; /* pointer name of monster/player we are battling*/ +const char *Enemyname; /* pointer name of monster/player we are battling*/ struct player Player; /* stats for player */ struct player Other; /* stats for another player */ @@ -39,10 +39,10 @@ struct monster Curmonster;/* stats for current monster */ struct energyvoid Enrgyvoid;/* energy void buffer */ -struct charstats *Statptr;/* pointer into Stattable[] */ +const struct charstats *Statptr;/* pointer into Stattable[] */ /* lookup table for character type dependent statistics */ -struct charstats Stattable[7] = { +const struct charstats Stattable[7] = { /* MAGIC USER */ { 15.0, 200.0, 18.0, 175.0, 10, @@ -92,7 +92,7 @@ struct charstats Stattable[7] = { }; /* menu of items for purchase */ -struct menuitem Menu[] = { +const struct menuitem Menu[] = { {"Mana", 1}, {"Shield", 5}, {"Book", 200}, @@ -110,9 +110,9 @@ FILE *Energyvoidfp; /* pointer to open energy void file */ char Databuf[SZ_DATABUF]; /* a place to read data into */ /* some canned strings for messages */ -char Illcmd[] = "Illegal command.\n"; -char Illmove[] = "Too far.\n"; -char Illspell[] = "Illegal spell.\n"; -char Nomana[] = "Not enought mana for that spell.\n"; -char Somebetter[] = "But you already have something better.\n"; -char Nobetter[] = "That's no better than what you already have.\n"; +const char Illcmd[] = "Illegal command.\n"; +const char Illmove[] = "Too far.\n"; +const char Illspell[] = "Illegal spell.\n"; +const char Nomana[] = "Not enought mana for that spell.\n"; +const char Somebetter[] = "But you already have something better.\n"; +const char Nobetter[] = "That's no better than what you already have.\n"; diff --git a/phantasia/phantglobs.h b/phantasia/phantglobs.h index 00077e5..46e16e5 100644 --- a/phantasia/phantglobs.h +++ b/phantasia/phantglobs.h @@ -1,4 +1,4 @@ -/* $NetBSD: phantglobs.h,v 1.5 1998/07/27 01:12:35 mycroft Exp $ */ +/* $NetBSD: phantglobs.h,v 1.8 2001/02/05 01:01:27 christos Exp $ */ /* * phantglobs.h - global declarations for Phantasia @@ -28,7 +28,7 @@ extern jmp_buf Timeoenv; /* used for timing out waiting for input */ extern long Fileloc; /* location in file of player statistics */ extern const char *Login; /* pointer to login of current player */ -extern char *Enemyname; /* pointer name of monster/player we are battling*/ +extern const char *Enemyname; /* pointer name of monster/player we are battling*/ extern struct player Player; /* stats for player */ extern struct player Other; /* stats for another player */ @@ -37,11 +37,11 @@ extern struct monster Curmonster;/* stats for current monster */ extern struct energyvoid Enrgyvoid;/* energy void buffer */ -extern struct charstats Stattable[];/* used for rolling and changing player stats*/ +extern const struct charstats Stattable[];/* used for rolling and changing player stats*/ -extern struct charstats *Statptr;/* pointer into Stattable[] */ +extern const struct charstats *Statptr;/* pointer into Stattable[] */ -extern struct menuitem Menu[]; /* menu of items for purchase */ +extern const struct menuitem Menu[]; /* menu of items for purchase */ extern FILE *Playersfp; /* pointer to open player file */ extern FILE *Monstfp; /* pointer to open monster file */ @@ -51,18 +51,18 @@ extern FILE *Energyvoidfp; /* pointer to open energy void file */ extern char Databuf[]; /* a place to read data into */ /* some canned strings for messages */ -extern char Illcmd[]; -extern char Illmove[]; -extern char Illspell[]; -extern char Nomana[]; -extern char Somebetter[]; -extern char Nobetter[]; +extern const char Illcmd[]; +extern const char Illmove[]; +extern const char Illspell[]; +extern const char Nomana[]; +extern const char Somebetter[]; +extern const char Nobetter[]; /* functions which we need to know about */ -char *descrlocation __P((struct player *, bool)); -char *descrstatus __P((struct player *)); -char *descrtype __P((struct player *, bool)); +const char *descrlocation __P((struct player *, bool)); +const char *descrstatus __P((struct player *)); +const char *descrtype __P((struct player *, bool)); void activelist __P((void)); void adjuststats __P((void)); long allocrecord __P((void)); @@ -73,26 +73,26 @@ void awardtreasure __P((void)); void battleplayer __P((long)); void callmonster __P((int)); void cancelmonster __P((void)); -void catchalarm __P((int)); +void catchalarm __P((int)) __attribute__((__noreturn__)); void changestats __P((bool)); void checkbattle __P((void)); void checktampered __P((void)); void cleanup __P((int)); void collecttaxes __P((double, double)); void cursedtreasure __P((void)); -void death __P((char *)); +void death __P((const char *)); void displaystats __P((void)); double distance __P((double, double, double, double)); void dotampered __P((void)); double drandom __P((void)); void encounter __P((int)); void enterscore __P((void)); -void error __P((char *)); +void error __P((const char *)); double explevel __P((double)); -long findname __P((char *, struct player *)); +long findname __P((const char *, struct player *)); void freerecord __P((struct player *, long)); void genchar __P((int)); -int getanswer __P((char *, bool)); +int getanswer __P((const char *, bool)); void getstring __P((char *, int)); void hitmonster __P((double)); void ill_sig __P((int)); @@ -116,7 +116,6 @@ void purgeoldplayers __P((void)); void readmessage __P((void)); void readrecord __P((struct player *, long)); long recallplayer __P((void)); -long recallplayer __P((void)); long rollnewplayer __P((void)); void scorelist __P((void)); void scramblestats __P((void)); diff --git a/phantasia/phantstruct.h b/phantasia/phantstruct.h index c7ada22..948bb23 100644 --- a/phantasia/phantstruct.h +++ b/phantasia/phantstruct.h @@ -1,4 +1,4 @@ -/* $NetBSD: phantstruct.h,v 1.2 1995/03/24 04:00:11 cgd Exp $ */ +/* $NetBSD: phantstruct.h,v 1.3 1999/09/08 21:17:55 jsm Exp $ */ /* * phantstruct.h - structure definitions for Phantasia @@ -121,6 +121,6 @@ struct charstats /* character type statistics */ struct menuitem /* menu item for purchase */ { - char *item; /* menu item name */ + const char *item; /* menu item name */ double cost; /* cost of item */ }; diff --git a/pig/Makefrag b/pig/Makefrag index 4b48fa8..7f6e30d 100644 --- a/pig/Makefrag +++ b/pig/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for pig +# +# Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. pig_DIRS := $(GAMESDIR) $(MAN6DIR) @@ -8,6 +34,3 @@ pig_install: pig_all $(INSTALL_BINARY) pig/pig $(INSTALL_PREFIX)$(GAMESDIR)/pig $(HIDE_GAME) pig $(INSTALL_MANUAL) pig/pig.6 - -pig_check: pig_all - echo "This is a test" |pig/pig diff --git a/pig/pig.6 b/pig/pig.6 index b25cb0a..ad70594 100644 --- a/pig/pig.6 +++ b/pig/pig.6 @@ -43,7 +43,7 @@ .Nm .Sh DESCRIPTION Ethay -.Nm +.Nm igpay utilityway eadsray ethay andardstay inputway andway iteswray itway outway otay andardstay outputway inway Igpay Atinlay. .Pp diff --git a/pig/pig.c b/pig/pig.c index aa25718..a21d2fb 100644 --- a/pig/pig.c +++ b/pig/pig.c @@ -1,4 +1,4 @@ -/* $NetBSD: pig.c,v 1.7 1998/09/13 15:27:29 hubertf Exp $ */ +/* $NetBSD: pig.c,v 1.8 1999/09/18 19:38:53 jsm Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\ #if 0 static char sccsid[] = "@(#)pig.c 8.2 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: pig.c,v 1.7 1998/09/13 15:27:29 hubertf Exp $"); +__RCSID("$NetBSD: pig.c,v 1.8 1999/09/18 19:38:53 jsm Exp $"); #endif #endif /* not lint */ diff --git a/pom/Makefrag b/pom/Makefrag index 99feed1..77e92d5 100644 --- a/pom/Makefrag +++ b/pom/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for pom +# +# Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. pom_DIRS := $(GAMESDIR) $(MAN6DIR) @@ -8,6 +34,3 @@ pom_install: pom_all $(INSTALL_BINARY) pom/pom $(INSTALL_PREFIX)$(GAMESDIR)/pom $(HIDE_GAME) pom $(INSTALL_MANUAL) pom/pom.6 - -pom_check: pom_all - pom/pom diff --git a/pom/pom.6 b/pom/pom.6 index 4a4ce04..bc3d530 100644 --- a/pom/pom.6 +++ b/pom/pom.6 @@ -1,4 +1,4 @@ -.\" $NetBSD: pom.6,v 1.6 1998/06/13 01:09:22 jeremy Exp $ +.\" $NetBSD: pom.6,v 1.11 2002/09/26 18:32:03 wiz Exp $ .\" .\" Copyright (c) 1989, 1993 .\" The Regents of the University of California. All rights reserved. @@ -33,29 +33,43 @@ .\" .\" @(#)pom.6 8.1 (Berkeley) 5/31/93 .\" -.Dd May 31, 1993 +.Dd January 9, 1999 .Dt POM 6 .Os .Sh NAME -.Nm pom +.Nm pom .Nd display the phase of the moon .Sh SYNOPSIS .Nm -.Op Ar secs +.Op [[[[[cc]yy]mm]dd]HH] .Sh DESCRIPTION The .Nm utility displays the current phase of the moon. -Useful for selecting software completion target dates and predicting +Useful for selecting software completion target dates and predicting managerial behavior. .Pp -.Bl -tag -width secs -.It Ar secs -Display the phase of the moon for the date represented by -.Ar secs -seconds past the Epoch -(Midnight, January 1, 1970 GMT). -If -.Ar secs -is unspecified, the current time is used. +.Bl -tag -width [[[[[cc]yy]mm]dd]HH] +.It Ar [[[[[cc]yy]mm]dd]HH] +Display the phase of the moon for a given time. +The format is similar to the canonical representation used by +.Xr date 1 . .El +.Sh SEE ALSO +.Xr date 1 +.Sh AUTHOR +.Nm +was written by +.An Keith E. Brandt . +.Sh BUGS +Times must be within range of the +.Ux +epoch. +.Pp +This program does not allow for the difference between the TDT and +UTC timescales (about one minute at the time of writing). +.Sh ACKNOWLEDGEMENTS +This program is based on algorithms from +.%B Practical Astronomy with Your Calculator, Third Edition +by Peter Duffett-Smith +.Aq pjds@mrao.cam.ac.uk . diff --git a/pom/pom.c b/pom/pom.c index 4c9eced..5a72d5f 100644 --- a/pom/pom.c +++ b/pom/pom.c @@ -1,4 +1,4 @@ -/* $NetBSD: pom.c,v 1.11 1998/09/11 14:07:04 hubertf Exp $ */ +/* $NetBSD: pom.c,v 1.12 1999/09/14 20:00:07 jsm Exp $ */ /* * Copyright (c) 1989, 1993 @@ -45,7 +45,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\ #if 0 static char sccsid[] = "@(#)pom.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: pom.c,v 1.11 1998/09/11 14:07:04 hubertf Exp $"); +__RCSID("$NetBSD: pom.c,v 1.12 1999/09/14 20:00:07 jsm Exp $"); #endif #endif /* not lint */ @@ -57,64 +57,74 @@ __RCSID("$NetBSD: pom.c,v 1.11 1998/09/11 14:07:04 hubertf Exp $"); * * -- Keith E. Brandt VIII 1984 * + * Updated to the Third Edition of Duffett-Smith's book, Paul Janzen, IX 1998 + * */ -#include +#include #include -#include #include #include #include #include -#include +#include #include #ifndef PI #define PI 3.14159265358979323846 #endif -#define EPOCH 85 /* really 1985 */ -#define EPSILONg 279.611371 /* solar ecliptic long at EPOCH */ -#define RHOg 282.680403 /* solar ecliptic long of perigee at EPOCH */ -#define ECCEN 0.01671542 /* solar orbit eccentricity */ -#define lzero 18.251907 /* lunar mean long at EPOCH */ -#define Pzero 192.917585 /* lunar mean long of perigee at EPOCH */ -#define Nzero 55.204723 /* lunar mean long of node at EPOCH */ + +/* + * The EPOCH in the third edition of the book is 1990 Jan 0.0 TDT. + * In this program, we do not bother to correct for the differences + * between UTC (as shown by the UNIX clock) and TDT. (TDT = TAI + 32.184s; + * TAI-UTC = 32s in Jan 1999.) + */ +#define EPOCH_MINUS_1970 (20 * 365 + 5 - 1) /* 20 years, 5 leaps, back 1 day to Jan 0 */ +#define EPSILONg 279.403303 /* solar ecliptic long at EPOCH */ +#define RHOg 282.768422 /* solar ecliptic long of perigee at EPOCH */ +#define ECCEN 0.016713 /* solar orbit eccentricity */ +#define lzero 318.351648 /* lunar mean long at EPOCH */ +#define Pzero 36.340410 /* lunar mean long of perigee at EPOCH */ +#define Nzero 318.510107 /* lunar mean long of node at EPOCH */ void adj360 __P((double *)); double dtor __P((double)); int main __P((int, char *[])); double potm __P((double)); +time_t parsetime __P((char *)); +void badformat __P((void)) __attribute__((__noreturn__)); int main(argc, argv) int argc; char *argv[]; { - struct timeval tp; - struct timezone tzp; - struct tm *GMT; - time_t tmpt; + time_t tmpt, now; double days, today, tomorrow; - int cnt; + char buf[1024]; /* Revoke setgid privileges */ setregid(getgid(), getgid()); + if (time(&now) == (time_t)-1) + err(1, "time"); if (argc > 1) { - tp.tv_sec = atoi(argv[1]); - tp.tv_usec = 0; + tmpt = parsetime(argv[1]); + strftime(buf, sizeof(buf), "%a %Y %b %e %H:%M:%S (%Z)", + localtime(&tmpt)); + printf("%s: ", buf); } else { - if (gettimeofday(&tp,&tzp)) - err(1, "gettimeofday"); + tmpt = now; } - tmpt = tp.tv_sec; - GMT = gmtime(&tmpt); - days = (GMT->tm_yday + 1) + ((GMT->tm_hour + - (GMT->tm_min / 60.0) + (GMT->tm_sec / 3600.0)) / 24.0); - for (cnt = EPOCH; cnt < GMT->tm_year; ++cnt) - days += isleap(cnt + 1900) ? 366 : 365; + days = (tmpt - EPOCH_MINUS_1970 * 86400) / 86400.0; today = potm(days) + .5; - (void)printf("The Moon is "); + if (tmpt < now) + (void)printf("The Moon was "); + else if (tmpt == now) + (void)printf("The Moon is "); + else + (void)printf("The Moon will be "); if ((int)today == 100) (void)printf("Full\n"); else if (!(int)today) @@ -124,7 +134,11 @@ main(argc, argv) if ((int)today == 50) (void)printf("%s\n", tomorrow > today ? "at the First Quarter" : "at the Last Quarter"); + /* today is 0.5 too big, but it doesn't matter here + * since the phase is changing fast enough + */ else { + today -= 0.5; /* Now it might matter */ (void)printf("%s ", tomorrow > today ? "Waxing" : "Waning"); if (today > 50) @@ -149,30 +163,30 @@ potm(days) double N, Msol, Ec, LambdaSol, l, Mm, Ev, Ac, A3, Mmprime; double A4, lprime, V, ldprime, D, Nm; - N = 360 * days / 365.2422; /* sec 42 #3 */ + N = 360 * days / 365.242191; /* sec 46 #3 */ adj360(&N); - Msol = N + EPSILONg - RHOg; /* sec 42 #4 */ + Msol = N + EPSILONg - RHOg; /* sec 46 #4 */ adj360(&Msol); - Ec = 360 / PI * ECCEN * sin(dtor(Msol)); /* sec 42 #5 */ - LambdaSol = N + Ec + EPSILONg; /* sec 42 #6 */ + Ec = 360 / PI * ECCEN * sin(dtor(Msol)); /* sec 46 #5 */ + LambdaSol = N + Ec + EPSILONg; /* sec 46 #6 */ adj360(&LambdaSol); - l = 13.1763966 * days + lzero; /* sec 61 #4 */ + l = 13.1763966 * days + lzero; /* sec 65 #4 */ adj360(&l); - Mm = l - (0.1114041 * days) - Pzero; /* sec 61 #5 */ + Mm = l - (0.1114041 * days) - Pzero; /* sec 65 #5 */ adj360(&Mm); - Nm = Nzero - (0.0529539 * days); /* sec 61 #6 */ + Nm = Nzero - (0.0529539 * days); /* sec 65 #6 */ adj360(&Nm); - Ev = 1.2739 * sin(dtor(2*(l - LambdaSol) - Mm)); /* sec 61 #7 */ - Ac = 0.1858 * sin(dtor(Msol)); /* sec 61 #8 */ + Ev = 1.2739 * sin(dtor(2*(l - LambdaSol) - Mm)); /* sec 65 #7 */ + Ac = 0.1858 * sin(dtor(Msol)); /* sec 65 #8 */ A3 = 0.37 * sin(dtor(Msol)); - Mmprime = Mm + Ev - Ac - A3; /* sec 61 #9 */ - Ec = 6.2886 * sin(dtor(Mmprime)); /* sec 61 #10 */ - A4 = 0.214 * sin(dtor(2 * Mmprime)); /* sec 61 #11 */ - lprime = l + Ev + Ec - Ac + A4; /* sec 61 #12 */ - V = 0.6583 * sin(dtor(2 * (lprime - LambdaSol))); /* sec 61 #13 */ - ldprime = lprime + V; /* sec 61 #14 */ - D = ldprime - LambdaSol; /* sec 63 #2 */ - return(50 * (1 - cos(dtor(D)))); /* sec 63 #3 */ + Mmprime = Mm + Ev - Ac - A3; /* sec 65 #9 */ + Ec = 6.2886 * sin(dtor(Mmprime)); /* sec 65 #10 */ + A4 = 0.214 * sin(dtor(2 * Mmprime)); /* sec 65 #11 */ + lprime = l + Ev + Ec - Ac + A4; /* sec 65 #12 */ + V = 0.6583 * sin(dtor(2 * (lprime - LambdaSol))); /* sec 65 #13 */ + ldprime = lprime + V; /* sec 65 #14 */ + D = ldprime - LambdaSol; /* sec 67 #2 */ + return(50.0 * (1 - cos(dtor(D)))); /* sec 67 #3 */ } /* @@ -202,3 +216,74 @@ adj360(deg) else break; } + +#define ATOI2(ar) ((ar)[0] - '0') * 10 + ((ar)[1] - '0'); (ar) += 2; +time_t +parsetime(p) + char *p; +{ + struct tm *lt; + int bigyear; + int yearset = 0; + time_t tval; + unsigned char *t; + + for (t = (unsigned char *)p; *t; ++t) { + if (isdigit(*t)) + continue; + badformat(); + } + + tval = time(NULL); + lt = localtime(&tval); + lt->tm_sec = 0; + lt->tm_min = 0; + + switch (strlen(p)) { + case 10: /* yyyy */ + bigyear = ATOI2(p); + lt->tm_year = bigyear * 100 - 1900; + yearset = 1; + /* FALLTHROUGH */ + case 8: /* yy */ + if (yearset) { + lt->tm_year += ATOI2(p); + } else { + lt->tm_year = ATOI2(p); + if (lt->tm_year < 69) /* hack for 2000 */ + lt->tm_year += 100; + } + /* FALLTHROUGH */ + case 6: /* mm */ + lt->tm_mon = ATOI2(p); + if ((lt->tm_mon > 12) || !lt->tm_mon) + badformat(); + --lt->tm_mon; /* time struct is 0 - 11 */ + /* FALLTHROUGH */ + case 4: /* dd */ + lt->tm_mday = ATOI2(p); + if ((lt->tm_mday > 31) || !lt->tm_mday) + badformat(); + /* FALLTHROUGH */ + case 2: /* HH */ + lt->tm_hour = ATOI2(p); + if (lt->tm_hour > 23) + badformat(); + break; + default: + badformat(); + } + /* The calling code needs a valid tm_ydays and this is the easiest + * way to get one */ + if ((tval = mktime(lt)) == -1) + errx(1, "specified date is outside allowed range"); + return (tval); +} + +void +badformat() +{ + warnx("illegal time format"); + (void)fprintf(stderr, "usage: pom [[[[[cc]yy]mm]dd]HH]\n"); + exit(1); +} diff --git a/ppt/Makefile.bsd b/ppt/Makefile.bsd index 580a7c1..800c6a2 100644 --- a/ppt/Makefile.bsd +++ b/ppt/Makefile.bsd @@ -1,9 +1,10 @@ -# $NetBSD: Makefile,v 1.3 1995/03/23 08:35:38 cgd Exp $ +# $NetBSD: Makefile,v 1.6 2002/09/18 06:16:41 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 -PROG= ppt -NOMAN= noman -HIDEGAME=hidegame +NOMAN= # defined + +PROG= ppt +HIDEGAME= hidegame .include diff --git a/ppt/Makefrag b/ppt/Makefrag index 669e7d7..626529f 100644 --- a/ppt/Makefrag +++ b/ppt/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for ppt +# +# Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. ppt_DIRS := $(GAMESDIR) $(MAN6DIR) @@ -8,6 +34,3 @@ ppt_install: ppt_all $(INSTALL_BINARY) ppt/ppt $(INSTALL_PREFIX)$(GAMESDIR)/ppt $(HIDE_GAME) ppt $(INSTALL_MANUAL) bcd.6 ppt.6 - -ppt_check: ppt_all - date | ppt/ppt diff --git a/ppt/ppt.c b/ppt/ppt.c index e6d0a4b..c3302ae 100644 --- a/ppt/ppt.c +++ b/ppt/ppt.c @@ -1,4 +1,4 @@ -/* $NetBSD: ppt.c,v 1.5 1997/10/10 16:48:39 lukem Exp $ */ +/* $NetBSD: ppt.c,v 1.14 2002/11/26 23:07:36 atatat Exp $ */ /* * Copyright (c) 1988, 1993 @@ -43,35 +43,94 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1993\n\ #if 0 static char sccsid[] = "@(#)ppt.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: ppt.c,v 1.5 1997/10/10 16:48:39 lukem Exp $"); +__RCSID("$NetBSD: ppt.c,v 1.14 2002/11/26 23:07:36 atatat Exp $"); #endif #endif /* not lint */ +#include #include +#include +#include #include +#define EDGE "___________" + + void usage __P((void)); int main __P((int, char *[])); static void putppt __P((int)); + int getppt __P((const char *)); + +void +usage(void) +{ + extern char *__progname; + fprintf(stderr, "usage: %s [-d] [string ...]\n", __progname); + exit(1); +} int main(argc, argv) int argc; char **argv; { - int c; - char *p; + char *p, buf[132]; + int c, start, neednl, dflag; /* Revoke setgid privileges */ setregid(getgid(), getgid()); - (void) puts("___________"); - if (argc > 1) - while ((p = *++argv) != NULL) - for (; *p; ++p) - putppt((int)*p); - else while ((c = getchar()) != EOF) - putppt(c); - (void) puts("___________"); + dflag = 0; + while ((c = getopt(argc, argv, "dh")) != -1) + switch(c) { + case 'd': + dflag = 1; + break; + case 'h': + case '?': + default: + usage(); + } + argc -= optind; + argv += optind; + + if (dflag) { + if (argc > 0) + usage(); + + start = 0; + neednl = 0; + while (fgets(buf, sizeof(buf), stdin) != NULL) { + c = getppt(buf); + if (c < 0) { + if (start) { + /* lost sync? */ + if (neednl) + putchar('\n'); + exit(0); + } else + continue; + } + start = 1; + putchar(c); + neednl = (c != '\n'); + } + if (!feof(stdin)) + err(1, "fgets"); + if (neednl) + putchar('\n'); + } else { + (void) puts(EDGE); + if (argc > 0) + while ((p = *argv++)) { + for (; *p; ++p) + putppt((int)*p); + if ((*(argv))) + putppt((int)' '); + } + else while ((c = getchar()) != EOF) + putppt(c); + (void) puts(EDGE); + } exit(0); } @@ -93,3 +152,33 @@ putppt(c) (void) putchar('|'); (void) putchar('\n'); } + +int +getppt(const char *buf) +{ + const char *p = strchr(buf, '.'); + int c; + + if (p == NULL) + return (-1); + + c = 0; + if (p[ 3] != ' ') + c |= 0001; + if (p[ 2] != ' ') + c |= 0002; + if (p[ 1] != ' ') + c |= 0004; + if (p[-1] != ' ') + c |= 0010; + if (p[-2] != ' ') + c |= 0020; + if (p[-3] != ' ') + c |= 0040; + if (p[-4] != ' ') + c |= 0100; + if (p[-5] != ' ') + c |= 0200; + + return (c); +} diff --git a/primes/Makefile.bsd b/primes/Makefile.bsd index 0a6747f..2947e41 100644 --- a/primes/Makefile.bsd +++ b/primes/Makefile.bsd @@ -1,10 +1,11 @@ -# $NetBSD: Makefile,v 1.3 1995/03/23 08:35:43 cgd Exp $ +# $NetBSD: Makefile,v 1.6 2002/09/18 06:16:41 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 -PROG= primes -SRCS= pattern.c pr_tbl.c primes.c -NOMAN= noman -DPADD= ${LIBM} -LDADD= -lm +NOMAN= # defined + +PROG= primes +SRCS= pattern.c pr_tbl.c primes.c +DPADD= ${LIBM} +LDADD= -lm .include diff --git a/primes/Makefrag b/primes/Makefrag index 22fad9a..f5444ea 100644 --- a/primes/Makefrag +++ b/primes/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for primes +# +# Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. primes_DEFS := -D_GNU_SOURCE primes_DIRS := $(GAMESDIR) $(MAN6DIR) @@ -9,6 +35,3 @@ primes_install: primes_all $(INSTALL_BINARY) primes/primes $(INSTALL_PREFIX)$(GAMESDIR)/primes $(HIDE_GAME) primes $(INSTALL_MANUAL) factor.6 primes.6 - -primes_check: primes_all - primes/primes 100 200 diff --git a/primes/pattern.c b/primes/pattern.c index 82a8ae9..d960a39 100644 --- a/primes/pattern.c +++ b/primes/pattern.c @@ -1,4 +1,4 @@ -/* $NetBSD: pattern.c,v 1.4 1997/10/12 01:04:43 lukem Exp $ */ +/* $NetBSD: pattern.c,v 1.5 1999/09/08 21:17:55 jsm Exp $ */ /* * Copyright (c) 1989, 1993 @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)pattern.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: pattern.c,v 1.4 1997/10/12 01:04:43 lukem Exp $"); +__RCSID("$NetBSD: pattern.c,v 1.5 1999/09/08 21:17:55 jsm Exp $"); #endif #endif /* not lint */ diff --git a/primes/pr_tbl.c b/primes/pr_tbl.c index db9b361..f743cf5 100644 --- a/primes/pr_tbl.c +++ b/primes/pr_tbl.c @@ -1,4 +1,4 @@ -/* $NetBSD: pr_tbl.c,v 1.4 1997/10/12 01:04:50 lukem Exp $ */ +/* $NetBSD: pr_tbl.c,v 1.6 2001/01/20 15:06:34 itojun Exp $ */ /* * Copyright (c) 1989, 1993 @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)pr_tbl.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: pr_tbl.c,v 1.4 1997/10/12 01:04:50 lukem Exp $"); +__RCSID("$NetBSD: pr_tbl.c,v 1.6 2001/01/20 15:06:34 itojun Exp $"); #endif #endif /* not lint */ @@ -550,4 +550,4 @@ const ubig prime[] = { }; /* pr_limit - largest prime in the prime table */ -const unsigned long *pr_limit = &prime[(sizeof(prime)/sizeof(prime[0]))-1]; +const ubig *pr_limit = &prime[(sizeof(prime)/sizeof(prime[0]))-1]; diff --git a/primes/primes.c b/primes/primes.c index 5791be7..252d843 100644 --- a/primes/primes.c +++ b/primes/primes.c @@ -1,4 +1,4 @@ -/* $NetBSD: primes.c,v 1.8 1998/09/13 15:27:29 hubertf Exp $ */ +/* $NetBSD: primes.c,v 1.10 2001/01/20 15:06:35 itojun Exp $ */ /* * Copyright (c) 1989, 1993 @@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\ #if 0 static char sccsid[] = "@(#)primes.c 8.5 (Berkeley) 5/10/95"; #else -__RCSID("$NetBSD: primes.c,v 1.8 1998/09/13 15:27:29 hubertf Exp $"); +__RCSID("$NetBSD: primes.c,v 1.10 2001/01/20 15:06:35 itojun Exp $"); #endif #endif /* not lint */ @@ -232,6 +232,7 @@ primes(start, stop) char *tab_lim; /* the limit to sieve on the table */ const ubig *p; /* prime table pointer */ ubig fact_lim; /* highest prime for current block */ + ubig mod; /* temp storage for mod */ /* * A number of systems can not convert double values into unsigned @@ -312,11 +313,11 @@ primes(start, stop) p = &prime[7]; /* 19 is next prime, pi(19)=7 */ do { /* determine the factor's initial sieve point */ - q = (char *)(start%factor); /* temp storage for mod */ - if ((long)q & 0x1) { - q = &table[(factor-(long)q)/2]; + mod = start%factor; + if (mod & 0x1) { + q = &table[(factor-mod)/2]; } else { - q = &table[q ? factor-((long)q/2) : 0]; + q = &table[mod ? factor-(mod/2) : 0]; } /* sive for our current factor */ for ( ; q < tab_lim; q += factor) { diff --git a/quiz/Makefile.bsd b/quiz/Makefile.bsd index 807ac4f..3832ad4 100644 --- a/quiz/Makefile.bsd +++ b/quiz/Makefile.bsd @@ -1,15 +1,19 @@ -# $NetBSD: Makefile,v 1.11 1997/03/24 22:15:48 christos Exp $ +# $NetBSD: Makefile,v 1.13 1999/02/13 02:54:22 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 +.include + PROG= quiz MAN= quiz.6 SRCS= quiz.c rxp.c +HIDEGAME=hidegame +.if ${MKSHARE} != "no" CATS= africa america areas arith asia babies bard chinese collectives \ ed elements europe flowers greek inca index latin locomotive \ midearth morse mult murders poetry posneg pres province seq-easy \ seq-hard sexes sov spell state trek ucc -HIDEGAME=hidegame FILES= ${CATS:S@^@${.CURDIR}/datfiles/@} FILESDIR=/usr/share/games/quiz.db +.endif .include diff --git a/quiz/Makefrag b/quiz/Makefrag index 545df1a..2e22276 100644 --- a/quiz/Makefrag +++ b/quiz/Makefrag @@ -1,5 +1,32 @@ # Makefrag - makefile fragment for quiz +# +# Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. +quiz_DEFS := $(FGETLN_DEFS) quiz_DIRS := $(GAMESDIR) $(MAN6DIR) quiz_all: quiz/quiz quiz/quiz.6 diff --git a/quiz/quiz.6.in b/quiz/quiz.6.in index 99cf9c7..6eb338c 100644 --- a/quiz/quiz.6.in +++ b/quiz/quiz.6.in @@ -1,4 +1,4 @@ -.\" $NetBSD: quiz.6,v 1.6 1997/09/20 14:28:16 lukem Exp $ +.\" $NetBSD: quiz.6,v 1.9 2002/09/26 18:32:03 wiz Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -71,16 +71,18 @@ You can pick any two categories from the same subject. .Nm will ask questions from the first category and it expects answers from the second category. -For example, the command ``quiz victim killer'' asks questions which are -the names of victims, and expects you to answer with the cause of their -untimely demise, whereas the command ``quiz killer victim'' works the -other way around. +For example, the command +.Dq quiz victim killer +asks questions which are the names of victims, and expects you to answer +with the cause of their untimely demise, whereas the command +.Dq quiz killer victim +works the other way around. .Pp If you get the answer wrong, .Nm lets you try again. To see the right answer, enter a blank line. -.Sh "Index and Data File Syntax" +.Ss Index and Data File Syntax The index and data files have a similar syntax. Lines in them consist of several categories separated by colons. The categories are regular expressions formed using the following diff --git a/quiz/quiz.c b/quiz/quiz.c index a791adc..dafc516 100644 --- a/quiz/quiz.c +++ b/quiz/quiz.c @@ -1,4 +1,4 @@ -/* $NetBSD: quiz.c,v 1.13 1998/09/13 15:27:29 hubertf Exp $ */ +/* $NetBSD: quiz.c,v 1.18 2000/05/08 07:56:05 mycroft Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\n\ #if 0 static char sccsid[] = "@(#)quiz.c 8.3 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: quiz.c,v 1.13 1998/09/13 15:27:29 hubertf Exp $"); +__RCSID("$NetBSD: quiz.c,v 1.18 2000/05/08 07:56:05 mycroft Exp $"); #endif #endif /* not lint */ @@ -69,12 +69,12 @@ static QE qlist; static int catone, cattwo, tflag; static u_int qsize; -char *appdstr __P((char *, char *, size_t)); +char *appdstr __P((char *, const char *, size_t)); void downcase __P((char *)); void get_cats __P((char *, char *)); -void get_file __P((char *)); +void get_file __P((const char *)); int main __P((int, char *[])); -char *next_cat __P((char *)); +const char *next_cat __P((const char *)); void quiz __P((void)); void score __P((u_int, u_int, u_int)); void show_index __P((void)); @@ -86,7 +86,7 @@ main(argc, argv) char *argv[]; { int ch; - char *indexfile; + const char *indexfile; /* Revoke setgid privileges */ setregid(getgid(), getgid()); @@ -125,7 +125,7 @@ main(argc, argv) void get_file(file) - char *file; + const char *file; { FILE *fp; QE *qp; @@ -167,9 +167,9 @@ void show_index() { QE *qp; - char *p, *s; + const char *p, *s; FILE *pf; - char *pager; + const char *pager; if (!isatty(1)) pager = "cat"; @@ -178,7 +178,7 @@ show_index() pager = _PATH_PAGER; } if ((pf = popen(pager, "w")) == NULL) - err(1, "%s", _PATH_PAGER); + err(1, "%s", pager); (void)fprintf(pf, "Subjects:\n\n"); for (qp = qlist.q_next; qp; qp = qp->q_next) { for (s = next_cat(qp->q_text); s; s = next_cat(s)) { @@ -202,7 +202,7 @@ get_cats(cat1, cat2) { QE *qp; int i; - char *s; + const char *s; downcase(cat1); downcase(cat2); @@ -237,7 +237,8 @@ quiz() size_t len; u_int guesses, rights, wrongs; int next; - char *answer, *s, *t, question[LINE_SZ]; + char *answer, *t, question[LINE_SZ]; + const char *s; srandom(time(NULL)); guesses = rights = wrongs = 0; @@ -311,9 +312,9 @@ quiz() score(rights, wrongs, guesses); } -char * +const char * next_cat(s) - char * s; + const char * s; { int esc; @@ -338,10 +339,11 @@ next_cat(s) char * appdstr(s, tp, len) char *s; - char *tp; + const char *tp; size_t len; { - char *mp, *sp; + char *mp; + const char *sp; int ch; char *m; diff --git a/quiz/quiz.h b/quiz/quiz.h index ff7e4de..f8123b3 100644 --- a/quiz/quiz.h +++ b/quiz/quiz.h @@ -1,4 +1,4 @@ -/* $NetBSD: quiz.h,v 1.4 1995/04/22 10:16:59 cgd Exp $ */ +/* $NetBSD: quiz.h,v 1.5 1999/09/08 21:17:56 jsm Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -58,6 +58,6 @@ typedef struct qentry { extern char rxperr[]; -int rxp_compile __P((char *)); +int rxp_compile __P((const char *)); char *rxp_expand __P((void)); -int rxp_match __P((char *)); +int rxp_match __P((const char *)); diff --git a/quiz/rxp.c b/quiz/rxp.c index 19a31bf..26c5951 100644 --- a/quiz/rxp.c +++ b/quiz/rxp.c @@ -1,4 +1,4 @@ -/* $NetBSD: rxp.c,v 1.6 1997/09/20 14:28:19 lukem Exp $ */ +/* $NetBSD: rxp.c,v 1.10 2002/12/06 01:54:55 thorpej Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)rxp.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: rxp.c,v 1.6 1997/09/20 14:28:19 lukem Exp $"); +__RCSID("$NetBSD: rxp.c,v 1.10 2002/12/06 01:54:55 thorpej Exp $"); #endif #endif /* not lint */ @@ -68,6 +68,7 @@ __RCSID("$NetBSD: rxp.c,v 1.6 1997/09/20 14:28:19 lukem Exp $"); */ #include +#include #include #include "quiz.h" /* regexp tokens, arg */ @@ -85,24 +86,24 @@ typedef short Rxp_t; /* type for regexp tokens */ static Rxp_t rxpbuf[RXP_LINE_SZ]; /* compiled regular expression buffer */ char rxperr[128]; /* parser error message */ -static int rxp__compile __P((char *, int)); +static int rxp__compile __P((const char *, int)); static char *rxp__expand __P((int)); -static int rxp__match __P((char *, int, Rxp_t *, Rxp_t *, char *)); +static int rxp__match __P((const char *, int, Rxp_t *, Rxp_t *, const char *)); int rxp_compile(s) - char * s; + const char * s; { return (rxp__compile(s, TRUE)); } static int rxp__compile(s, first) - char *s; + const char *s; int first; { static Rxp_t *rp; - static char *sp; + static const char *sp; Rxp_t *grp_ptr; Rxp_t *alt_ptr; int esc, err; @@ -196,24 +197,23 @@ rxp__compile(s, first) */ int rxp_match(s) - char * s; + const char * s; { return (rxp__match(s, TRUE, NULL, NULL, NULL)); } static int rxp__match(s, first, j_succ, j_fail, sp_fail) - char *s; + const char *s; int first; Rxp_t *j_succ; /* jump here on successful alt match */ Rxp_t *j_fail; /* jump here on failed match */ - char *sp_fail; /* reset sp to here on failed match */ + const char *sp_fail; /* reset sp to here on failed match */ { static Rxp_t *rp; - static char *sp; + static const char *sp; int ch; Rxp_t *grp_end = NULL; - int err; if (first) { rp = rxpbuf; @@ -227,7 +227,7 @@ rxp__match(s, first, j_succ, j_fail, sp_fail) if (ch != *sp++) { rp = j_fail; sp = sp_fail; - return (TRUE); + return (FALSE); } rp++; break; @@ -247,16 +247,17 @@ rxp__match(s, first, j_succ, j_fail, sp_fail) break; case ALT_S: rp++; - if ((err = rxp__match(sp, - FALSE, grp_end, rxpbuf + *rp++, sp)) != TRUE) - return (err); + rxp__match(sp, FALSE, grp_end, rxpbuf + *rp++, sp); break; case ALT_E: rp = j_succ; return (TRUE); case GRP_E: - default: + rp = j_fail; + sp = sp_fail; return (FALSE); + default: + abort(); } return (*rp != END ? FALSE : TRUE); } diff --git a/rain/Makefile.bsd b/rain/Makefile.bsd index e73cfce..9f7cc8f 100644 --- a/rain/Makefile.bsd +++ b/rain/Makefile.bsd @@ -1,9 +1,9 @@ -# $NetBSD: Makefile,v 1.7 1998/02/04 10:21:12 christos Exp $ +# $NetBSD: Makefile,v 1.8 1999/07/30 02:14:56 hubertf Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 PROG= rain MAN= rain.6 -DPADD= ${LIBTERMCAP} -LDADD= -ltermcap +DPADD= ${LIBCURSES} +LDADD= -lcurses .include diff --git a/rain/Makefrag b/rain/Makefrag index a8ead4e..ad6fc15 100644 --- a/rain/Makefrag +++ b/rain/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for rain +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. rain_DIRS := $(GAMESDIR) $(MAN6DIR) diff --git a/rain/rain.6 b/rain/rain.6 index 5e11502..b64a061 100644 --- a/rain/rain.6 +++ b/rain/rain.6 @@ -1,4 +1,4 @@ -.\" $NetBSD: rain.6,v 1.6 1997/10/12 01:12:44 lukem Exp $ +.\" $NetBSD: rain.6,v 1.10 2002/09/26 18:32:04 wiz Exp $ .\" .\" Copyright (c) 1989, 1993 .\" The Regents of the University of California. All rights reserved. @@ -37,25 +37,22 @@ .Dt RAIN 6 .Os .Sh NAME -.Nm rain +.Nm rain .Nd animated raindrops display .Sh SYNOPSIS .Nm +.Op Fl d Ar delay .Sh DESCRIPTION The output of .Nm -is modeled after the -.Tn VAX/VMS +is modeled after the +.Tn VAX/VMS program of the same name. -The terminal has to be set for 9600 baud to obtain the proper effect. -.Pp -As with all programs that use -.Tn termcap , -the -.Ev TERM -environment variable must be set (and exported) to the type of the -terminal being used. -.Sh FILES -.Pa /usr/share/misc/termcap +To obtain the proper effect, either the terminal must be set for 9600 +baud or the +.Fl d +option must be used to specify a delay, in milliseconds, between each +update. +A reasonable delay is 120; the default is 0. .Sh AUTHOR -Eric P. Scott +.An Eric P. Scott diff --git a/random/Makefrag b/random/Makefrag index 15b86ad..2a07859 100644 --- a/random/Makefrag +++ b/random/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for random +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. random_DIRS := $(GAMESDIR) $(MAN6DIR) diff --git a/random/random.6 b/random/random.6 index 5fff3e3..5e21e8b 100644 --- a/random/random.6 +++ b/random/random.6 @@ -1,4 +1,4 @@ -.\" $NetBSD: random.6,v 1.3 1997/10/12 01:14:18 lukem Exp $ +.\" $NetBSD: random.6,v 1.5 2002/09/26 18:32:04 wiz Exp $ .\" .\" Copyright (c) 1994 .\" The Regents of the University of California. All rights reserved. @@ -35,7 +35,7 @@ .\" .Dd March 31, 1994 .Dt RANDOM 6 -.Os BSD 4 +.Os .Sh NAME .Nm random .Nd random lines from a file or random numbers @@ -60,8 +60,8 @@ option is specified, .Nm does not read or write anything, and simply exits with a random exit value of 0 to -.Ar denominator -\&- 1, inclusive. +.Ar denominator Ns -1 , +inclusive. .It Fl r The .Fl r diff --git a/robots/Makefile.bsd b/robots/Makefile.bsd index 521b92f..6237c71 100644 --- a/robots/Makefile.bsd +++ b/robots/Makefile.bsd @@ -1,9 +1,9 @@ -# $NetBSD: Makefile,v 1.14 1998/02/18 22:37:32 jtc Exp $ +# $NetBSD: Makefile,v 1.15 1999/05/15 23:56:35 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 PROG= robots CPPFLAGS+=-DMAX_PER_UID=5 -SRCS= extern.c init_field.c main.c make_level.c move.c move_robs.c \ +SRCS= auto.c extern.c init_field.c main.c make_level.c move.c move_robs.c \ play_level.c query.c rnd_pos.c score.c flush_in.c MAN= robots.6 DPADD= ${LIBCURSES} diff --git a/robots/Makefrag b/robots/Makefrag index 2c18a80..457d8f9 100644 --- a/robots/Makefrag +++ b/robots/Makefrag @@ -1,4 +1,30 @@ # Makefile - makefile for robots +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. robots_DEFS := -DFANCY -DMAX_PER_UID=5 robots_DIRS := $(GAMESDIR) $(MAN6DIR) diff --git a/robots/auto.c b/robots/auto.c index c0a15bf..29bba25 100644 --- a/robots/auto.c +++ b/robots/auto.c @@ -1,4 +1,4 @@ -/* $NetBSD: auto.c,v 1.4 1999/09/08 21:17:56 jsm Exp $ */ +/* $NetBSD: auto.c,v 1.5 2002/01/31 17:35:52 christos Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -236,7 +236,7 @@ move_towards(dx, dy) (void)strcpy(ok_moves, find_moves()); best_move = ok_moves[0]; - if (best_move != 'F') { + if (best_move != 't') { mvx = xinc(best_move); mvy = yinc(best_move); move_judge = ABS(mvx - dx) + ABS(mvy - dy); diff --git a/robots/extern.c b/robots/extern.c index 81b4df5..77d9004 100644 --- a/robots/extern.c +++ b/robots/extern.c @@ -1,4 +1,4 @@ -/* $NetBSD: extern.c,v 1.4 1997/10/12 14:09:56 lukem Exp $ */ +/* $NetBSD: extern.c,v 1.7 1999/09/18 19:38:53 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)extern.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: extern.c,v 1.4 1997/10/12 14:09:56 lukem Exp $"); +__RCSID("$NetBSD: extern.c,v 1.7 1999/09/18 19:38:53 jsm Exp $"); #endif #endif /* not lint */ @@ -52,6 +52,7 @@ bool Newscore; /* There was a new score added */ bool Pattern_roll = FALSE; /* Auto play for YHBJNLUK pattern */ #endif bool Real_time = FALSE; /* Play in real time? */ +bool Auto_bot = FALSE; /* Automatic mover */ bool Running = FALSE; /* Currently in the middle of a run */ #ifdef FANCY bool Stand_still = FALSE; /* Auto play for standing still pattern */ @@ -62,15 +63,17 @@ bool Was_bonus = FALSE; /* Was a bonus last level */ char Cnt_move; /* Command which has preceded the count */ char Field[Y_FIELDSIZE][X_FIELDSIZE]; /* the playing field itslef */ -char *Next_move; /* Next move to be used in the pattern */ -char *Move_list = "YHBJNLUK";/* List of moves in the pattern */ +const char *Next_move; /* Next move to be used in the pattern */ +const char *Move_list = "YHBJNLUK";/* List of moves in the pattern */ char Run_ch; /* Character for the direction we are running */ int Count = 0; /* Command count */ int Level; /* Current level */ int Num_robots; /* Number of robots left */ +int Num_scrap; /* Number of scrap heaps */ int Num_scores; /* Number of scores posted */ -int Score; /* Current score */ +int Num_games; /* Number of games to play */ +u_int32_t Score; /* Current score */ int Start_level = 1; /* Level on which to start */ int Wait_bonus; /* bonus for waiting */ @@ -78,5 +81,6 @@ COORD Max; /* Max area robots take up */ COORD Min; /* Min area robots take up */ COORD My_pos; /* Player's current position */ COORD Robots[MAXROBOTS]; /* Robots' current positions */ +COORD Scrap[MAXROBOTS]; /* ScrapHeap' current position */ jmp_buf End_move; /* Jump to on Real_time */ diff --git a/robots/init_field.c b/robots/init_field.c index a5fd9e2..822ab10 100644 --- a/robots/init_field.c +++ b/robots/init_field.c @@ -1,4 +1,4 @@ -/* $NetBSD: init_field.c,v 1.5 1997/10/12 14:09:57 lukem Exp $ */ +/* $NetBSD: init_field.c,v 1.7 2002/01/31 17:35:52 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,12 +38,15 @@ #if 0 static char sccsid[] = "@(#)init_field.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: init_field.c,v 1.5 1997/10/12 14:09:57 lukem Exp $"); +__RCSID("$NetBSD: init_field.c,v 1.7 2002/01/31 17:35:52 christos Exp $"); #endif #endif /* not lint */ # include "robots.h" +static int telx = 0; +static int tely = 0; + /* * init_field: * Lay down the initial pattern whih is constant across all levels, @@ -54,7 +57,7 @@ init_field() { int i; static bool first = TRUE; - static char *desc[] = { + static const char *const desc[] = { "Directions:", "", "y k u", @@ -112,6 +115,8 @@ init_field() move(i, X_FIELDSIZE + 2); addstr(desc[i]); } + telx = X_FIELDSIZE + 2; + tely = i; if (first) refresh(); first = FALSE; @@ -120,3 +125,11 @@ init_field() Next_move = &Move_list[-1]; #endif } + +void +telmsg(on) + int on; +{ + move(tely, telx); + addstr(on ? "Teleport!" : " "); +} diff --git a/robots/make_level.c b/robots/make_level.c index b67d4d7..d4f15b4 100644 --- a/robots/make_level.c +++ b/robots/make_level.c @@ -1,4 +1,4 @@ -/* $NetBSD: make_level.c,v 1.5 1997/10/12 14:16:27 lukem Exp $ */ +/* $NetBSD: make_level.c,v 1.6 1999/05/15 23:56:36 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)make_level.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: make_level.c,v 1.5 1997/10/12 14:16:27 lukem Exp $"); +__RCSID("$NetBSD: make_level.c,v 1.6 1999/05/15 23:56:36 christos Exp $"); #endif #endif /* not lint */ @@ -78,6 +78,8 @@ make_level() if ((i = Level * 10) > MAXROBOTS) i = MAXROBOTS; Num_robots = i; + memset(Scrap, 0, sizeof(Scrap[0]) * MAXROBOTS); + Num_scrap = 0; while (i-- > 0) { cp = rnd_pos(); Robots[i] = *cp; diff --git a/robots/move.c b/robots/move.c index ff8476c..c098292 100644 --- a/robots/move.c +++ b/robots/move.c @@ -1,4 +1,4 @@ -/* $NetBSD: move.c,v 1.7 1998/07/24 23:28:02 hubertf Exp $ */ +/* $NetBSD: move.c,v 1.10 2002/01/31 17:35:52 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: move.c,v 1.7 1998/07/24 23:28:02 hubertf Exp $"); +__RCSID("$NetBSD: move.c,v 1.10 2002/01/31 17:35:52 christos Exp $"); #endif #endif /* not lint */ @@ -94,7 +94,10 @@ get_move() #endif else { over: - c = getchar(); + if (Auto_bot) + c = automove(); + else + c = getchar(); if (isdigit(c)) { Count = (c - '0'); while (isdigit(c = getchar())) @@ -172,6 +175,10 @@ teleport: Running = FALSE; mvaddch(My_pos.y, My_pos.x, ' '); My_pos = *rnd_pos(); + telmsg(1); + refresh(); + sleep(1); + telmsg(0); mvaddch(My_pos.y, My_pos.x, PLAYER); leaveok(stdscr, FALSE); refresh(); @@ -271,7 +278,7 @@ do_move(dy, dx) */ bool eaten(pos) - COORD *pos; + const COORD *pos; { int x, y; diff --git a/robots/move_robs.c b/robots/move_robs.c index b45357c..36927f9 100644 --- a/robots/move_robs.c +++ b/robots/move_robs.c @@ -1,4 +1,4 @@ -/* $NetBSD: move_robs.c,v 1.4 1997/10/12 14:10:00 lukem Exp $ */ +/* $NetBSD: move_robs.c,v 1.6 2001/01/16 02:50:28 cgd Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)move_robs.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: move_robs.c,v 1.4 1997/10/12 14:10:00 lukem Exp $"); +__RCSID("$NetBSD: move_robs.c,v 1.6 2001/01/16 02:50:28 cgd Exp $"); #endif #endif /* not lint */ @@ -61,7 +61,7 @@ move_robots(was_sig) addch(inch()); move(Max.y, Max.x); addch(inch()); -# endif DEBUG +# endif /* DEBUG */ for (rp = Robots; rp < &Robots[MAXROBOTS]; rp++) { if (rp->y < 0) continue; @@ -91,6 +91,7 @@ move_robots(was_sig) Dead = TRUE; else if (Field[rp->y][rp->x] > 1) { mvaddch(rp->y, rp->x, HEAP); + Scrap[Num_scrap++] = *rp; rp->y = -1; Num_robots--; if (Waiting) @@ -122,7 +123,7 @@ move_robots(was_sig) move(Max.y, Max.x); addch(inch()); standend(); -# endif DEBUG +# endif /* DEBUG */ if (Real_time) alarm(3); } diff --git a/robots/play_level.c b/robots/play_level.c index 74a013f..864fcf9 100644 --- a/robots/play_level.c +++ b/robots/play_level.c @@ -1,4 +1,4 @@ -/* $NetBSD: play_level.c,v 1.4 1997/10/12 14:10:01 lukem Exp $ */ +/* $NetBSD: play_level.c,v 1.5 2001/01/16 02:50:28 cgd Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)play_level.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: play_level.c,v 1.4 1997/10/12 14:10:01 lukem Exp $"); +__RCSID("$NetBSD: play_level.c,v 1.5 2001/01/16 02:50:28 cgd Exp $"); #endif #endif /* not lint */ @@ -70,7 +70,7 @@ play_level() move(Max.y, Max.x); addch(inch()); standend(); -# endif DEBUG +# endif /* DEBUG */ setjmp(End_move); flush_in(); while (!Dead && Num_robots > 0) { diff --git a/robots/query.c b/robots/query.c index e0ca582..b89535e 100644 --- a/robots/query.c +++ b/robots/query.c @@ -1,4 +1,4 @@ -/* $NetBSD: query.c,v 1.4 1997/10/12 14:10:01 lukem Exp $ */ +/* $NetBSD: query.c,v 1.5 1999/09/08 21:17:57 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)query.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: query.c,v 1.4 1997/10/12 14:10:01 lukem Exp $"); +__RCSID("$NetBSD: query.c,v 1.5 1999/09/08 21:17:57 jsm Exp $"); #endif #endif /* not lint */ @@ -50,7 +50,7 @@ __RCSID("$NetBSD: query.c,v 1.4 1997/10/12 14:10:01 lukem Exp $"); */ int query(prompt) - char *prompt; + const char *prompt; { int c, retval; int y, x; diff --git a/robots/robots.6.in b/robots/robots.6.in index af39b3f..6762ff7 100644 --- a/robots/robots.6.in +++ b/robots/robots.6.in @@ -1,4 +1,4 @@ -.\" $NetBSD: robots.6,v 1.6 1997/10/12 14:10:03 lukem Exp $ +.\" $NetBSD: robots.6,v 1.11 2002/09/26 18:32:04 wiz Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -37,11 +37,11 @@ .Dt ROBOTS 6 .Os .Sh NAME -.Nm robots +.Nm robots .Nd fight off villainous robots .Sh SYNOPSIS .Nm -.Op Fl sjta +.Op Fl Asjtan .Op Ar scorefile .Sh DESCRIPTION .Nm @@ -61,7 +61,7 @@ you start on the next field. This keeps up until they finally get you. .Pp Robots are represented on the screen by a -.Sq \+ , +.Sq \&+ , the junk heaps from their collisions by a .Sq \(** , and you @@ -91,7 +91,7 @@ move one square down and right (also space) do nothing for one turn .It Ic HJKLBNYU run as far as possible in the given direction -.It Ic \> +.It Ic \*[Gt] do nothing for as long as possible .It Ic t teleport to a random location @@ -106,7 +106,7 @@ redraw the screen All commands can be preceded by a count. .Pp If you use the -.Sq Ic w +.Sq Ic w command and survive to the next level, you will get a bonus of 10% for each robot which died after you decided to wait. If you die, however, you get nothing. @@ -138,9 +138,15 @@ This is a little disconcerting until you get used to it, and then it is very nice. .It Fl a Advance into the higher levels directly, skipping the lower, easier levels. +.It Fl A +Auto-bot mode. +Lets the game play itself. +.It Fl n +Increase the number of games played by one. .El .Sh AUTHOR Ken Arnold +Christos Zoulas (autobot mode) .Sh FILES .Bl -tag -width @robots_scorefile@ -compact .It Pa @robots_scorefile@ diff --git a/robots/robots.h b/robots/robots.h index 6a8701b..63fa6de 100644 --- a/robots/robots.h +++ b/robots/robots.h @@ -1,4 +1,4 @@ -/* $NetBSD: robots.h,v 1.8 1998/09/13 15:27:29 hubertf Exp $ */ +/* $NetBSD: robots.h,v 1.15 2002/01/31 17:35:52 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -41,6 +41,7 @@ # include # include # include +# include # include # include # include @@ -87,9 +88,11 @@ typedef struct { } COORD; typedef struct { - int s_uid; - int s_score; - char s_name[MAXNAME]; + u_int32_t s_uid; + u_int32_t s_score; + u_int32_t s_auto; + u_int32_t s_level; + char s_name[MAXNAME]; } SCORE; typedef struct passwd PASSWD; @@ -99,19 +102,21 @@ typedef struct passwd PASSWD; */ extern bool Dead, Full_clear, Jump, Newscore, Real_time, Running, - Teleport, Waiting, Was_bonus; + Teleport, Waiting, Was_bonus, Auto_bot; #ifdef FANCY extern bool Pattern_roll, Stand_still; #endif -extern char Cnt_move, Field[Y_FIELDSIZE][X_FIELDSIZE], *Next_move, - *Move_list, Run_ch; +extern char Cnt_move, Field[Y_FIELDSIZE][X_FIELDSIZE], Run_ch; +extern const char *Next_move, *Move_list; -extern int Count, Level, Num_robots, Num_scores, Score, - Start_level, Wait_bonus; +extern int Count, Level, Num_robots, Num_scrap, Num_scores, + Start_level, Wait_bonus, Num_games; -extern COORD Max, Min, My_pos, Robots[]; +extern u_int32_t Score; + +extern COORD Max, Min, My_pos, Robots[], Scrap[]; extern jmp_buf End_move; @@ -121,9 +126,10 @@ extern jmp_buf End_move; void add_score __P((int)); bool another __P((void)); +char automove __P((void)); int cmp_sc __P((const void *, const void *)); bool do_move __P((int, int)); -bool eaten __P((COORD *)); +bool eaten __P((const COORD *)); void flush_in __P((void)); void get_move __P((void)); void init_field __P((void)); @@ -132,7 +138,7 @@ void make_level __P((void)); void move_robots __P((int)); bool must_telep __P((void)); void play_level __P((void)); -int query __P((char *)); +int query __P((const char *)); void quit __P((int)) __attribute__((__noreturn__)); void reset_count __P((void)); int rnd __P((int)); @@ -141,3 +147,4 @@ void score __P((int)); void set_name __P((SCORE *)); void show_score __P((void)); int sign __P((int)); +void telmsg __P((int)); diff --git a/sail/Makefile.bsd b/sail/Makefile.bsd index 1ba8f19..42968bf 100644 --- a/sail/Makefile.bsd +++ b/sail/Makefile.bsd @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.10 1998/02/18 22:37:32 jtc Exp $ +# $NetBSD: Makefile,v 1.13 2000/06/11 15:37:51 mycroft Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 PROG= sail diff --git a/sail/Makefrag b/sail/Makefrag index 226d959..5973517 100644 --- a/sail/Makefrag +++ b/sail/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for sail +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. sail_DIRS := $(GAMESDIR) $(MAN6DIR) diff --git a/sail/assorted.c b/sail/assorted.c index d7074e7..a03b12e 100644 --- a/sail/assorted.c +++ b/sail/assorted.c @@ -1,4 +1,4 @@ -/* $NetBSD: assorted.c,v 1.6 1997/10/13 21:02:57 christos Exp $ */ +/* $NetBSD: assorted.c,v 1.14 2001/02/05 01:10:08 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,21 +38,18 @@ #if 0 static char sccsid[] = "@(#)assorted.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: assorted.c,v 1.6 1997/10/13 21:02:57 christos Exp $"); +__RCSID("$NetBSD: assorted.c,v 1.14 2001/02/05 01:10:08 christos Exp $"); #endif #endif /* not lint */ -#include "extern.h" #include -#include #include +#include "extern.h" -static void strike __P((struct ship *, struct ship *)); +static void strike (struct ship *, struct ship *); void -table(rig, shot, hittable, on, from, roll) -struct ship *on, *from; -int rig, shot, hittable, roll; +table(struct ship *from, struct ship *on, int rig, int shot, int hittable, int roll) { int hhits = 0, chits = 0, ghits = 0, rhits = 0; int Ghit = 0, Hhit = 0, Rhit = 0, Chit = 0; @@ -60,8 +57,8 @@ int rig, shot, hittable, roll; int crew[3]; int n; int rigg[4]; - char *message; - struct Tables *tp; + const char *message; + const struct Tables *tp; pc = on->file->pcrew; hull = on->specs->hull; @@ -139,17 +136,17 @@ int rig, shot, hittable, roll; hull -= ghits; if (Ghit) Write(portside(from, on, 0) ? W_GUNR : W_GUNL, - on, 0, guns, car, 0, 0); + on, guns, car, 0, 0); hull -= hhits; hull = hull < 0 ? 0 : hull; if (on->file->captured != 0 && Chit) - Write(W_PCREW, on, 0, pc, 0, 0, 0); + Write(W_PCREW, on, pc, 0, 0, 0); if (Hhit) - Write(W_HULL, on, 0, hull, 0, 0, 0); + Write(W_HULL, on, hull, 0, 0, 0); if (Chit) - Write(W_CREW, on, 0, crew[0], crew[1], crew[2], 0); + Write(W_CREW, on, crew[0], crew[1], crew[2], 0); if (Rhit) - Write(W_RIGG, on, 0, rigg[0], rigg[1], rigg[2], rigg[3]); + Write(W_RIGG, on, rigg[0], rigg[1], rigg[2], rigg[3]); switch (shot) { case L_ROUND: message = "firing round shot on $$"; @@ -217,7 +214,7 @@ int rig, shot, hittable, roll; break; case 5: message = "rudder cables shot through"; - Write(W_TA, on, 0, 0, 0, 0, 0); + Write(W_TA, on, 0, 0, 0, 0); break; case 6: message = "shot holes below the water line"; @@ -233,10 +230,10 @@ int rig, shot, hittable, roll; if (on->specs->qual <= 0) { makemsg(on, "crew mutinying!"); on->specs->qual = 5; - Write(W_CAPTURED, on, 0, on->file->index, 0, 0, 0); + Write(W_CAPTURED, on, on->file->index, 0, 0, 0); } else makemsg(on, "crew demoralized"); - Write(W_QUAL, on, 0, on->specs->qual, 0, 0, 0); + Write(W_QUAL, on, on->specs->qual, 0, 0, 0); } */ if (!hull) @@ -244,17 +241,15 @@ int rig, shot, hittable, roll; } void -Cleansnag(from, to, all, flag) -struct ship *from, *to; -char all, flag; +Cleansnag(struct ship *from, struct ship *to, int all, int flag) { if (flag & 1) { - Write(W_UNGRAP, from, 0, to->file->index, all, 0, 0); - Write(W_UNGRAP, to, 0, from->file->index, all, 0, 0); + Write(W_UNGRAP, from, to->file->index, all, 0, 0); + Write(W_UNGRAP, to, from->file->index, all, 0, 0); } if (flag & 2) { - Write(W_UNFOUL, from, 0, to->file->index, all, 0, 0); - Write(W_UNFOUL, to, 0, from->file->index, all, 0, 0); + Write(W_UNFOUL, from, to->file->index, all, 0, 0); + Write(W_UNFOUL, to, from->file->index, all, 0, 0); } if (!snagged2(from, to)) { if (!snagged(from)) { @@ -271,27 +266,26 @@ char all, flag; } static void -strike(ship, from) -struct ship *ship, *from; +strike(struct ship *ship, struct ship *from) { int points; if (ship->file->struck) return; - Write(W_STRUCK, ship, 0, 1, 0, 0, 0); + Write(W_STRUCK, ship, 1, 0, 0, 0); points = ship->specs->pts + from->file->points; - Write(W_POINTS, from, 0, points, 0, 0, 0); + Write(W_POINTS, from, points, 0, 0, 0); unboard(ship, ship, 0); /* all offense */ unboard(ship, ship, 1); /* all defense */ - switch (die()) { + switch (dieroll()) { case 3: case 4: /* ship may sink */ - Write(W_SINK, ship, 0, 1, 0, 0, 0); + Write(W_SINK, ship, 1, 0, 0, 0); break; case 5: case 6: /* ship may explode */ - Write(W_EXPLODE, ship, 0, 1, 0, 0, 0); + Write(W_EXPLODE, ship, 1, 0, 0, 0); break; } - Write(W_SIGNAL, ship, 1, (int) "striking her colours!", 0, 0, 0); + Writestr(W_SIGNAL, ship, "striking her colours!"); } diff --git a/sail/dr_1.c b/sail/dr_1.c index 1b4db2e..782d8d5 100644 --- a/sail/dr_1.c +++ b/sail/dr_1.c @@ -1,4 +1,4 @@ -/* $NetBSD: dr_1.c,v 1.7 1998/08/30 09:19:40 veego Exp $ */ +/* $NetBSD: dr_1.c,v 1.18 2001/02/05 01:10:08 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,15 +38,21 @@ #if 0 static char sccsid[] = "@(#)dr_1.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: dr_1.c,v 1.7 1998/08/30 09:19:40 veego Exp $"); +__RCSID("$NetBSD: dr_1.c,v 1.18 2001/02/05 01:10:08 christos Exp $"); #endif #endif /* not lint */ -#include "driver.h" +#include +#include #include +#include +#include "extern.h" +#include "driver.h" + +static int fightitout(struct ship *, struct ship *, int); void -unfoul() +unfoul(void) { struct ship *sp; struct ship *to; @@ -62,14 +68,14 @@ unfoul() !is_toughmelee(sp, to, 0, 0)) continue; for (i = fouled2(sp, to); --i >= 0;) - if (die() <= 2) + if (dieroll() <= 2) cleanfoul(sp, to, 0); } } } void -boardcomp() +boardcomp(void) { int crew[3]; struct ship *sp, *sq; @@ -133,10 +139,8 @@ boardcomp() } } -int -fightitout(from, to, key) -struct ship *from, *to; -int key; +static int +fightitout(struct ship *from, struct ship *to, int key) { struct ship *fromcap, *tocap; int crewfrom[3], crewto[3], menfrom, mento; @@ -173,12 +177,12 @@ int key; index = fromstrength/10; if (index > 8) index = 8; - toinjured = MT[index][2 - die() / 3]; + toinjured = MT[index][2 - dieroll() / 3]; totalto += toinjured; index = strengthto/10; if (index > 8) index = 8; - frominjured = MT[index][2 - die() / 3]; + frominjured = MT[index][2 - dieroll() / 3]; totalfrom += frominjured; menfrom -= frominjured; mento -= toinjured; @@ -187,21 +191,21 @@ int key; } if (fromstrength >= strengthto * 3 || count == 4) { unboard(to, from, 0); - subtract(from, totalfrom, crewfrom, fromcap, pcfrom); - subtract(to, totalto, crewto, tocap, pcto); + subtract(from, fromcap, totalfrom, crewfrom, pcfrom); + subtract(to, tocap, totalto, crewto, pcto); makemsg(from, "boarders from %s repelled", to->shipname); - (void) sprintf(message, "killed in melee: %d. %s: %d", + sprintf(message, "killed in melee: %d. %s: %d", totalto, from->shipname, totalfrom); - Write(W_SIGNAL, to, 1, (long) message, 0, 0, 0); + Writestr(W_SIGNAL, to, message); if (key) return 1; } else if (strengthto >= fromstrength * 3) { unboard(from, to, 0); - subtract(from, totalfrom, crewfrom, fromcap, pcfrom); - subtract(to, totalto, crewto, tocap, pcto); + subtract(from, fromcap, totalfrom, crewfrom, pcfrom); + subtract(to, tocap, totalto, crewto, pcto); if (key) { if (fromcap != from) - Write(W_POINTS, fromcap, 0, + Write(W_POINTS, fromcap, fromcap->file->points - from->file->struck ? from->specs->pts @@ -212,22 +216,21 @@ int key; I guess that what is going on here is that the pointer is multiplied or something. */ - Write(W_CAPTURED, from, 0, to->file->index, 0, 0, 0); + Write(W_CAPTURED, from, to->file->index, 0, 0, 0); topoints = 2 * from->specs->pts + to->file->points; if (from->file->struck) topoints -= from->specs->pts; - Write(W_POINTS, to, 0, topoints, 0, 0, 0); + Write(W_POINTS, to, topoints, 0, 0, 0); mento = crewto[0] ? crewto[0] : crewto[1]; if (mento) { - subtract(to, mento, crewto, tocap, pcto); - subtract(from, - mento, crewfrom, to, 0); + subtract(to, tocap, mento, crewto, pcto); + subtract(from, to, - mento, crewfrom, 0); } - (void) sprintf(message, "captured by the %s!", - to->shipname); - Write(W_SIGNAL, from, 1, (long) message, 0, 0, 0); - (void) sprintf(message, "killed in melee: %d. %s: %d", + sprintf(message, "captured by the %s!", to->shipname); + Writestr(W_SIGNAL, from, message); + sprintf(message, "killed in melee: %d. %s: %d", totalto, from->shipname, totalfrom); - Write(W_SIGNAL, to, 1, (long) message, 0, 0, 0); + Writestr(W_SIGNAL, to, message); mento = 0; return 0; } @@ -236,7 +239,7 @@ int key; } void -resolve() +resolve(void) { int thwart; struct ship *sp, *sq; @@ -246,7 +249,7 @@ resolve() continue; for (sq = sp + 1; sq < ls; sq++) if (sq->file->dir && meleeing(sp, sq) && meleeing(sq, sp)) - (void) fightitout(sp, sq, 0); + fightitout(sp, sq, 0); thwart = 2; foreachship(sq) { if (sq->file->dir && meleeing(sq, sp)) @@ -267,7 +270,7 @@ resolve() } void -compcombat() +compcombat(void) { int n; struct ship *sp; @@ -392,14 +395,14 @@ compcombat() if (hit >= 0) { if (load != L_GRAPE) hit = hit > 10 ? 10 : hit; - table(shootat, load, hit, closest, sp, die()); + table(sp, closest, shootat, load, hit, dieroll()); } } } } int -next() +next(void) { if (++turn % 55 == 0) { if (alive) @@ -421,12 +424,16 @@ next() } } if (best > 0.0) { - char *p = getenv("WOTD"); - if (p == 0) + char *tp = getenv("WOTD"); + const char *p; + if (tp == 0) p = "Driver"; - if (islower(*p)) - *p = toupper(*p); - (void) strncpy(bestship->file->captain, p, + else { + if (islower(*tp)) + *tp = toupper(*tp); + p = tp; + } + strncpy(bestship->file->captain, p, sizeof bestship->file->captain); bestship->file->captain [sizeof bestship->file->captain - 1] = 0; @@ -434,9 +441,9 @@ next() } return -1; } - Write(W_TURN, SHIP(0), 0, turn, 0, 0, 0); - if (turn % 7 == 0 && (die() >= cc->windchange || !windspeed)) { - switch (die()) { + Write(W_TURN, SHIP(0), turn, 0, 0, 0); + if (turn % 7 == 0 && (dieroll() >= cc->windchange || !windspeed)) { + switch (dieroll()) { case 1: winddir = 1; break; @@ -460,7 +467,7 @@ next() if (winddir < 1) winddir += 8; if (windspeed) - switch (die()) { + switch (dieroll()) { case 1: case 2: windspeed--; @@ -472,7 +479,7 @@ next() } else windspeed++; - Write(W_WIND, SHIP(0), 0, winddir, windspeed, 0, 0); + Write(W_WIND, SHIP(0), winddir, windspeed, 0, 0); } return 0; } diff --git a/sail/dr_2.c b/sail/dr_2.c index 17d7b5a..3eb96ab 100644 --- a/sail/dr_2.c +++ b/sail/dr_2.c @@ -1,4 +1,4 @@ -/* $NetBSD: dr_2.c,v 1.8 1998/09/11 14:13:46 hubertf Exp $ */ +/* $NetBSD: dr_2.c,v 1.18 2001/02/05 01:10:08 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,17 +38,28 @@ #if 0 static char sccsid[] = "@(#)dr_2.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: dr_2.c,v 1.8 1998/09/11 14:13:46 hubertf Exp $"); +__RCSID("$NetBSD: dr_2.c,v 1.18 2001/02/05 01:10:08 christos Exp $"); #endif #endif /* not lint */ -#include "driver.h" +#include #include +#include +#include "extern.h" +#include "driver.h" #define couldwin(f,t) (f->specs->crew2 > t->specs->crew2 * 1.5) +static int str_end(const char *); +static int score(struct ship *, struct ship *, char *, int); +static void move_ship(struct ship *, const char *, unsigned char *, short *, short *, char *); +static void try(struct ship *, struct ship *, char *, char *, int, int, int, int, int, int *, int); +static void rmend(char *); + +const int dtab[] = {0,1,1,2,3,4,4,5}; /* diagonal distances in x==y */ + void -thinkofgrapples() +thinkofgrapples(void) { struct ship *sp, *sq; char friendly; @@ -79,7 +90,7 @@ thinkofgrapples() } void -checkup() +checkup(void) { struct ship *sp, *sq; char explode, sink; @@ -91,10 +102,10 @@ checkup() sink = sp->file->sink; if (explode != 1 && sink != 1) continue; - if (die() < 5) + if (dieroll() < 5) continue; - Write(sink == 1 ? W_SINK : W_EXPLODE, sp, 0, 2, 0, 0, 0); - Write(W_DIR, sp, 0, 0, 0, 0, 0); + Write(sink == 1 ? W_SINK : W_EXPLODE, sp, 2, 0, 0, 0); + Write(W_DIR, sp, 0, 0, 0, 0); if (snagged(sp)) foreachship(sq) cleansnag(sp, sq, 1); @@ -102,7 +113,7 @@ checkup() makemsg(sp, "exploding!"); foreachship(sq) { if (sp != sq && sq->file->dir && range(sp, sq) < 4) - table(RIGGING, L_EXPLODE, sp->specs->guns/13, sq, sp, 6); + table(sp, sq, RIGGING, L_EXPLODE, sp->specs->guns/13, 6); } } else makemsg(sp, "sinking!"); @@ -110,7 +121,7 @@ checkup() } void -prizecheck() +prizecheck(void) { struct ship *sp; @@ -120,19 +131,17 @@ prizecheck() if (sp->file->struck || sp->file->dir == 0) continue; if (sp->specs->crew1 + sp->specs->crew2 + sp->specs->crew3 > sp->file->pcrew * 6) { - Write(W_SIGNAL, sp, 1, - (long)"prize crew overthrown", 0, 0, 0); - Write(W_POINTS, sp->file->captured, 0, sp->file->captured->file->points - 2 * sp->specs->pts, 0, 0, 0); - Write(W_CAPTURED, sp, 0, -1, 0, 0, 0); + Writestr(W_SIGNAL, sp, "prize crew overthrown"); + Write(W_POINTS, sp->file->captured, sp->file->captured->file->points - 2 * sp->specs->pts, 0, 0, 0); + Write(W_CAPTURED, sp, -1, 0, 0, 0); } } } -int -str_end(str) -char *str; +static int +str_end(const char *str) { - char *p; + const char *p; for (p = str; *p; p++) ; @@ -140,26 +149,18 @@ char *str; } void -closeon(from, to, command, ta, ma, af) -struct ship *from, *to; -char command[]; -int ma, ta, af; +closeon(struct ship *from, struct ship *to, char *command, int ta, int ma, int af) { int high; char temp[10]; temp[0] = command[0] = '\0'; high = -30000; - try(command, temp, ma, ta, af, ma, from->file->dir, from, to, &high, 0); + try(from, to, command, temp, ma, ta, af, ma, from->file->dir, &high, 0); } -int dtab[] = {0,1,1,2,3,4,4,5}; /* diagonal distances in x==y */ - -int -score(movement, ship, to, onlytemp) -char movement[]; -struct ship *ship, *to; -char onlytemp; +static int +score(struct ship *ship, struct ship *to, char *movement, int onlytemp) { char drift; int row, col, dir, total, ran; @@ -170,9 +171,9 @@ char onlytemp; row = fp->row; col = fp->col; drift = fp->drift; - move_ship(movement, ship, &fp->dir, &fp->row, &fp->col, &drift); + move_ship(ship, movement, &fp->dir, &fp->row, &fp->col, &drift); if (!*movement) - (void) strcpy(movement, "d"); + strcpy(movement, "d"); ran = range(ship, to); total = -50 * ran; @@ -189,13 +190,8 @@ char onlytemp; return total; } -void -move_ship(p, ship, dir, row, col, drift) -char *p; -struct ship *ship; -unsigned char *dir; -short *row, *col; -char *drift; +static void +move_ship(struct ship *ship, const char *p, unsigned char *dir, short *row, short *col, char *drift) { int dist; char moved = 0; @@ -234,11 +230,8 @@ char *drift; *drift = 0; } -void -try(command, temp, ma, ta, af, vma, dir, f, t, high, rakeme) -struct ship *f, *t; -int ma, ta, af, vma, dir, *high, rakeme; -char command[], temp[]; +static void +try(struct ship *f, struct ship *t, char *command, char *temp, int ma, int ta, int af, int vma, int dir, int *high, int rakeme) { int new, n; char st[4]; @@ -246,42 +239,41 @@ char command[], temp[]; if ((n = str_end(temp)) < '1' || n > '9') for (n = 1; vma - n >= 0; n++) { - (void) sprintf(st, "%d", n); - (void) strcat(temp, st); - new = score(temp, f, t, rakeme); + sprintf(st, "%d", n); + strcat(temp, st); + new = score(f, t, temp, rakeme); if (new > *high && (!rakeme || rakeyou)) { *high = new; - (void) strcpy(command, temp); + strcpy(command, temp); } - try(command, temp, ma-n, ta, af, vma-n, - dir, f, t, high, rakeme); + try(f, t, command, temp, ma-n, ta, af, vma-n, + dir, high, rakeme); rmend(temp); } if ((ma > 0 && ta > 0 && (n = str_end(temp)) != 'l' && n != 'r') || !strlen(temp)) { - (void) strcat(temp, "r"); - new = score(temp, f, t, rakeme); + strcat(temp, "r"); + new = score(f, t, temp, rakeme); if (new > *high && (!rakeme || (gunsbear(f, t) && !gunsbear(t, f)))) { *high = new; - (void) strcpy(command, temp); + strcpy(command, temp); } - try(command, temp, ma-1, ta-1, af, min(ma-1, maxmove(f, (dir == 8 ? 1 : dir+1), 0)), (dir == 8 ? 1 : dir+1),f,t,high,rakeme); + try(f, t, command, temp, ma-1, ta-1, af, min(ma-1, maxmove(f, (dir == 8 ? 1 : dir+1), 0)), (dir == 8 ? 1 : dir+1), high, rakeme); rmend(temp); } if ((ma > 0 && ta > 0 && (n = str_end(temp)) != 'l' && n != 'r') || !strlen(temp)){ - (void) strcat(temp, "l"); - new = score(temp, f, t, rakeme); + strcat(temp, "l"); + new = score(f, t, temp, rakeme); if (new > *high && (!rakeme || (gunsbear(f, t) && !gunsbear(t, f)))){ *high = new; - (void) strcpy(command, temp); + strcpy(command, temp); } - try(command, temp, ma-1, ta-1, af, (min(ma-1,maxmove(f, (dir-1 ? dir-1 : 8), 0))), (dir-1 ? dir -1 : 8), f, t, high, rakeme); + try(f, t, command, temp, ma-1, ta-1, af, (min(ma-1,maxmove(f, (dir-1 ? dir-1 : 8), 0))), (dir-1 ? dir -1 : 8), high, rakeme); rmend(temp); } } -void -rmend(str) -char *str; +static void +rmend(char *str) { char *p; diff --git a/sail/dr_3.c b/sail/dr_3.c index 489ab5b..22404c7 100644 --- a/sail/dr_3.c +++ b/sail/dr_3.c @@ -1,4 +1,4 @@ -/* $NetBSD: dr_3.c,v 1.5 1997/10/13 21:03:27 christos Exp $ */ +/* $NetBSD: dr_3.c,v 1.14 2001/02/05 01:10:09 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,15 +38,23 @@ #if 0 static char sccsid[] = "@(#)dr_3.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: dr_3.c,v 1.5 1997/10/13 21:03:27 christos Exp $"); +__RCSID("$NetBSD: dr_3.c,v 1.14 2001/02/05 01:10:09 christos Exp $"); #endif #endif /* not lint */ -#include "driver.h" #include +#include +#include "extern.h" +#include "driver.h" +static int stillmoving(int); +static int is_isolated(struct ship *); +static int push(struct ship *, struct ship *); +static void step(struct ship *, int, char *); + +/* move all comp ships */ void -moveall() /* move all comp ships */ +moveall(void) { struct ship *sp, *sq; int n; @@ -86,10 +94,10 @@ moveall() /* move all comp ships */ n = 0; foreachship(sp) { if (snagged(sp)) - (void) strcpy(sp->file->movebuf, "d"); + strcpy(sp->file->movebuf, "d"); else if (*sp->file->movebuf != 'd') - (void) strcat(sp->file->movebuf, "d"); + strcat(sp->file->movebuf, "d"); row[n] = sp->file->row; col[n] = sp->file->col; dir[n] = sp->file->dir; @@ -111,7 +119,7 @@ moveall() /* move all comp ships */ if (!sp->file->movebuf[k]) sp->file->movebuf[k+1] = '\0'; else if (sp->file->dir) - step(sp->file->movebuf[k], sp, &moved[n]); + step(sp, sp->file->movebuf[k], &moved[n]); n++; } /* @@ -135,11 +143,11 @@ moveall() /* move all comp ships */ snap++; if (!range(sp, sq) && !fouled2(sp, sq)) { makesignal(sp, "collision with $$", sq); - if (die() < 4) { + if (dieroll() < 4) { makesignal(sp, "fouled with $$", sq); - Write(W_FOUL, sp, 0, l, 0, 0, 0); - Write(W_FOUL, sq, 0, n, 0, 0, 0); + Write(W_FOUL, sp, l, 0, 0, 0); + Write(W_FOUL, sq, n, 0, 0, 0); } snap++; } @@ -170,21 +178,20 @@ moveall() /* move all comp ships */ if (sp->file->dir != 0) { *sp->file->movebuf = 0; if (row[n] != sp->file->row) - Write(W_ROW, sp, 0, sp->file->row, 0, 0, 0); + Write(W_ROW, sp, sp->file->row, 0, 0, 0); if (col[n] != sp->file->col) - Write(W_COL, sp, 0, sp->file->col, 0, 0, 0); + Write(W_COL, sp, sp->file->col, 0, 0, 0); if (dir[n] != sp->file->dir) - Write(W_DIR, sp, 0, sp->file->dir, 0, 0, 0); + Write(W_DIR, sp, sp->file->dir, 0, 0, 0); if (drift[n] != sp->file->drift) - Write(W_DRIFT, sp, 0, sp->file->drift, 0, 0, 0); + Write(W_DRIFT, sp, sp->file->drift, 0, 0, 0); } n++; } } -int -stillmoving(k) -int k; +static int +stillmoving(int k) { struct ship *sp; @@ -194,9 +201,8 @@ int k; return 0; } -int -is_isolated(ship) -struct ship *ship; +static int +is_isolated(struct ship *ship) { struct ship *sp; @@ -207,9 +213,8 @@ struct ship *ship; return 1; } -int -push(from, to) -struct ship *from, *to; +static int +push(struct ship *from, struct ship *to) { int bs, sb; @@ -222,11 +227,8 @@ struct ship *from, *to; return from < to; } -void -step(com, sp, moved) -char com; -struct ship *sp; -char *moved; +static void +step(struct ship *sp, int com, char *moved) { int dist; @@ -266,10 +268,7 @@ char *moved; } void -sendbp(from, to, sections, isdefense) -struct ship *from, *to; -int sections; -char isdefense; +sendbp(struct ship *from, struct ship *to, int sections, int isdefense) { int n; struct BP *bp; @@ -278,7 +277,7 @@ char isdefense; for (n = 0; n < NBP && bp[n].turnsent; n++) ; if (n < NBP && sections) { - Write(isdefense ? W_DBP : W_OBP, from, 0, + Write(isdefense ? W_DBP : W_OBP, from, n, turn, to->file->index, sections); if (isdefense) makemsg(from, "repelling boarders"); @@ -288,9 +287,7 @@ char isdefense; } int -is_toughmelee(ship, to, isdefense, count) -struct ship *ship, *to; -int isdefense, count; +is_toughmelee(struct ship *ship, struct ship *to, int isdefense, int count) { struct BP *bp; int obp = 0; @@ -321,7 +318,7 @@ int isdefense, count; } void -reload() +reload(void) { struct ship *sp; @@ -331,7 +328,7 @@ reload() } void -checksails() +checksails(void) { struct ship *sp; int rig, full; @@ -355,6 +352,6 @@ checksails() } else full = 0; if ((sp->file->FS != 0) != full) - Write(W_FS, sp, 0, full, 0, 0, 0); + Write(W_FS, sp, full, 0, 0, 0); } } diff --git a/sail/dr_4.c b/sail/dr_4.c index 4d786dc..664a409 100644 --- a/sail/dr_4.c +++ b/sail/dr_4.c @@ -1,4 +1,4 @@ -/* $NetBSD: dr_4.c,v 1.6 1997/10/13 21:03:37 christos Exp $ */ +/* $NetBSD: dr_4.c,v 1.12 2001/02/05 01:10:09 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,16 +38,15 @@ #if 0 static char sccsid[] = "@(#)dr_4.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: dr_4.c,v 1.6 1997/10/13 21:03:37 christos Exp $"); +__RCSID("$NetBSD: dr_4.c,v 1.12 2001/02/05 01:10:09 christos Exp $"); #endif #endif /* not lint */ -#include "extern.h" #include +#include "extern.h" void -ungrap(from, to) -struct ship *from, *to; +ungrap(struct ship *from, struct ship *to) { int k; char friend; @@ -56,7 +55,7 @@ struct ship *from, *to; return; friend = capship(from)->nationality == capship(to)->nationality; while (--k >= 0) { - if (friend || die() < 3) { + if (friend || dieroll() < 3) { cleangrapple(from, to, 0); makesignal(from, "ungrappling $$", to); } @@ -64,12 +63,11 @@ struct ship *from, *to; } void -grap(from, to) -struct ship *from, *to; +grap(struct ship *from, struct ship *to) { - if (capship(from)->nationality != capship(to)->nationality && die() > 2) + if (capship(from)->nationality != capship(to)->nationality && dieroll() > 2) return; - Write(W_GRAP, from, 0, to->file->index, 0, 0, 0); - Write(W_GRAP, to, 0, from->file->index, 0, 0, 0); + Write(W_GRAP, from, to->file->index, 0, 0, 0); + Write(W_GRAP, to, from->file->index, 0, 0, 0); makesignal(from, "grappled with $$", to); } diff --git a/sail/dr_5.c b/sail/dr_5.c index 6040b7a..93d630a 100644 --- a/sail/dr_5.c +++ b/sail/dr_5.c @@ -1,4 +1,4 @@ -/* $NetBSD: dr_5.c,v 1.5 1997/10/13 19:43:47 christos Exp $ */ +/* $NetBSD: dr_5.c,v 1.11 2001/02/05 01:10:09 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,17 +38,15 @@ #if 0 static char sccsid[] = "@(#)dr_5.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: dr_5.c,v 1.5 1997/10/13 19:43:47 christos Exp $"); +__RCSID("$NetBSD: dr_5.c,v 1.11 2001/02/05 01:10:09 christos Exp $"); #endif #endif /* not lint */ +#include #include "extern.h" void -subtract(from, totalfrom, crewfrom, fromcap, pcfrom) -struct ship *from, *fromcap; -int pcfrom; -int totalfrom, crewfrom[3]; +subtract(struct ship *from, struct ship *fromcap, int totalfrom, int *crewfrom, int pcfrom) { int n; @@ -62,19 +60,16 @@ int totalfrom, crewfrom[3]; totalfrom = 0; } } - Write(W_CREW, from, 0, crewfrom[0], crewfrom[1], crewfrom[2], 0); + Write(W_CREW, from, crewfrom[0], crewfrom[1], crewfrom[2], 0); } else if (totalfrom) { pcfrom -= totalfrom; pcfrom = pcfrom < 0 ? 0 : pcfrom; - Write(W_PCREW, from, 0, pcfrom, 0, 0, 0); + Write(W_PCREW, from, pcfrom, 0, 0, 0); } } int -mensent(from, to, crew, captured, pc, isdefense) -struct ship *from, *to, **captured; -int crew[3], *pc; -char isdefense; +mensent(struct ship *from, struct ship *to, int *crew, struct ship **captured, int *pc, int isdefense) { /* returns # of crew squares sent */ int men = 0; int n; diff --git a/sail/dr_main.c b/sail/dr_main.c index a221243..c3f145d 100644 --- a/sail/dr_main.c +++ b/sail/dr_main.c @@ -1,4 +1,4 @@ -/* $NetBSD: dr_main.c,v 1.5 1997/10/13 19:43:54 christos Exp $ */ +/* $NetBSD: dr_main.c,v 1.11 2001/02/05 01:10:09 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,25 +38,28 @@ #if 0 static char sccsid[] = "@(#)dr_main.c 8.2 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: dr_main.c,v 1.5 1997/10/13 19:43:54 christos Exp $"); +__RCSID("$NetBSD: dr_main.c,v 1.11 2001/02/05 01:10:09 christos Exp $"); #endif #endif /* not lint */ -#include "driver.h" +#include +#include #include #include +#include "extern.h" +#include "driver.h" int -dr_main() +dr_main(void) { int n; struct ship *sp; int nat[NNATION]; int value = 0; - (void) signal(SIGINT, SIG_IGN); - (void) signal(SIGQUIT, SIG_IGN); - (void) signal(SIGTSTP, SIG_IGN); + signal(SIGINT, SIG_IGN); + signal(SIGQUIT, SIG_IGN); + signal(SIGTSTP, SIG_IGN); if (game < 0 || game >= NSCENE) { fprintf(stderr, "DRIVER: Bad game number %d\n", game); exit(1); @@ -72,7 +75,7 @@ dr_main() foreachship(sp) { if (sp->file == NULL && (sp->file = (struct File *)calloc(1, sizeof (struct File))) == NULL) { - (void) fprintf(stderr, "DRIVER: Out of memory.\n"); + fprintf(stderr, "DRIVER: Out of memory.\n"); exit(1); } sp->file->index = sp - SHIP(0); diff --git a/sail/driver.h b/sail/driver.h index 033e1ed..22f87c9 100644 --- a/sail/driver.h +++ b/sail/driver.h @@ -1,4 +1,4 @@ -/* $NetBSD: driver.h,v 1.5 1998/03/29 04:57:19 mrg Exp $ */ +/* $NetBSD: driver.h,v 1.7 2001/01/04 03:21:17 jwise Exp $ */ /* * Copyright (c) 1983, 1993 @@ -35,6 +35,4 @@ * @(#)driver.h 8.2 (Berkeley) 5/3/95 */ -#include "extern.h" - -extern int dtab[]; +extern const int dtab[]; diff --git a/sail/extern.h b/sail/extern.h index cd4d584..5b06cf4 100644 --- a/sail/extern.h +++ b/sail/extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.8 1998/09/13 15:27:30 hubertf Exp $ */ +/* $NetBSD: extern.h,v 1.24 2001/01/04 06:16:51 jwise Exp $ */ /* * Copyright (c) 1983, 1993 @@ -35,34 +35,26 @@ * @(#)externs.h 8.1 (Berkeley) 5/31/93 */ -#include -#include -#include -#include -#include #include #include "machdep.h" /* program mode */ -int mode; -jmp_buf restart; +extern int mode; #define MODE_PLAYER 1 #define MODE_DRIVER 2 #define MODE_LOGGER 3 /* command line flags */ -char debug; /* -D */ -char randomize; /* -x, give first available ship */ -char longfmt; /* -l, print score in long format */ -char nobells; /* -b, don't ring bell before Signal */ +extern int randomize; /* -x, give first available ship */ +extern int longfmt; /* -l, print score in long format */ +extern int nobells; /* -b, don't ring bell before Signal */ /* other initial modes */ -gid_t gid; -gid_t egid; +extern gid_t gid; +extern gid_t egid; -#define die() ((rand() >> 3) % 6 + 1) +#define dieroll() ((random()) % 6 + 1) #define sqr(a) ((a) * (a)) -#define abs(a) ((a) > 0 ? (a) : -(a)) #define min(a,b) ((a) < (b) ? (a) : (b)) #define grappled(a) ((a)->file->ngrap) @@ -216,7 +208,7 @@ struct File { }; struct ship { - char *shipname; /* 0 */ + const char *shipname; /* 0 */ struct shipspecs *specs; /* 2 */ unsigned char nationality; /* 4 */ short shiprow; /* 6 */ @@ -230,7 +222,7 @@ struct scenario { char windspeed; /* 2 */ char windchange; /* 4 */ unsigned char vessels; /* 12 */ - char *name; /* 14 */ + const char *name; /* 14 */ struct ship ship[NSHIP]; /* 16 */ }; extern struct scenario scene[]; @@ -259,8 +251,8 @@ struct shipspecs { }; extern struct shipspecs specs[]; -struct scenario *cc; /* the current scenario */ -struct ship *ls; /* &cc->ship[cc->vessels] */ +extern struct scenario *cc; /* the current scenario */ +extern struct ship *ls; /* &cc->ship[cc->vessels] */ #define SHIP(s) (&cc->ship[s]) #define foreachship(sp) for ((sp) = cc->ship; (sp) < ls; (sp)++) @@ -268,175 +260,157 @@ struct ship *ls; /* &cc->ship[cc->vessels] */ struct windeffects { char A, B, C, D; }; -extern struct windeffects WET[7][6]; +extern const struct windeffects WET[7][6]; struct Tables { char H, G, C, R; }; -extern struct Tables RigTable[11][6]; -extern struct Tables HullTable[11][6]; +extern const struct Tables RigTable[11][6]; +extern const struct Tables HullTable[11][6]; -extern char AMMO[9][4]; -extern char HDT[9][10]; -extern char HDTrake[9][10]; -extern char QUAL[9][5]; -extern char MT[9][3]; +extern const char AMMO[9][4]; +extern const char HDT[9][10]; +extern const char HDTrake[9][10]; +extern const char QUAL[9][5]; +extern const char MT[9][3]; -extern char *countryname[]; -extern char *classname[]; -extern char *directionname[]; -extern char *qualname[]; -extern char loadname[]; +extern const char *const countryname[]; +extern const char *const classname[]; +extern const char *const directionname[]; +extern const char *const qualname[]; +extern const char loadname[]; -extern char rangeofshot[]; +extern const char rangeofshot[]; -extern char dr[], dc[]; +extern const char dr[], dc[]; -int winddir; -int windspeed; -int turn; -int game; -int alive; -int people; -char hasdriver; +extern int winddir; +extern int windspeed; +extern int turn; +extern int game; +extern int alive; +extern int people; +extern int hasdriver; /* assorted.c */ -void table __P((int, int, int, struct ship *, struct ship *, int)); -void Cleansnag __P((struct ship *, struct ship *, int, int)); +void table (struct ship *, struct ship *, int, int, int, int); +void Cleansnag (struct ship *, struct ship *, int, int); /* dr_1.c */ -void unfoul __P((void)); -void boardcomp __P((void)); -int fightitout __P((struct ship *, struct ship *, int)); -void resolve __P((void)); -void compcombat __P((void)); -int next __P((void)); +void unfoul (void); +void boardcomp (void); +void resolve (void); +void compcombat (void); +int next (void); /* dr_2.c */ -void thinkofgrapples __P((void)); -void checkup __P((void)); -void prizecheck __P((void)); -int str_end __P((char *)); -void closeon __P((struct ship *, struct ship *, char[], int, int, int)); -int score __P((char[], struct ship *, struct ship *, int)); -void move_ship __P((char *, struct ship *, unsigned char *, short *, short *, char *)); -void try __P((char[], char [], int, int, int, int, int, struct ship *, - struct ship *, int *, int)); -void rmend __P((char *)); +void thinkofgrapples (void); +void checkup (void); +void prizecheck (void); +void closeon (struct ship *, struct ship *, char *, int, int, int); /* dr_3.c */ -void moveall __P((void)); -int stillmoving __P((int)); -int is_isolated __P((struct ship *)); -int push __P((struct ship *, struct ship *)); -void step __P((int, struct ship *, char *)); -void sendbp __P((struct ship *, struct ship *, int, int)); -int is_toughmelee __P((struct ship *, struct ship *, int, int)); -void reload __P((void)); -void checksails __P((void)); +void moveall (void); +void sendbp (struct ship *, struct ship *, int, int); +int is_toughmelee (struct ship *, struct ship *, int, int); +void reload (void); +void checksails (void); /* dr_4.c */ -void ungrap __P((struct ship *, struct ship *)); -void grap __P((struct ship *, struct ship *)); +void ungrap (struct ship *, struct ship *); +void grap (struct ship *, struct ship *); /* dr_5.c */ -void subtract __P((struct ship *, int, int [3], struct ship *, int)); -int mensent __P((struct ship *, struct ship *, int[3], struct ship **, int *, - int)); +void subtract (struct ship *, struct ship *, int, int [3], int); +int mensent (struct ship *, struct ship *, int[3], struct ship **, int *, + int); /* dr_main.c */ -int dr_main __P((void)); +int dr_main (void); /* game.c */ -int maxturns __P((struct ship *, char *)); -int maxmove __P((struct ship *, int, int)); +int maxturns (struct ship *, char *); +int maxmove (struct ship *, int, int); /* lo_main.c */ -int lo_main __P((void)); +int lo_main (void); /* misc.c */ -int range __P((struct ship *, struct ship *)); -struct ship *closestenemy __P((struct ship *, int, int)); -int angle __P((int, int)); -int gunsbear __P((struct ship *, struct ship *)); -int portside __P((struct ship *, struct ship *, int)); -int colours __P((struct ship *)); -void logger __P((struct ship *)); +int range (struct ship *, struct ship *); +struct ship *closestenemy (struct ship *, int, int); +int gunsbear (struct ship *, struct ship *); +int portside (struct ship *, struct ship *, int); +int colours (struct ship *); +void logger (struct ship *); /* parties.c */ -int meleeing __P((struct ship *, struct ship *)); -int boarding __P((struct ship *, int)); -void unboard __P((struct ship *, struct ship *, int)); +int meleeing (struct ship *, struct ship *); +int boarding (struct ship *, int); +void unboard (struct ship *, struct ship *, int); /* pl_1.c */ -void leave __P((int)) __attribute__((__noreturn__)); -void choke __P((int)) __attribute__((__noreturn__)); -void child __P((int)); +void leave (int) __attribute__((__noreturn__)); +void choke (int) __attribute__((__noreturn__)); +void child (int); /* pl_2.c */ -void play __P((void)); +void play (void) __attribute__((__noreturn__)); /* pl_3.c */ -void acceptcombat __P((void)); -void grapungrap __P((void)); -void unfoulplayer __P((void)); +void acceptcombat (void); +void grapungrap (void); +void unfoulplayer (void); /* pl_4.c */ -void changesail __P((void)); -void acceptsignal __P((void)); -void lookout __P((void)); -char *saywhat __P((struct ship *, int)); -void eyeball __P((struct ship *)); +void changesail (void); +void acceptsignal (void); +void lookout (void); +const char *saywhat (struct ship *, int); +void eyeball (struct ship *); /* pl_5.c */ -void acceptmove __P((void)); -void acceptboard __P((void)); -void parties __P((int[3], struct ship *, int, int)); +void acceptmove (void); +void acceptboard (void); /* pl_6.c */ -void repair __P((void)); -int turned __P((void)); -void loadplayer __P((void)); +void repair (void); +void loadplayer (void); /* pl_7.c */ -void initscreen __P((void)); -void cleanupscreen __P((void)); -void newturn __P((int)); -void Signal __P((const char *, struct ship *, ...)) +void initscreen (void); +void cleanupscreen (void); +void newturn (int); +void Signal (const char *, struct ship *, ...) __attribute__((__format__(__printf__,1,3))); -void Msg __P((const char *, ...)) +void Msg (const char *, ...) __attribute__((__format__(__printf__,1,2))); -void Scroll __P((void)); -void prompt __P((char *, struct ship *)); -void endprompt __P((int)); -int sgetch __P((char *, struct ship *, int)); -void sgetstr __P((char *, char *, int)); -void draw_screen __P((void)); -void draw_view __P((void)); -void draw_turn __P((void)); -void draw_stat __P((void)); -void draw_slot __P((void)); -void draw_board __P((void)); -void centerview __P((void)); -void upview __P((void)); -void downview __P((void)); -void leftview __P((void)); -void rightview __P((void)); -void adjustview __P((void)); +void prompt (const char *, struct ship *); +int sgetch (const char *, struct ship *, int); +void sgetstr (const char *, char *, int); +void draw_screen (void); +void draw_view (void); +void draw_turn (void); +void draw_stat (void); +void draw_slot (void); +void draw_board (void); +void centerview (void); +void upview (void); +void downview (void); +void leftview (void); +void rightview (void); /* pl_main.c */ -int pl_main __P((void)); -void initialize __P((void)); +int pl_main (void); /* sync.c */ -void fmtship __P((char *, size_t, const char *, struct ship *)); -void makesignal __P((struct ship *, const char *, struct ship *, ...)) +void fmtship (char *, size_t, const char *, struct ship *); +void makesignal (struct ship *, const char *, struct ship *, ...) __attribute__((__format__(__printf__,2,4))); -void makemsg __P((struct ship *, const char *, ...)) +void makemsg (struct ship *, const char *, ...) __attribute__((__format__(__printf__,2,3))); -int sync_exists __P((int)); -int sync_open __P((void)); -void sync_close __P((int)); -void Write __P((int, struct ship *, int, long, long, long, long)); -int Sync __P((void)); -int sync_update __P((int, struct ship *, long, long, long, long)); +int sync_exists (int); +int sync_open (void); +void sync_close (int); +void Write (int, struct ship *, long, long, long, long); +void Writestr (int, struct ship *, const char *); +int Sync (void); diff --git a/sail/game.c b/sail/game.c index cd6c8c0..087ab9c 100644 --- a/sail/game.c +++ b/sail/game.c @@ -1,4 +1,4 @@ -/* $NetBSD: game.c,v 1.5 1997/10/13 19:44:09 christos Exp $ */ +/* $NetBSD: game.c,v 1.10 2001/02/05 01:10:09 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,21 +38,21 @@ #if 0 static char sccsid[] = "@(#)game.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: game.c,v 1.5 1997/10/13 19:44:09 christos Exp $"); +__RCSID("$NetBSD: game.c,v 1.10 2001/02/05 01:10:09 christos Exp $"); #endif #endif /* not lint */ +#include #include "extern.h" int -maxturns(ship, af) -struct ship *ship; -char *af; +maxturns(struct ship *ship, char *af) { int turns; turns = ship->specs->ta; - if ((*af = (ship->file->drift > 1 && turns)) != 0) { + *af = (ship->file->drift > 1 && turns); + if (*af != '\0') { turns--; if (ship->file->FS == 1) turns = 0; @@ -61,9 +61,7 @@ char *af; } int -maxmove(ship, dir, fs) -struct ship *ship; -int dir, fs; +maxmove(struct ship *ship, int dir, int fs) { int riggone = 0, Move, flank = 0; diff --git a/sail/globals.c b/sail/globals.c index 01c1415..3415380 100644 --- a/sail/globals.c +++ b/sail/globals.c @@ -1,4 +1,4 @@ -/* $NetBSD: globals.c,v 1.6 1997/10/13 19:44:17 christos Exp $ */ +/* $NetBSD: globals.c,v 1.12 2001/01/04 05:34:56 jwise Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,10 +38,12 @@ #if 0 static char sccsid[] = "@(#)globals.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: globals.c,v 1.6 1997/10/13 19:44:17 christos Exp $"); +__RCSID("$NetBSD: globals.c,v 1.12 2001/01/04 05:34:56 jwise Exp $"); #endif #endif /* not lint */ +#include +#include #include "extern.h" struct scenario scene[] = { @@ -406,7 +408,7 @@ struct shipspecs specs[] = { /* class qual crew2 gunL carL rig1 rig3 */ }; -struct windeffects WET[7][6] = { +const struct windeffects WET[7][6] = { { {9,9,9,9}, {9,9,9,9}, {9,9,9,9}, {9,9,9,9}, {9,9,9,9}, {9,9,9,9} }, { {3,2,2,0}, {3,2,1,0}, {3,2,1,0}, {3,2,1,0}, {2,1,0,0}, {2,1,0,0} }, { {1,1,1,0}, {1,1,0,0}, {1,0,0,0}, {1,0,0,0}, {1,0,0,0}, {1,0,0,0} }, @@ -416,7 +418,7 @@ struct windeffects WET[7][6] = { { {2,1,1,0}, {3,2,1,0}, {3,2,1,0}, {3,2,1,0}, {3,3,2,0}, {3,3,2,0} } }; -struct Tables RigTable[11][6] = { +const struct Tables RigTable[11][6] = { { {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,1}, {0,0,1,0} }, { {0,0,0,0}, {0,0,0,0}, {0,0,0,1}, {0,0,1,0}, {1,0,0,1}, {0,1,1,1} }, { {0,0,0,0}, {0,0,0,1}, {0,0,1,1}, {0,1,0,1}, {0,1,0,1}, {1,0,1,2} }, @@ -429,7 +431,7 @@ struct Tables RigTable[11][6] = { { {1,1,0,4}, {1,0,1,4}, {2,0,0,5}, {0,2,1,5}, {0,1,2,6}, {0,2,0,7} }, { {1,0,1,5}, {0,2,0,6}, {1,2,0,6}, {1,1,1,6}, {2,0,2,6}, {1,1,2,7} } }; -struct Tables HullTable[11][6] = { +const struct Tables HullTable[11][6] = { { {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {1,0,0,0}, {0,1,0,0} }, { {0,0,0,0}, {0,0,0,0}, {0,1,0,0}, {1,1,0,0}, {1,0,1,0}, {1,0,1,1} }, { {0,1,0,0}, {1,0,0,0}, {1,1,0,0}, {1,0,1,0}, {1,0,1,1}, {2,1,0,0} }, @@ -443,7 +445,7 @@ struct Tables HullTable[11][6] = { { {2,2,4,0}, {3,3,1,1}, {4,2,1,1}, {5,1,0,2}, {5,1,2,1}, {6,2,2,0} }, }; -char AMMO[9][4] = { +const char AMMO[9][4] = { { -1, 1, 0, 1 }, { -1, 1, 0, 1 }, { -1, 1, 0, 1 }, @@ -455,7 +457,7 @@ char AMMO[9][4] = { { -3, 2, 0, 3 } }; -char HDT[9][10] = { +const char HDT[9][10] = { { 1, 0,-1,-2,-3,-3,-4,-4,-4,-4 }, { 1, 1, 0,-1,-2,-2,-3,-3,-3,-3 }, { 2, 1, 0,-1,-2,-2,-3,-3,-3,-3 }, @@ -467,7 +469,7 @@ char HDT[9][10] = { { 5, 4, 3, 2, 1, 1, 0, 0, 0, 0 } }; -char HDTrake[9][10] = { +const char HDTrake[9][10] = { { 2, 1, 0,-1,-2,-2,-3,-3,-3,-3 }, { 2, 2, 1, 0,-1,-1,-2,-2,-2,-2 }, { 3, 2, 1, 0,-1,-1,-2,-2,-2,-2 }, @@ -479,7 +481,7 @@ char HDTrake[9][10] = { { 9, 8, 7, 6, 5, 5, 4, 4, 4, 4 } }; -char QUAL[9][5] = { +const char QUAL[9][5] = { { -1, 0, 0, 1, 1 }, { -1, 0, 0, 1, 1 }, { -1, 0, 0, 1, 2 }, @@ -491,7 +493,7 @@ char QUAL[9][5] = { { -2,-1, 0, 2, 3 } }; -char MT[9][3] = { +const char MT[9][3] = { { 1, 0, 0 }, { 1, 1, 0 }, { 2, 1, 0 }, @@ -503,7 +505,7 @@ char MT[9][3] = { { 4, 4, 2 } }; -char rangeofshot[] = { +const char rangeofshot[] = { 0, 1, /* grape */ 3, /* chain */ @@ -511,12 +513,12 @@ char rangeofshot[] = { 1 /* double */ }; -char *countryname[] = { +const char *const countryname[] = { "American", "British", "Spanish", "French", "Japanese", "Federation", "Klingon", "Orion" }; -char *classname[] = { +const char *const classname[] = { "Drift wood", "Ship of the Line", "Ship of the Line", @@ -526,7 +528,7 @@ char *classname[] = { "Brig" }; -char *directionname[] = { +const char *const directionname[] = { "dead ahead", "off the starboard bow", "off the starboard beam", @@ -538,9 +540,30 @@ char *directionname[] = { "dead ahead" }; -char *qualname[] = { "dead", "mutinous", "green", "mundane", "crack", "elite" }; +const char *const qualname[] = { "dead", "mutinous", "green", "mundane", "crack", "elite" }; -char loadname[] = { '-', 'G', 'C', 'R', 'D', 'E' }; +const char loadname[] = { '-', 'G', 'C', 'R', 'D', 'E' }; -char dr[] = { 0, 1, 1, 0, -1, -1, -1, 0, 1 }; -char dc[] = { 0, 0, -1, -1, -1, 0, 1, 1, 1 }; +const char dr[] = { 0, 1, 1, 0, -1, -1, -1, 0, 1 }; +const char dc[] = { 0, 0, -1, -1, -1, 0, 1, 1, 1 }; + +int mode; +jmp_buf restart; + +int randomize; /* -x, give first available ship */ +int longfmt; /* -l, print score in long format */ +int nobells; /* -b, don't ring bell before Signal */ + +gid_t gid; +gid_t egid; + +struct scenario *cc; /* the current scenario */ +struct ship *ls; /* &cc->ship[cc->vessels] */ + +int winddir; +int windspeed; +int turn; +int game; +int alive; +int people; +int hasdriver; diff --git a/sail/lo_main.c b/sail/lo_main.c index 92c5012..38ff057 100644 --- a/sail/lo_main.c +++ b/sail/lo_main.c @@ -1,4 +1,4 @@ -/* $NetBSD: lo_main.c,v 1.5 1997/10/13 19:44:24 christos Exp $ */ +/* $NetBSD: lo_main.c,v 1.11 2001/02/05 01:10:10 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)lo_main.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: lo_main.c,v 1.5 1997/10/13 19:44:24 christos Exp $"); +__RCSID("$NetBSD: lo_main.c,v 1.11 2001/02/05 01:10:10 christos Exp $"); #endif #endif /* not lint */ @@ -47,19 +47,21 @@ __RCSID("$NetBSD: lo_main.c,v 1.5 1997/10/13 19:44:24 christos Exp $"); * * -l force a long listing (print out real usernames) */ -#include + +#include +#include #include #include "extern.h" #include "pathnames.h" -char *title[] = { +const char *const title[] = { "Admiral", "Commodore", "Captain", "Captain", "Captain", "Captain", "Captain", "Commander", "Commander", "Lieutenant" }; int -lo_main() +lo_main(void) { FILE *fp; char sbuf[32]; @@ -85,10 +87,9 @@ lo_main() while (fread((char *)&log, sizeof log, 1, fp) == 1 && log.l_name[0] != '\0') { if (longfmt && (pass = getpwuid(log.l_uid)) != NULL) - (void) sprintf(sbuf, "%10.10s (%s)", - log.l_name, pass->pw_name); + sprintf(sbuf, "%10.10s (%s)", log.l_name, pass->pw_name); else - (void) sprintf(sbuf, "%20.20s", log.l_name); + sprintf(sbuf, "%20.20s", log.l_name); ship = &scene[log.l_gamenum].ship[log.l_shipnum]; printf("%-10s %21s of the %15s %3d points, %5.2f equiv\n", title[n++], sbuf, ship->shipname, log.l_netpoints, diff --git a/sail/main.c b/sail/main.c index b739ecc..c1fc0af 100644 --- a/sail/main.c +++ b/sail/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.6 1997/10/13 21:03:55 christos Exp $ */ +/* $NetBSD: main.c,v 1.20 2001/08/29 18:23:44 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -43,52 +43,58 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\ #if 0 static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: main.c,v 1.6 1997/10/13 21:03:55 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.20 2001/08/29 18:23:44 jsm Exp $"); #endif #endif /* not lint */ -#include "extern.h" -#include +#include +#include +#include #include #include +#include +#include +#include "extern.h" +#include "restart.h" -int main __P((int, char **)); - -/*ARGSUSED*/ int -main(argc, argv) - int argc __attribute__((unused)); - char **argv; +main(int argc, char **argv) { char *p; - int i; + int a,i; + int fd; gid = getgid(); egid = getegid(); setegid(gid); - (void) srand(getpid()); + fd = open("/dev/null", O_RDONLY); + if (fd < 3) + exit(1); + close(fd); + + srandom((u_long)time(NULL)); + if ((p = strrchr(*argv, '/')) != NULL) p++; else p = *argv; + if (strcmp(p, "driver") == 0 || strcmp(p, "saildriver") == 0) mode = MODE_DRIVER; else if (strcmp(p, "sail.log") == 0) mode = MODE_LOGGER; else mode = MODE_PLAYER; - while ((p = *++argv) && *p == '-') - switch (p[1]) { + + while ((a = getopt(argc, argv, "dsxlb")) != -1) + switch (a) { case 'd': mode = MODE_DRIVER; break; case 's': mode = MODE_LOGGER; break; - case 'D': - debug++; - break; case 'x': randomize++; break; @@ -102,12 +108,18 @@ main(argc, argv) fprintf(stderr, "SAIL: Unknown flag %s.\n", p); exit(1); } + + argc -= optind; + argv += optind; + if (*argv) game = atoi(*argv); else game = -1; + if ((i = setjmp(restart)) != 0) mode = i; + switch (mode) { case MODE_PLAYER: return pl_main(); diff --git a/sail/misc.c b/sail/misc.c index 0edf7d8..90c0a9f 100644 --- a/sail/misc.c +++ b/sail/misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: misc.c,v 1.5 1997/10/13 19:44:38 christos Exp $ */ +/* $NetBSD: misc.c,v 1.12 2001/02/05 01:10:10 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,23 +38,26 @@ #if 0 static char sccsid[] = "@(#)misc.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: misc.c,v 1.5 1997/10/13 19:44:38 christos Exp $"); +__RCSID("$NetBSD: misc.c,v 1.12 2001/02/05 01:10:10 christos Exp $"); #endif #endif /* not lint */ -#include -#include +#include +#include #include #include +#include +#include #include "extern.h" #include "pathnames.h" #define distance(x,y) (abs(x) >= abs(y) ? abs(x) + abs(y)/2 : abs(y) + abs(x)/2) +static int angle(int, int); + /* XXX */ int -range(from, to) -struct ship *from, *to; +range(struct ship *from, struct ship *to) { int bow1r, bow1c, bow2r, bow2c; int stern1r, stern1c, stern2c, stern2r; @@ -81,9 +84,7 @@ struct ship *from, *to; } struct ship * -closestenemy(from, side, anyship) -struct ship *from; -char side, anyship; +closestenemy(struct ship *from, int side, int anyship) { struct ship *sp; char a; @@ -109,9 +110,8 @@ char side, anyship; return closest; } -int -angle(dr, dc) -int dr, dc; +static int +angle(int dr, int dc) { int i; @@ -137,9 +137,9 @@ int dr, dc; return i % 8 + 1; } +/* checks for target bow or stern */ int -gunsbear(from, to) /* checks for target bow or stern */ -struct ship *from, *to; +gunsbear(struct ship *from, struct ship *to) { int Dr, Dc, i; int ang; @@ -159,11 +159,10 @@ struct ship *from, *to; return 0; } +/* returns true if fromship is shooting at onship's starboard side */ int -portside(from, on, quick) -struct ship *from, *on; -int quick; /* returns true if fromship is */ -{ /* shooting at onship's starboard side */ +portside(struct ship *from, struct ship *on, int quick) +{ int ang; int Dr, Dc; @@ -181,8 +180,7 @@ int quick; /* returns true if fromship is */ } int -colours(sp) -struct ship *sp; +colours(struct ship *sp) { char flag = '\0'; @@ -199,8 +197,7 @@ struct ship *sp; } void -logger(s) -struct ship *s; +logger(struct ship *s) { FILE *fp; int persons; @@ -227,27 +224,24 @@ struct ship *s; = lp->l_gamenum = lp->l_netpoints = 0; rewind(fp); if (persons < 0) - (void) putw(1, fp); + putw(1, fp); else - (void) putw(persons + 1, fp); + putw(persons + 1, fp); for (lp = log; lp < &log[NLOG]; lp++) if (net > (float)lp->l_netpoints / scene[lp->l_gamenum].ship[lp->l_shipnum].specs->pts) { - (void) fwrite((char *)log, - sizeof (struct logs), lp - log, fp); - (void) strcpy(log[NLOG-1].l_name, s->file->captain); + fwrite((char *)log, sizeof (struct logs), lp - log, fp); + strcpy(log[NLOG-1].l_name, s->file->captain); log[NLOG-1].l_uid = getuid(); log[NLOG-1].l_shipnum = s->file->index; log[NLOG-1].l_gamenum = game; log[NLOG-1].l_netpoints = s->file->points; - (void) fwrite((char *)&log[NLOG-1], - sizeof (struct logs), 1, fp); - (void) fwrite((char *)lp, - sizeof (struct logs), &log[NLOG-1] - lp, fp); + fwrite((char *)&log[NLOG-1], sizeof (struct logs), 1, fp); + fwrite((char *)lp, sizeof (struct logs), &log[NLOG-1] - lp, fp); break; } #ifdef LOCK_EX - (void) flock(fileno(fp), LOCK_UN); + flock(fileno(fp), LOCK_UN); #endif - (void) fclose(fp); + fclose(fp); } diff --git a/sail/parties.c b/sail/parties.c index 3db054c..582e784 100644 --- a/sail/parties.c +++ b/sail/parties.c @@ -1,4 +1,4 @@ -/* $NetBSD: parties.c,v 1.5 1997/10/13 19:44:47 christos Exp $ */ +/* $NetBSD: parties.c,v 1.10 2001/02/05 01:10:10 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,16 +38,15 @@ #if 0 static char sccsid[] = "@(#)parties.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: parties.c,v 1.5 1997/10/13 19:44:47 christos Exp $"); +__RCSID("$NetBSD: parties.c,v 1.10 2001/02/05 01:10:10 christos Exp $"); #endif #endif /* not lint */ +#include #include "extern.h" int -meleeing(from, to) -struct ship *from; -struct ship *to; +meleeing(struct ship *from, struct ship *to) { struct BP *p = from->file->OBP; struct BP *q = p + NBP; @@ -59,9 +58,7 @@ struct ship *to; } int -boarding(from, isdefense) -struct ship *from; -char isdefense; +boarding(struct ship *from, int isdefense) { struct BP *p = isdefense ? from->file->DBP : from->file->OBP; struct BP *q = p + NBP; @@ -73,14 +70,12 @@ char isdefense; } void -unboard(ship, to, isdefense) -struct ship *ship, *to; -char isdefense; +unboard(struct ship *ship, struct ship *to, int isdefense) { struct BP *p = isdefense ? ship->file->DBP : ship->file->OBP; int n; for (n = 0; n < NBP; p++, n++) if (p->turnsent && (p->toship == to || isdefense || ship == to)) - Write(isdefense ? W_DBP : W_OBP, ship, 0, n, 0, 0, 0); + Write(isdefense ? W_DBP : W_OBP, ship, n, 0, 0, 0); } diff --git a/sail/pathnames.h.in b/sail/pathnames.h.in index 4f30015..47f6ba0 100644 --- a/sail/pathnames.h.in +++ b/sail/pathnames.h.in @@ -1,4 +1,4 @@ -/* $NetBSD: pathnames.h,v 1.3 1995/04/22 10:37:06 cgd Exp $ */ +/* $NetBSD: pathnames.h,v 1.4 2000/02/09 22:27:56 jsm Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -36,5 +36,5 @@ */ #define _PATH_LOGFILE "@sail_scorefile@" -#define _PATH_SYNC "@sail_dir@/#sailsink.%d" -#define _PATH_LOCK "@sail_dir@/#saillock.%d" +#define _PATH_SYNC "@sail_dir@/#sailsink.%d" +#define _PATH_LOCK "@sail_dir@/#saillock.%d" diff --git a/sail/pl_1.c b/sail/pl_1.c index 31683d4..3397ddf 100644 --- a/sail/pl_1.c +++ b/sail/pl_1.c @@ -1,4 +1,4 @@ -/* $NetBSD: pl_1.c,v 1.5 1997/10/13 21:04:02 christos Exp $ */ +/* $NetBSD: pl_1.c,v 1.16 2001/02/05 01:10:10 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,14 +38,18 @@ #if 0 static char sccsid[] = "@(#)pl_1.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: pl_1.c,v 1.5 1997/10/13 21:04:02 christos Exp $"); +__RCSID("$NetBSD: pl_1.c,v 1.16 2001/02/05 01:10:10 christos Exp $"); #endif #endif /* not lint */ -#include "player.h" #include #include +#include +#include +#include #include +#include "extern.h" +#include "player.h" /* * If we get here before a ship is chosen, then ms == 0 and @@ -56,14 +60,13 @@ __RCSID("$NetBSD: pl_1.c,v 1.5 1997/10/13 21:04:02 christos Exp $"); * because of a Sync() failure. */ void -leave(conditions) -int conditions; +leave(int conditions) { - (void) signal(SIGHUP, SIG_IGN); - (void) signal(SIGINT, SIG_IGN); - (void) signal(SIGQUIT, SIG_IGN); - (void) signal(SIGALRM, SIG_IGN); - (void) signal(SIGCHLD, SIG_IGN); + signal(SIGHUP, SIG_IGN); + signal(SIGINT, SIG_IGN); + signal(SIGQUIT, SIG_IGN); + signal(SIGALRM, SIG_IGN); + signal(SIGCHLD, SIG_IGN); if (done_curses) { Msg("It looks like you've had it!"); @@ -109,8 +112,8 @@ int conditions; if (conditions != LEAVE_SYNC) { makemsg(ms, "Captain %s relinquishing.", mf->captain); - Write(W_END, ms, 0, 0, 0, 0, 0); - (void) Sync(); + Write(W_END, ms, 0, 0, 0, 0); + Sync(); } } sync_close(!hasdriver); @@ -121,25 +124,23 @@ int conditions; /*ARGSUSED*/ void -choke(n) - int n __attribute__((unused)); +choke(int n __attribute__((__unused__))) { leave(LEAVE_QUIT); } /*ARGSUSED*/ void -child(n) - int n __attribute__((unused)); +child(int n __attribute__((__unused__))) { union wait status; int pid; - (void) signal(SIGCHLD, SIG_IGN); + signal(SIGCHLD, SIG_IGN); do { pid = wait3((int *)&status, WNOHANG, (struct rusage *)0); if (pid < 0 || (pid > 0 && !WIFSTOPPED(status))) hasdriver = 0; } while (pid > 0); - (void) signal(SIGCHLD, child); + signal(SIGCHLD, child); } diff --git a/sail/pl_2.c b/sail/pl_2.c index 1ac1d20..e893726 100644 --- a/sail/pl_2.c +++ b/sail/pl_2.c @@ -1,4 +1,4 @@ -/* $NetBSD: pl_2.c,v 1.4 1997/10/13 19:45:01 christos Exp $ */ +/* $NetBSD: pl_2.c,v 1.10 2001/02/05 01:10:10 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,14 +38,16 @@ #if 0 static char sccsid[] = "@(#)pl_2.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: pl_2.c,v 1.4 1997/10/13 19:45:01 christos Exp $"); +__RCSID("$NetBSD: pl_2.c,v 1.10 2001/02/05 01:10:10 christos Exp $"); #endif #endif /* not lint */ +#include +#include "extern.h" #include "player.h" void -play() +play(void) { struct ship *sp; diff --git a/sail/pl_3.c b/sail/pl_3.c index 0a3bb09..52c6e88 100644 --- a/sail/pl_3.c +++ b/sail/pl_3.c @@ -1,4 +1,4 @@ -/* $NetBSD: pl_3.c,v 1.6 1998/08/30 09:19:40 veego Exp $ */ +/* $NetBSD: pl_3.c,v 1.16 2001/02/05 01:10:10 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,15 +38,17 @@ #if 0 static char sccsid[] = "@(#)pl_3.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: pl_3.c,v 1.6 1998/08/30 09:19:40 veego Exp $"); +__RCSID("$NetBSD: pl_3.c,v 1.16 2001/02/05 01:10:10 christos Exp $"); #endif #endif /* not lint */ -#include "player.h" +#include #include +#include "extern.h" +#include "player.h" void -acceptcombat() +acceptcombat(void) { int men = 0; int target, temp; @@ -177,11 +179,11 @@ acceptcombat() if (windspeed == 6 && temp <= 3) hit--; if (hit >= 0) { - roll = die(); + roll = dieroll(); if (load == L_GRAPE) chits = hit; else { - struct Tables *t; + const struct Tables *t; if (hit > 10) hit = 10; t = &(shootat == RIGGING ? RigTable : HullTable) @@ -197,7 +199,7 @@ acceptcombat() hhits = 0; } } - table(shootat, load, hit, closest, ms, roll); + table(ms, closest, shootat, load, hit, roll); } Msg("Damage inflicted on the %s:", closest->shipname); Msg("\t%d HULL, %d GUNS, %d CREW, %d RIGGING", @@ -219,7 +221,7 @@ acceptcombat() } void -grapungrap() +grapungrap(void) { struct ship *sp; int i; @@ -232,10 +234,10 @@ grapungrap() switch (sgetch("Attempt to grapple or ungrapple $$: ", sp, 1)) { case 'g': - if (die() < 3 + if (dieroll() < 3 || ms->nationality == capship(sp)->nationality) { - Write(W_GRAP, ms, 0, sp->file->index, 0, 0, 0); - Write(W_GRAP, sp, 0, player, 0, 0, 0); + Write(W_GRAP, ms, sp->file->index, 0, 0, 0); + Write(W_GRAP, sp, player, 0, 0, 0); Msg("Attempt succeeds!"); makesignal(ms, "grappled with $$", sp); } else @@ -245,7 +247,7 @@ grapungrap() for (i = grappled2(ms, sp); --i >= 0;) { if (ms->nationality == capship(sp)->nationality - || die() < 3) { + || dieroll() < 3) { cleangrapple(ms, sp, 0); Msg("Attempt succeeds!"); makesignal(ms, "ungrappling with $$", @@ -259,7 +261,7 @@ grapungrap() } void -unfoulplayer() +unfoulplayer(void) { struct ship *to; int i; @@ -270,7 +272,7 @@ unfoulplayer() if (sgetch("Attempt to unfoul with the $$? ", to, 1) != 'y') continue; for (i = fouled2(ms, to); --i >= 0;) { - if (die() <= 2) { + if (dieroll() <= 2) { cleanfoul(ms, to, 0); Msg("Attempt succeeds!"); makesignal(ms, "Unfouling $$", to); diff --git a/sail/pl_4.c b/sail/pl_4.c index 3071930..affc39f 100644 --- a/sail/pl_4.c +++ b/sail/pl_4.c @@ -1,4 +1,4 @@ -/* $NetBSD: pl_4.c,v 1.6 1997/10/13 21:04:17 christos Exp $ */ +/* $NetBSD: pl_4.c,v 1.13 2001/02/05 01:10:11 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,14 +38,17 @@ #if 0 static char sccsid[] = "@(#)pl_4.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: pl_4.c,v 1.6 1997/10/13 21:04:17 christos Exp $"); +__RCSID("$NetBSD: pl_4.c,v 1.13 2001/02/05 01:10:11 christos Exp $"); #endif #endif /* not lint */ +#include +#include +#include "extern.h" #include "player.h" void -changesail() +changesail(void) { int rig, full; @@ -58,12 +61,12 @@ changesail() if (sgetch("Increase to Full sails? ", (struct ship *)0, 1) == 'y') { changed = 1; - Write(W_FS, ms, 0, 1, 0, 0, 0); + Write(W_FS, ms, 1, 0, 0, 0); } } else { if (sgetch("Reduce to Battle sails? ", (struct ship *)0, 1) == 'y') { - Write(W_FS, ms, 0, 0, 0, 0, 0); + Write(W_FS, ms, 0, 0, 0, 0); changed = 1; } } @@ -72,7 +75,7 @@ changesail() } void -acceptsignal() +acceptsignal(void) { char buf[60]; char *p = buf; @@ -83,11 +86,11 @@ acceptsignal() ; p[-1] = '"'; *p = 0; - Write(W_SIGNAL, ms, 1, (long)buf, 0, 0, 0); + Writestr(W_SIGNAL, ms, buf); } void -lookout() +lookout(void) { struct ship *sp; char buf[3]; @@ -104,10 +107,8 @@ lookout() } } -char * -saywhat(sp, flag) -struct ship *sp; -char flag; +const char * +saywhat(struct ship *sp, int flag) { if (sp->file->captain[0]) return sp->file->captain; @@ -122,8 +123,7 @@ char flag; } void -eyeball(ship) -struct ship *ship; +eyeball(struct ship *ship) { int i; diff --git a/sail/pl_5.c b/sail/pl_5.c index 39991ba..44c37c2 100644 --- a/sail/pl_5.c +++ b/sail/pl_5.c @@ -1,4 +1,4 @@ -/* $NetBSD: pl_5.c,v 1.6 1997/10/13 21:04:24 christos Exp $ */ +/* $NetBSD: pl_5.c,v 1.15 2001/02/05 01:10:11 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,16 +38,25 @@ #if 0 static char sccsid[] = "@(#)pl_5.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: pl_5.c,v 1.6 1997/10/13 21:04:24 christos Exp $"); +__RCSID("$NetBSD: pl_5.c,v 1.15 2001/02/05 01:10:11 christos Exp $"); #endif #endif /* not lint */ +#include +#include +#include +#include +#include +#include "extern.h" #include "player.h" +#include "display.h" #define turnfirst(x) (*x == 'r' || *x == 'l') +static void parties(struct ship *, int *, int, int); + void -acceptmove() +acceptmove(void) { int ta; int ma; @@ -65,7 +74,7 @@ acceptmove() ta = maxturns(ms, &af); ma = maxmove(ms, mf->dir, 0); - (void) sprintf(prompt, "move (%d,%c%d): ", ma, af ? '\'' : ' ', ta); + sprintf(prompt, "move (%d,%c%d): ", ma, af ? '\'' : ' ', ta); sgetstr(prompt, buf, sizeof buf); dir = mf->dir; vma = ma; @@ -127,7 +136,7 @@ acceptmove() Msg("Movement error."); if (ta < 0 && moved) { if (mf->FS == 1) { - Write(W_FS, ms, 0, 0, 0, 0, 0); + Write(W_FS, ms, 0, 0, 0, 0); Msg("No hands to set full sails."); } } else if (ma >= 0) @@ -135,20 +144,20 @@ acceptmove() } if (af && !moved) { if (mf->FS == 1) { - Write(W_FS, ms, 0, 0, 0, 0, 0); + Write(W_FS, ms, 0, 0, 0, 0); Msg("No hands to set full sails."); } } if (*buf) - (void) strcpy(movebuf, buf); + strcpy(movebuf, buf); else - (void) strcpy(movebuf, "d"); - Write(W_MOVE, ms, 1, (long)movebuf, 0, 0, 0); + strcpy(movebuf, "d"); + Writestr(W_MOVE, ms, movebuf); Msg("Helm: %s.", movebuf); } void -acceptboard() +acceptboard(void) { struct ship *sp; int n; @@ -184,28 +193,24 @@ acceptboard() if (meleeing(ms, sp) && crew[2]) { c = sgetch("How many more to board the $$? ", sp, 1); - parties(crew, sp, 0, c); + parties(sp, crew, 0, c); } else if ((fouled2(ms, sp) || grappled2(ms, sp)) && crew[2]) { c = sgetch("Crew sections to board the $$ (3 max) ?", sp, 1); - parties(crew, sp, 0, c); + parties(sp, crew, 0, c); } } if (crew[2]) { c = sgetch("How many sections to repel boarders? ", (struct ship *)0, 1); - parties(crew, ms, 1, c); + parties(ms, crew, 1, c); } blockalarm(); draw_slot(); unblockalarm(); } -void -parties(crew, to, isdefense, buf) -struct ship *to; -int crew[3]; -char isdefense; -char buf; +static void +parties(struct ship *to, int *crew, int isdefense, int buf) { int k, j, men; struct BP *ptr; @@ -228,29 +233,29 @@ char buf; } if (buf > '0') Msg("Sending all crew sections."); - Write(isdefense ? W_DBP : W_OBP, ms, 0, + Write(isdefense ? W_DBP : W_OBP, ms, j, turn, to->file->index, men); if (isdefense) { - (void) wmove(slot_w, 2, 0); + wmove(slot_w, 2, 0); for (k=0; k < NBP; k++) if (temp[k] && !crew[k]) - (void) waddch(slot_w, k + '1'); + waddch(slot_w, k + '1'); else - (void) wmove(slot_w, 2, 1 + k); - (void) mvwaddstr(slot_w, 3, 0, "DBP"); + wmove(slot_w, 2, 1 + k); + mvwaddstr(slot_w, 3, 0, "DBP"); makemsg(ms, "repelling boarders"); } else { - (void) wmove(slot_w, 0, 0); + wmove(slot_w, 0, 0); for (k=0; k < NBP; k++) if (temp[k] && !crew[k]) - (void) waddch(slot_w, k + '1'); + waddch(slot_w, k + '1'); else - (void) wmove(slot_w, 0, 1 + k); - (void) mvwaddstr(slot_w, 1, 0, "OBP"); + wmove(slot_w, 0, 1 + k); + mvwaddstr(slot_w, 1, 0, "OBP"); makesignal(ms, "boarding the $$", to); } blockalarm(); - (void) wrefresh(slot_w); + wrefresh(slot_w); unblockalarm(); } else Msg("Sending no crew sections."); diff --git a/sail/pl_6.c b/sail/pl_6.c index e684035..f45ea10 100644 --- a/sail/pl_6.c +++ b/sail/pl_6.c @@ -1,4 +1,4 @@ -/* $NetBSD: pl_6.c,v 1.4 1997/10/13 19:45:33 christos Exp $ */ +/* $NetBSD: pl_6.c,v 1.10 2001/02/05 01:10:11 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,14 +38,18 @@ #if 0 static char sccsid[] = "@(#)pl_6.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: pl_6.c,v 1.4 1997/10/13 19:45:33 christos Exp $"); +__RCSID("$NetBSD: pl_6.c,v 1.10 2001/02/05 01:10:11 christos Exp $"); #endif #endif /* not lint */ +#include +#include "extern.h" #include "player.h" +static int turned(void); + void -repair() +repair(void) { char c; char *repairs; @@ -81,7 +85,7 @@ repair() int max = ptr->guns/4; if (ptr->hull < max) { FIX(hull, max); - Write(W_HULL, ms, 0, ptr->hull, 0, 0, 0); + Write(W_HULL, ms, ptr->hull, 0, 0, 0); } break; } @@ -90,14 +94,14 @@ repair() int max = ptr->guns/5 - ptr->carL; if (ptr->gunL < max) { FIX(gunL, max); - Write(W_GUNL, ms, 0, ptr->gunL, + Write(W_GUNL, ms, ptr->gunL, ptr->carL, 0, 0); } } else { int max = ptr->guns/5 - ptr->carR; if (ptr->gunR < max) { FIX(gunR, max); - Write(W_GUNR, ms, 0, ptr->gunR, + Write(W_GUNR, ms, ptr->gunR, ptr->carR, 0, 0); } } @@ -106,19 +110,19 @@ repair() #define X 2 if (ptr->rig4 >= 0 && ptr->rig4 < X) { FIX(rig4, X); - Write(W_RIG4, ms, 0, ptr->rig4, 0, 0, 0); + Write(W_RIG4, ms, ptr->rig4, 0, 0, 0); } if (count && ptr->rig3 < X) { FIX(rig3, X); - Write(W_RIG3, ms, 0, ptr->rig3, 0, 0, 0); + Write(W_RIG3, ms, ptr->rig3, 0, 0, 0); } if (count && ptr->rig2 < X) { FIX(rig2, X); - Write(W_RIG2, ms, 0, ptr->rig2, 0, 0, 0); + Write(W_RIG2, ms, ptr->rig2, 0, 0, 0); } if (count && ptr->rig1 < X) { FIX(rig1, X); - Write(W_RIG1, ms, 0, ptr->rig1, 0, 0, 0); + Write(W_RIG1, ms, ptr->rig1, 0, 0, 0); } break; } @@ -138,8 +142,8 @@ repair() repaired = 1; } -int -turned() +static int +turned(void) { char *p; @@ -150,7 +154,7 @@ turned() } void -loadplayer() +loadplayer(void) { char c; int loadL, loadR, ready, load; diff --git a/sail/pl_7.c b/sail/pl_7.c index 8977261..82a4afb 100644 --- a/sail/pl_7.c +++ b/sail/pl_7.c @@ -1,4 +1,4 @@ -/* $NetBSD: pl_7.c,v 1.9 1998/08/30 09:19:40 veego Exp $ */ +/* $NetBSD: pl_7.c,v 1.26 2001/12/06 12:21:00 blymn Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,31 +38,52 @@ #if 0 static char sccsid[] = "@(#)pl_7.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: pl_7.c,v 1.9 1998/08/30 09:19:40 veego Exp $"); +__RCSID("$NetBSD: pl_7.c,v 1.26 2001/12/06 12:21:00 blymn Exp $"); #endif #endif /* not lint */ -#include -#include "player.h" -#ifdef __STDC__ +#include +#include #include -#else -#include -#endif +#include +#include #include +#include +#include "extern.h" +#include "player.h" +#include "display.h" +static void Scroll(void); +static void endprompt(int); +static void adjustview(void); /* * Display interface */ static char sc_hasprompt; -static char *sc_prompt; -static char *sc_buf; +static const char *sc_prompt; +static const char *sc_buf; static int sc_line; +WINDOW *view_w; +WINDOW *slot_w; +WINDOW *scroll_w; +WINDOW *stat_w; +WINDOW *turn_w; + +int done_curses; +int loaded, fired, changed, repaired; +int dont_adjust; +int viewrow, viewcol; +char movebuf[sizeof SHIP(0)->file->movebuf]; +int player; +struct ship *ms; /* memorial structure, &cc->ship[player] */ +struct File *mf; /* ms->file */ +struct shipspecs *mc; /* ms->specs */ + void -initscreen() +initscreen(void) { if (!SCREENTEST()) { printf("Can't sail on this terminal.\n"); @@ -75,21 +96,21 @@ initscreen() stat_w = newwin(STAT_Y, STAT_X, STAT_T, STAT_L); turn_w = newwin(TURN_Y, TURN_X, TURN_T, TURN_L); done_curses++; - (void) leaveok(view_w, 1); - (void) leaveok(slot_w, 1); - (void) leaveok(stat_w, 1); - (void) leaveok(turn_w, 1); + leaveok(view_w, 1); + leaveok(slot_w, 1); + leaveok(stat_w, 1); + leaveok(turn_w, 1); noecho(); - crmode(); + cbreak(); } void -cleanupscreen() +cleanupscreen(void) { /* alarm already turned off */ if (done_curses) { - (void) wmove(scroll_w, SCROLL_Y - 1, 0); - (void) wclrtoeol(scroll_w); + wmove(scroll_w, SCROLL_Y - 1, 0); + wclrtoeol(scroll_w); draw_screen(); endwin(); } @@ -97,13 +118,12 @@ cleanupscreen() /*ARGSUSED*/ void -newturn(n) - int n __attribute__((unused)); +newturn(int n __attribute__((__unused__))) { repaired = loaded = fired = changed = 0; movebuf[0] = '\0'; - (void) alarm(0); + alarm(0); if (mf->readyL & R_LOADING) { if (mf->readyL & R_DOUBLE) mf->readyL = R_LOADING; @@ -117,25 +137,25 @@ newturn(n) mf->readyR = R_LOADED; } if (!hasdriver) - Write(W_DDEAD, SHIP(0), 0, 0, 0, 0, 0); + Write(W_DDEAD, SHIP(0), 0, 0, 0, 0); if (sc_hasprompt) { - (void) wmove(scroll_w, sc_line, 0); - (void) wclrtoeol(scroll_w); + wmove(scroll_w, sc_line, 0); + wclrtoeol(scroll_w); } if (Sync() < 0) leave(LEAVE_SYNC); if (!hasdriver) leave(LEAVE_DRIVER); if (sc_hasprompt) - (void) wprintw(scroll_w, "%s%s", sc_prompt, sc_buf); + wprintw(scroll_w, "%s%s", sc_prompt, sc_buf); if (turn % 50 == 0) - Write(W_ALIVE, SHIP(0), 0, 0, 0, 0, 0); + Write(W_ALIVE, SHIP(0), 0, 0, 0, 0); if (mf->FS && (!mc->rig1 || windspeed == 6)) - Write(W_FS, ms, 0, 0, 0, 0, 0); + Write(W_FS, ms, 0, 0, 0, 0); if (mf->FS == 1) - Write(W_FS, ms, 0, 2, 0, 0, 0); + Write(W_FS, ms, 2, 0, 0, 0); if (mf->struck) leave(LEAVE_QUIT); @@ -147,82 +167,55 @@ newturn(n) adjustview(); draw_screen(); - (void) signal(SIGALRM, newturn); - (void) alarm(7); + signal(SIGALRM, newturn); + alarm(7); } /*VARARGS2*/ void -#ifdef __STDC__ Signal(const char *fmt, struct ship *ship, ...) -#else -Signal(va_alist) - va_dcl -#endif { va_list ap; char format[BUFSIZ]; -#ifndef __STDC__ - const char *fmt; - struct ship *ship; - va_start(ap); - fmt = va_arg(ap, const char *); - ship = va_arg(ap, struct ship *); -#else - va_start(ap, ship); -#endif if (!done_curses) return; + va_start(ap, ship); if (*fmt == '\7') putchar(*fmt++); fmtship(format, sizeof(format), fmt, ship); - (void) vwprintw(scroll_w, format, ap); + vwprintw(scroll_w, format, ap); va_end(ap); Scroll(); } /*VARARGS2*/ void -#ifdef __STDC__ Msg(const char *fmt, ...) -#else -Msg(va_alist) - va_dcl -#endif { va_list ap; -#ifndef __STDC__ - const char *fmt; - - va_start(ap); - fmt = va_arg(ap, const char *); -#else - va_start(ap, fmt); -#endif if (!done_curses) return; + va_start(ap, fmt); if (*fmt == '\7') putchar(*fmt++); - (void) vwprintw(scroll_w, fmt, ap); + vwprintw(scroll_w, fmt, ap); va_end(ap); Scroll(); } -void -Scroll() +static void +Scroll(void) { if (++sc_line >= SCROLL_Y) sc_line = 0; - (void) wmove(scroll_w, sc_line, 0); - (void) wclrtoeol(scroll_w); + wmove(scroll_w, sc_line, 0); + wclrtoeol(scroll_w); } void -prompt(p, ship) -char *p; -struct ship *ship; +prompt(const char *p, struct ship *ship) { static char buf[BUFSIZ]; @@ -230,12 +223,11 @@ struct ship *ship; sc_prompt = buf; sc_buf = ""; sc_hasprompt = 1; - (void) waddstr(scroll_w, buf); + waddstr(scroll_w, buf); } -void -endprompt(flag) -char flag; +static void +endprompt(int flag) { sc_hasprompt = 0; if (flag) @@ -243,29 +235,23 @@ char flag; } int -sgetch(p, ship, flag) -char *p; -struct ship *ship; -char flag; +sgetch(const char *p, struct ship *ship, int flag) { int c; prompt(p, ship); blockalarm(); - (void) wrefresh(scroll_w); + wrefresh(scroll_w); unblockalarm(); while ((c = wgetch(scroll_w)) == EOF) ; if (flag && c >= ' ' && c < 0x7f) - (void) waddch(scroll_w, c); + waddch(scroll_w, c); endprompt(flag); return c; } void -sgetstr(pr, buf, n) -char *pr; -char *buf; -int n; +sgetstr(const char *pr, char *buf, int n) { int c; char *p = buf; @@ -275,7 +261,7 @@ int n; for (;;) { *p = 0; blockalarm(); - (void) wrefresh(scroll_w); + wrefresh(scroll_w); unblockalarm(); while ((c = wgetch(scroll_w)) == EOF) ; @@ -286,248 +272,248 @@ int n; return; case '\b': if (p > buf) { - (void) waddstr(scroll_w, "\b \b"); + waddstr(scroll_w, "\b \b"); p--; } break; default: if (c >= ' ' && c < 0x7f && p < buf + n - 1) { *p++ = c; - (void) waddch(scroll_w, c); + waddch(scroll_w, c); } else - (void) putchar('\a'); + putchar('\a'); } } } void -draw_screen() +draw_screen(void) { draw_view(); draw_turn(); draw_stat(); draw_slot(); - (void) wrefresh(scroll_w); /* move the cursor */ + wrefresh(scroll_w); /* move the cursor */ } void -draw_view() +draw_view(void) { struct ship *sp; - (void) werase(view_w); + werase(view_w); foreachship(sp) { if (sp->file->dir && sp->file->row > viewrow && sp->file->row < viewrow + VIEW_Y && sp->file->col > viewcol && sp->file->col < viewcol + VIEW_X) { - (void) wmove(view_w, sp->file->row - viewrow, + wmove(view_w, sp->file->row - viewrow, sp->file->col - viewcol); - (void) waddch(view_w, colours(sp)); - (void) wmove(view_w, + waddch(view_w, colours(sp)); + wmove(view_w, sternrow(sp) - viewrow, sterncol(sp) - viewcol); - (void) waddch(view_w, sterncolour(sp)); + waddch(view_w, sterncolour(sp)); } } - (void) wrefresh(view_w); + wrefresh(view_w); } void -draw_turn() +draw_turn(void) { - (void) wmove(turn_w, 0, 0); - (void) wprintw(turn_w, "%cTurn %d", dont_adjust?'*':'-', turn); - (void) wrefresh(turn_w); + wmove(turn_w, 0, 0); + wprintw(turn_w, "%cTurn %d", dont_adjust?'*':'-', turn); + wrefresh(turn_w); } void -draw_stat() +draw_stat(void) { - (void) wmove(stat_w, STAT_1, 0); - (void) wprintw(stat_w, "Points %3d\n", mf->points); - (void) wprintw(stat_w, "Fouls %2d\n", fouled(ms)); - (void) wprintw(stat_w, "Grapples %2d\n", grappled(ms)); + wmove(stat_w, STAT_1, 0); + wprintw(stat_w, "Points %3d\n", mf->points); + wprintw(stat_w, "Fouls %2d\n", fouled(ms)); + wprintw(stat_w, "Grapples %2d\n", grappled(ms)); - (void) wmove(stat_w, STAT_2, 0); - (void) wprintw(stat_w, " 0 %c(%c)\n", + wmove(stat_w, STAT_2, 0); + wprintw(stat_w, " 0 %c(%c)\n", maxmove(ms, winddir + 3, -1) + '0', maxmove(ms, winddir + 3, 1) + '0'); - (void) waddstr(stat_w, " \\|/\n"); - (void) wprintw(stat_w, " -^-%c(%c)\n", + waddstr(stat_w, " \\|/\n"); + wprintw(stat_w, " -^-%c(%c)\n", maxmove(ms, winddir + 2, -1) + '0', maxmove(ms, winddir + 2, 1) + '0'); - (void) waddstr(stat_w, " /|\\\n"); - (void) wprintw(stat_w, " | %c(%c)\n", + waddstr(stat_w, " /|\\\n"); + wprintw(stat_w, " | %c(%c)\n", maxmove(ms, winddir + 1, -1) + '0', maxmove(ms, winddir + 1, 1) + '0'); - (void) wprintw(stat_w, " %c(%c)\n", + wprintw(stat_w, " %c(%c)\n", maxmove(ms, winddir, -1) + '0', maxmove(ms, winddir, 1) + '0'); - (void) wmove(stat_w, STAT_3, 0); - (void) wprintw(stat_w, "Load %c%c %c%c\n", + wmove(stat_w, STAT_3, 0); + wprintw(stat_w, "Load %c%c %c%c\n", loadname[mf->loadL], readyname(mf->readyL), loadname[mf->loadR], readyname(mf->readyR)); - (void) wprintw(stat_w, "Hull %2d\n", mc->hull); - (void) wprintw(stat_w, "Crew %2d %2d %2d\n", + wprintw(stat_w, "Hull %2d\n", mc->hull); + wprintw(stat_w, "Crew %2d %2d %2d\n", mc->crew1, mc->crew2, mc->crew3); - (void) wprintw(stat_w, "Guns %2d %2d\n", mc->gunL, mc->gunR); - (void) wprintw(stat_w, "Carr %2d %2d\n", mc->carL, mc->carR); - (void) wprintw(stat_w, "Rigg %d %d %d ", mc->rig1, mc->rig2, mc->rig3); + wprintw(stat_w, "Guns %2d %2d\n", mc->gunL, mc->gunR); + wprintw(stat_w, "Carr %2d %2d\n", mc->carL, mc->carR); + wprintw(stat_w, "Rigg %d %d %d ", mc->rig1, mc->rig2, mc->rig3); if (mc->rig4 < 0) - (void) waddch(stat_w, '-'); + waddch(stat_w, '-'); else - (void) wprintw(stat_w, "%d", mc->rig4); - (void) wrefresh(stat_w); + wprintw(stat_w, "%d", mc->rig4); + wrefresh(stat_w); } void -draw_slot() +draw_slot(void) { if (!boarding(ms, 0)) { - (void) mvwaddstr(slot_w, 0, 0, " "); - (void) mvwaddstr(slot_w, 1, 0, " "); + mvwaddstr(slot_w, 0, 0, " "); + mvwaddstr(slot_w, 1, 0, " "); } else - (void) mvwaddstr(slot_w, 1, 0, "OBP"); + mvwaddstr(slot_w, 1, 0, "OBP"); if (!boarding(ms, 1)) { - (void) mvwaddstr(slot_w, 2, 0, " "); - (void) mvwaddstr(slot_w, 3, 0, " "); + mvwaddstr(slot_w, 2, 0, " "); + mvwaddstr(slot_w, 3, 0, " "); } else - (void) mvwaddstr(slot_w, 3, 0, "DBP"); + mvwaddstr(slot_w, 3, 0, "DBP"); - (void) wmove(slot_w, SLOT_Y-4, 0); + wmove(slot_w, SLOT_Y-4, 0); if (mf->RH) - (void) wprintw(slot_w, "%dRH", mf->RH); + wprintw(slot_w, "%dRH", mf->RH); else - (void) waddstr(slot_w, " "); - (void) wmove(slot_w, SLOT_Y-3, 0); + waddstr(slot_w, " "); + wmove(slot_w, SLOT_Y-3, 0); if (mf->RG) - (void) wprintw(slot_w, "%dRG", mf->RG); + wprintw(slot_w, "%dRG", mf->RG); else - (void) waddstr(slot_w, " "); - (void) wmove(slot_w, SLOT_Y-2, 0); + waddstr(slot_w, " "); + wmove(slot_w, SLOT_Y-2, 0); if (mf->RR) - (void) wprintw(slot_w, "%dRR", mf->RR); + wprintw(slot_w, "%dRR", mf->RR); else - (void) waddstr(slot_w, " "); + waddstr(slot_w, " "); #define Y (SLOT_Y/2) - (void) wmove(slot_w, 7, 1); - (void) wprintw(slot_w,"%d", windspeed); - (void) mvwaddch(slot_w, Y, 0, ' '); - (void) mvwaddch(slot_w, Y, 2, ' '); - (void) mvwaddch(slot_w, Y-1, 0, ' '); - (void) mvwaddch(slot_w, Y-1, 1, ' '); - (void) mvwaddch(slot_w, Y-1, 2, ' '); - (void) mvwaddch(slot_w, Y+1, 0, ' '); - (void) mvwaddch(slot_w, Y+1, 1, ' '); - (void) mvwaddch(slot_w, Y+1, 2, ' '); - (void) wmove(slot_w, Y - dr[winddir], 1 - dc[winddir]); + wmove(slot_w, 7, 1); + wprintw(slot_w,"%d", windspeed); + mvwaddch(slot_w, Y, 0, ' '); + mvwaddch(slot_w, Y, 2, ' '); + mvwaddch(slot_w, Y-1, 0, ' '); + mvwaddch(slot_w, Y-1, 1, ' '); + mvwaddch(slot_w, Y-1, 2, ' '); + mvwaddch(slot_w, Y+1, 0, ' '); + mvwaddch(slot_w, Y+1, 1, ' '); + mvwaddch(slot_w, Y+1, 2, ' '); + wmove(slot_w, Y - dr[winddir], 1 - dc[winddir]); switch (winddir) { case 1: case 5: - (void) waddch(slot_w, '|'); + waddch(slot_w, '|'); break; case 2: case 6: - (void) waddch(slot_w, '/'); + waddch(slot_w, '/'); break; case 3: case 7: - (void) waddch(slot_w, '-'); + waddch(slot_w, '-'); break; case 4: case 8: - (void) waddch(slot_w, '\\'); + waddch(slot_w, '\\'); break; } - (void) mvwaddch(slot_w, Y + dr[winddir], 1 + dc[winddir], '+'); - (void) wrefresh(slot_w); + mvwaddch(slot_w, Y + dr[winddir], 1 + dc[winddir], '+'); + wrefresh(slot_w); } void -draw_board() +draw_board(void) { int n; - (void) clear(); - (void) werase(view_w); - (void) werase(slot_w); - (void) werase(scroll_w); - (void) werase(stat_w); - (void) werase(turn_w); + clear(); + werase(view_w); + werase(slot_w); + werase(scroll_w); + werase(stat_w); + werase(turn_w); sc_line = 0; - (void) move(BOX_T, BOX_L); + move(BOX_T, BOX_L); for (n = 0; n < BOX_X; n++) - (void) addch('-'); - (void) move(BOX_B, BOX_L); + addch('-'); + move(BOX_B, BOX_L); for (n = 0; n < BOX_X; n++) - (void) addch('-'); + addch('-'); for (n = BOX_T+1; n < BOX_B; n++) { - (void) mvaddch(n, BOX_L, '|'); - (void) mvaddch(n, BOX_R, '|'); + mvaddch(n, BOX_L, '|'); + mvaddch(n, BOX_R, '|'); } - (void) mvaddch(BOX_T, BOX_L, '+'); - (void) mvaddch(BOX_T, BOX_R, '+'); - (void) mvaddch(BOX_B, BOX_L, '+'); - (void) mvaddch(BOX_B, BOX_R, '+'); - (void) refresh(); + mvaddch(BOX_T, BOX_L, '+'); + mvaddch(BOX_T, BOX_R, '+'); + mvaddch(BOX_B, BOX_L, '+'); + mvaddch(BOX_B, BOX_R, '+'); + refresh(); #define WSaIM "Wooden Ships & Iron Men" - (void) wmove(view_w, 2, (VIEW_X - sizeof WSaIM - 1) / 2); - (void) waddstr(view_w, WSaIM); - (void) wmove(view_w, 4, (VIEW_X - strlen(cc->name)) / 2); - (void) waddstr(view_w, cc->name); - (void) wrefresh(view_w); + wmove(view_w, 2, (VIEW_X - sizeof WSaIM - 1) / 2); + waddstr(view_w, WSaIM); + wmove(view_w, 4, (VIEW_X - strlen(cc->name)) / 2); + waddstr(view_w, cc->name); + wrefresh(view_w); - (void) move(LINE_T, LINE_L); - (void) printw("Class %d %s (%d guns) '%s' (%c%c)", + move(LINE_T, LINE_L); + printw("Class %d %s (%d guns) '%s' (%c%c)", mc->class, classname[mc->class], mc->guns, ms->shipname, colours(ms), sterncolour(ms)); - (void) refresh(); + refresh(); } void -centerview() +centerview(void) { viewrow = mf->row - VIEW_Y / 2; viewcol = mf->col - VIEW_X / 2; } void -upview() +upview(void) { viewrow -= VIEW_Y / 3; } void -downview() +downview(void) { viewrow += VIEW_Y / 3; } void -leftview() +leftview(void) { viewcol -= VIEW_X / 5; } void -rightview() +rightview(void) { viewcol += VIEW_X / 5; } -void -adjustview() +static void +adjustview(void) { if (dont_adjust) return; diff --git a/sail/pl_main.c b/sail/pl_main.c index 362c93e..85fd88e 100644 --- a/sail/pl_main.c +++ b/sail/pl_main.c @@ -1,4 +1,4 @@ -/* $NetBSD: pl_main.c,v 1.6 1997/10/13 19:45:48 christos Exp $ */ +/* $NetBSD: pl_main.c,v 1.15 2001/02/05 01:10:11 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,19 +38,25 @@ #if 0 static char sccsid[] = "@(#)pl_main.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: pl_main.c,v 1.6 1997/10/13 19:45:48 christos Exp $"); +__RCSID("$NetBSD: pl_main.c,v 1.15 2001/02/05 01:10:11 christos Exp $"); #endif #endif /* not lint */ -#include "player.h" -#include -#include +#include +#include +#include #include +#include #include +#include "extern.h" +#include "player.h" +#include "restart.h" + +static void initialize(void); /*ARGSUSED*/ int -pl_main() +pl_main(void) { initialize(); @@ -59,21 +65,21 @@ pl_main() return 0; /* for lint, play() never returns */ } -void -initialize() +static void +initialize(void) { - register struct File *fp; - register struct ship *sp; + struct File *fp; + struct ship *sp; char captain[80]; char message[60]; int load; - register int n; + int n; char *nameptr; int nat[NNATION]; if (game < 0) { - (void) puts("Choose a scenario:\n"); - (void) puts("\n\tNUMBER\tSHIPS\tIN PLAY\tTITLE"); + puts("Choose a scenario:\n"); + puts("\n\tNUMBER\tSHIPS\tIN PLAY\tTITLE"); for (n = 0; n < NSCENE; n++) { /* ( */ printf("\t%d):\t%d\t%s\t%s\n", n, scene[n].vessels, @@ -82,13 +88,13 @@ initialize() } reprint: printf("\nScenario number? "); - (void) fflush(stdout); - (void) scanf("%d", &game); + fflush(stdout); + scanf("%d", &game); while (getchar() != '\n') ; } if (game < 0 || game >= NSCENE) { - (void) puts("Very funny."); + puts("Very funny."); exit(1); } cc = &scene[game]; @@ -99,7 +105,7 @@ reprint: foreachship(sp) { if (sp->file == NULL && (sp->file = (struct File *)calloc(1, sizeof (struct File))) == NULL) { - (void) puts("OUT OF MEMORY"); + puts("OUT OF MEMORY"); exit(1); } sp->file->index = sp - SHIP(0); @@ -111,8 +117,8 @@ reprint: windspeed = cc->windspeed; winddir = cc->winddir; - (void) signal(SIGHUP, choke); - (void) signal(SIGINT, choke); + signal(SIGHUP, choke); + signal(SIGINT, choke); hasdriver = sync_exists(game); if (sync_open() < 0) { @@ -121,8 +127,8 @@ reprint: } if (hasdriver) { - (void) puts("Synchronizing with the other players..."); - (void) fflush(stdout); + puts("Synchronizing with the other players..."); + fflush(stdout); if (Sync() < 0) leave(LEAVE_SYNC); } @@ -132,7 +138,7 @@ reprint: && sp->file->captured == 0) break; if (sp >= ls) { - (void) puts("All ships taken in that scenario."); + puts("All ships taken in that scenario."); foreachship(sp) free((char *)sp->file); sync_close(0); @@ -151,12 +157,12 @@ reprint: sp->specs->pts, saywhat(sp, 1)); printf("\nWhich ship (0-%d)? ", cc->vessels-1); - (void) fflush(stdout); + fflush(stdout); if (scanf("%d", &player) != 1 || player < 0 || player >= cc->vessels) { while (getchar() != '\n') ; - (void) puts("Say what?"); + puts("Say what?"); player = -1; } else while (getchar() != '\n') @@ -168,7 +174,7 @@ reprint: leave(LEAVE_SYNC); fp = SHIP(player)->file; if (fp->captain[0] || fp->struck || fp->captured != 0) - (void) puts("That ship is taken."); + puts("That ship is taken."); else break; } @@ -177,11 +183,11 @@ reprint: mf = ms->file; mc = ms->specs; - Write(W_BEGIN, ms, 0, 0, 0, 0, 0); + Write(W_BEGIN, ms, 0, 0, 0, 0); if (Sync() < 0) leave(LEAVE_SYNC); - (void) signal(SIGCHLD, child); + signal(SIGCHLD, child); if (!hasdriver) switch (fork()) { case 0: @@ -199,25 +205,25 @@ reprint: ms->shipname, mc->guns, classname[mc->class], qualname[mc->qual]); if ((nameptr = (char *) getenv("SAILNAME")) && *nameptr) - (void) strncpy(captain, nameptr, sizeof captain); + strncpy(captain, nameptr, sizeof captain); else { - (void) printf("Your name, Captain? "); - (void) fflush(stdout); - (void) fgets(captain, sizeof captain, stdin); + printf("Your name, Captain? "); + fflush(stdout); + fgets(captain, sizeof captain, stdin); if (!*captain) - (void) strcpy(captain, "no name"); + strcpy(captain, "no name"); else captain[strlen(captain) - 1] = '\0'; } captain[sizeof captain - 1] = '\0'; - Write(W_CAPTAIN, ms, 1, (long)captain, 0, 0, 0); + Writestr(W_CAPTAIN, ms, captain); for (n = 0; n < 2; n++) { char buf[10]; printf("\nInitial broadside %s (grape, chain, round, double): ", n ? "right" : "left"); - (void) fflush(stdout); - (void) scanf("%s", buf); + fflush(stdout); + scanf("%s", buf); switch (*buf) { case 'g': load = L_GRAPE; @@ -245,7 +251,8 @@ reprint: initscreen(); draw_board(); - (void) sprintf(message, "Captain %s assuming command", captain); - Write(W_SIGNAL, ms, 1, (long)message, 0, 0, 0); + snprintf(message, sizeof message, "Captain %s assuming command", + captain); + Writestr(W_SIGNAL, ms, message); newturn(0); } diff --git a/sail/player.h b/sail/player.h index 9b201b3..ea7cde4 100644 --- a/sail/player.h +++ b/sail/player.h @@ -1,4 +1,4 @@ -/* $NetBSD: player.h,v 1.6 1998/03/29 04:57:20 mrg Exp $ */ +/* $NetBSD: player.h,v 1.10 2001/01/04 05:34:56 jwise Exp $ */ /* * Copyright (c) 1983, 1993 @@ -35,9 +35,6 @@ * @(#)player.h 8.2 (Berkeley) 5/3/95 */ -#include -#include "extern.h" - /* sizes and coordinates for the screen */ #define LINE_T 0 @@ -92,28 +89,16 @@ #define SLOT_B VIEW_B #define SLOT_R (SLOT_L+SLOT_X-1) -#ifdef SIGTSTP -#define SCREENTEST() (initscr() != NULL && signal(SIGTSTP, SIG_DFL) != SIG_ERR && STAT_R < COLS && SCROLL_Y > 0) -#else -#define SCREENTEST() (initscr() != NULL && STAT_R < COLS && SCROLL_Y > 0) -#endif - -WINDOW *view_w; -WINDOW *slot_w; -WINDOW *scroll_w; -WINDOW *stat_w; -WINDOW *turn_w; - -char done_curses; -char loaded, fired, changed, repaired; -char dont_adjust; -int viewrow, viewcol; -char movebuf[sizeof SHIP(0)->file->movebuf]; +extern int done_curses; +extern int loaded, fired, changed, repaired; +extern int dont_adjust; +extern int viewrow, viewcol; +extern char movebuf[sizeof SHIP(0)->file->movebuf]; extern char version[]; -int player; -struct ship *ms; /* memorial structure, &cc->ship[player] */ -struct File *mf; /* ms->file */ -struct shipspecs *mc; /* ms->specs */ +extern int player; +extern struct ship *ms; /* memorial structure, &cc->ship[player] */ +extern struct File *mf; /* ms->file */ +extern struct shipspecs *mc; /* ms->specs */ /* condition codes for leave() */ #define LEAVE_QUIT 0 diff --git a/sail/sail.6 b/sail/sail.6 index 2f2db47..1fccdd0 100644 --- a/sail/sail.6 +++ b/sail/sail.6 @@ -1,4 +1,4 @@ -.\" $NetBSD: sail.6,v 1.6 1997/01/07 12:42:25 tls Exp $ +.\" $NetBSD: sail.6,v 1.11 2002/09/26 16:33:54 wiz Exp $ .\" .\" Copyright (c) 1988, 1993 .\" The Regents of the University of California. All rights reserved. @@ -60,17 +60,19 @@ originally developed by S. Craig Taylor. Players of .I Sail take command of an old fashioned Man of War and fight other -players or the computer. They may re-enact one of the many +players or the computer. +They may re-enact one of the many historical sea battles recorded in the game, or they can choose a fictional battle. .PP -As a sea captain in the +As a sea captain in the .I Sail Navy, the player has complete control over the workings of his ship. He must order every maneuver, change the set of his sails, and judge the right moment to let loose the terrible destruction of his broadsides. In addition to fighting the enemy, he must harness the powers of the wind -and sea to make them work for him. The outcome of many battles during the +and sea to make them work for him. +The outcome of many battles during the age of sail was decided by the ability of one captain to hold the `weather gage.' .PP @@ -80,7 +82,8 @@ The flags are: Print the names and ships of the top ten sailors. .TP .B \-l -Show the login name. Only effective with \fB-s\fP. +Show the login name. +Only effective with \fB-s\fP. .TP .B \-x Play the first available ship instead of prompting for a choice. @@ -89,8 +92,9 @@ Play the first available ship instead of prompting for a choice. No bells. .SH IMPLEMENTATION .I Sail -is really two programs in one. Each player starts up a process which -runs his own ship. In addition, a +is really two programs in one. +Each player starts up a process which runs his own ship. +In addition, a .I driver process is forked (by the first player) to run the computer ships and take care of global bookkeeping. @@ -101,38 +105,41 @@ must calculate moves for each ship it controls, the more ships the computer is playing, the slower the game will appear. .PP If a player joins a game in progress, he will synchronize -with the other players (a rather slow process for everyone), and +with the other players (a rather slow process for everyone), and then he may play along with the rest. .PP To implement a multi-user game in Version 7 UNIX, which was the operating system .I Sail was first written under, the communicating processes must use a common -temporary file as a place to read and write messages. In addition, a -locking mechanism must be provided to ensure exclusive access to the -shared file. For example, +temporary file as a place to read and write messages. +In addition, a locking mechanism must be provided to ensure exclusive +access to the shared file. +For example, .I Sail uses a temporary file named /tmp/#sailsink.21 for scenario 21, and -corresponding file names for the other scenarios. To provide exclusive -access to the temporary file, +corresponding file names for the other scenarios. +To provide exclusive +access to the temporary file, .I Sail uses a technique stolen from an old game called "pubcaves" by Jeff Cohen. Processes do a busy wait in the loop .br .sp .ce 2 - for (n = 0; link(sync_file, sync_lock) < 0 && n < 30; n++) + for (n = 0; link(sync_file, sync_lock) \*[Lt] 0 \*[Am]\*[Am] n \*[Lt] 30; n++) sleep(2); .br .sp until they are able to create a link to a file named "/tmp/#saillock.??". -The "??" correspond to the scenario number of the game. Since UNIX +The "??" correspond to the scenario number of the game. +Since UNIX guarantees that a link will point to only one file, the process that succeeds in linking will have exclusive access to the temporary file. .PP -Whether or not this really works is open to speculation. When ucbmiro -was rebooted after a crash, the file system check program found 3 links -between the +Whether or not this really works is open to speculation. +When ucbmiro was rebooted after a crash, the file system check program +found 3 links between the .I Sail temporary file and its link file. .SH CONSEQUENCES OF SEPARATE PLAYER AND DRIVER PROCESSES @@ -141,24 +148,29 @@ the driver must coordinate the action with the other ships in the game. For example, if a player wants to move in a certain direction, he writes a message into the temporary file requesting the driver to move his ship. Each ``turn,'' the driver reads all the messages sent from the players and -decides what happened. It then writes back into the temporary file new -values of variables, etc. +decides what happened. +It then writes back into the temporary file new values of variables, etc. .PP The most noticeable effect this communication has on the game is the -delay in moving. Suppose a player types a move for his ship and hits -return. What happens then? The player process saves up messages to -be written to the temporary file in a buffer. Every 7 seconds or so, the -player process gets exclusive access to the temporary file and writes -out its buffer to the file. The driver, running asynchronously, must -read in the movement command, process it, and write out the results. This -takes two exclusive accesses to the temporary file. Finally, when the player -process gets around to doing another 7 second update, the results of the -move are displayed on the screen. Hence, every movement requires four +delay in moving. +Suppose a player types a move for his ship and hits return. +What happens then? +The player process saves up messages to +be written to the temporary file in a buffer. +Every 7 seconds or so, the player process gets exclusive access to +the temporary file and writes out its buffer to the file. +The driver, running asynchronously, must +read in the movement command, process it, and write out the results. +This takes two exclusive accesses to the temporary file. +Finally, when the player process gets around to doing another 7 second +update, the results of the move are displayed on the screen. +Hence, every movement requires four exclusive accesses to the temporary file (anywhere from 7 to 21 seconds depending upon asynchrony) before the player sees the results of his moves. .PP -In practice, the delays are not as annoying as they would appear. There -is room for "pipelining" in the movement. After the player writes out +In practice, the delays are not as annoying as they would appear. +There is room for "pipelining" in the movement. +After the player writes out a first movement message, a second movement command can then be issued. The first message will be in the temporary file waiting for the driver, and the second will be in the file buffer waiting to be written to the file. @@ -166,19 +178,22 @@ Thus, by always typing moves a turn ahead of the time, the player can sail around quite quickly. .PP If the player types several movement commands between two 7 second updates, -only the last movement command typed will be seen by the driver. Movement -commands within the same update "overwrite" each other, in a sense. -.SH THE HISTORY OF SAIL +only the last movement command typed will be seen by the driver. +Movement commands within the same update "overwrite" each other, in a sense. +.SH THE HISTORY OF SAIL I wrote the first version of .I Sail -on a PDP 11/70 in the fall of 1980. Needless to say, the code was horrendous, -not portable in any sense of the word, and didn't work. The program was not -very modular and had fseeks() and fwrites() every few lines. After a -tremendous rewrite from the top down, I got the first working version up by -1981. There were several annoying bugs concerning firing broadsides and +on a PDP 11/70 in the fall of 1980. +Needless to say, the code was horrendous, +not portable in any sense of the word, and didn't work. +The program was not +very modular and had fseeks() and fwrites() every few lines. +After a tremendous rewrite from the top down, +I got the first working version up by 1981. +There were several annoying bugs concerning firing broadsides and finding angles. .I Sail -uses no floating point, by the way, so the direction routines are rather +uses no floating point, by the way, so the direction routines are rather tricky. Ed Wang rewrote my angle() routine in 1981 to be more correct (although it still doesn't work perfectly), and he added code to let a player select @@ -187,12 +202,14 @@ available). .PP Captain Happy (Craig Leres) is responsible for making .I Sail -portable for the first time. This was no easy task, by the way. Constants -like 2 and 10 were very frequent in the code. I also became famous for -using "Riggle Memorial Structures" in +portable for the first time. +This was no easy task, by the way. +Constants like 2 and 10 were very frequent in the code. +I also became famous for using "Riggle Memorial Structures" in .I Sail. Many of my structure references are so long that they run off the line -printer page. Here is an example, if you promise not to laugh. +printer page. +Here is an example, if you promise not to laugh. .br .sp .ce @@ -202,15 +219,19 @@ specs[scene[flog.fgamenum].ship[flog.fshipnum].shipnum].pts .PP .I Sail received its fourth and most thorough rewrite in the summer and fall -of 1983. Ed Wang rewrote and modularized the code (a monumental feat) -almost from scratch. Although he introduced many new bugs, the final -result was very much cleaner and (?) faster. He added window movement -commands and find ship commands. +of 1983. +Ed Wang rewrote and modularized the code (a monumental feat) +almost from scratch. +Although he introduced many new bugs, the final result was very much +cleaner and (?) faster. +He added window movement commands and find ship commands. .SH HISTORICAL INFO Old Square Riggers were very maneuverable ships capable of intricate -sailing. Their only disadvantage was an inability to sail very -close to the wind. The design of a wooden ship allowed only for the -guns to bear to the left and right sides. A few guns of small +sailing. +Their only disadvantage was an inability to sail very close to the wind. +The design of a wooden ship allowed only for the +guns to bear to the left and right sides. +A few guns of small aspect (usually 6 or 9 pounders) could point forward, but their effect was small compared to a 68 gun broadside of 24 or 32 pounders. The guns bear approximately like so: @@ -229,9 +250,10 @@ The guns bear approximately like so: .fi An interesting phenomenon occurred when a broadside was fired -down the length of an enemy ship. The shot tended to bounce along -the deck and did several times more damage. This phenomenon was called -a rake. Because the bows of a ship are very strong and present a smaller +down the length of an enemy ship. +The shot tended to bounce along the deck and did several times more damage. +This phenomenon was called a rake. +Because the bows of a ship are very strong and present a smaller target than the stern, a stern rake (firing from the stern to the bow) causes more damage than a bow rake. .nf @@ -242,91 +264,109 @@ more damage than a bow rake. .fi Most ships were equipped with carronades, which were very large, close -range cannons. American ships from the revolution until the War of 1812 +range cannons. +American ships from the revolution until the War of 1812 were almost entirely armed with carronades. .PP The period of history covered in .I Sail is approximately from the 1770's until the end of Napoleonic France in 1815. -There are many excellent books about the age of sail. My favorite author -is Captain Frederick Marryat. More contemporary authors include C.S. Forester -and Alexander Kent. +There are many excellent books about the age of sail. +My favorite author is Captain Frederick Marryat. +More contemporary authors include C.S. Forester and Alexander Kent. .PP -Fighting ships came in several sizes classed by armament. The mainstays of -any fleet were its "Ships of the Line", or "Line of Battle Ships". They -were so named because these ships fought together in great lines. They were +Fighting ships came in several sizes classed by armament. +The mainstays of +any fleet were its "Ships of the Line", or "Line of Battle Ships". +They were so named because these ships fought together in great lines. +They were close enough for mutual support, yet every ship could fire both its broadsides. We get the modern words "ocean liner," or "liner," and "battleship" from -"ship of the line." The most common size was the 74 gun two decked -ship of the line. The two gun decks usually mounted 18 and 24 pounder guns. +"ship of the line." +The most common size was the 74 gun two decked ship of the line. +The two gun decks usually mounted 18 and 24 pounder guns. .PP -The pride of the fleet were the first rates. These were huge three decked -ships of the line mounting 80 to 136 guns. The guns in the three tiers +The pride of the fleet were the first rates. +These were huge three decked ships of the line mounting 80 to 136 guns. +The guns in the three tiers were usually 18, 24, and 32 pounders in that order from top to bottom. .PP -Various other ships came next. They were almost all "razees," or ships -of the line with one deck sawed off. They mounted 40-64 guns and were -a poor cross between a frigate and a line of battle ship. They neither -had the speed of the former nor the firepower of the latter. +Various other ships came next. +They were almost all "razees," or ships of the line with one deck sawed off. +They mounted 40-64 guns and were +a poor cross between a frigate and a line of battle ship. +They neither had the speed of the former nor the firepower of the latter. .PP -Next came the "eyes of the fleet." Frigates came in many sizes mounting -anywhere from 32 to 44 guns. They were very handy vessels. They could -outsail anything bigger and outshoot anything smaller. Frigates didn't -fight in lines of battle as the much bigger 74's did. Instead, they -harassed the enemy's rear or captured crippled ships. They were much -more useful in missions away from the fleet, such as cutting out expeditions -or boat actions. They could hit hard and get away fast. +Next came the "eyes of the fleet." +Frigates came in many sizes mounting anywhere from 32 to 44 guns. +They were very handy vessels. +They could outsail anything bigger and outshoot anything smaller. +Frigates didn't fight in lines of battle as the much bigger 74's did. +Instead, they harassed the enemy's rear or captured crippled ships. +They were much more useful in missions away from the fleet, +such as cutting out expeditions or boat actions. +They could hit hard and get away fast. .PP -Lastly, there were the corvettes, sloops, and brigs. These were smaller -ships mounting typically fewer than 20 guns. A corvette was only slightly -smaller than a frigate, so one might have up to 30 guns. Sloops were used -for carrying dispatches or passengers. Brigs were something you built for -land-locked lakes. +Lastly, there were the corvettes, sloops, and brigs. +These were smaller ships mounting typically fewer than 20 guns. +A corvette was only slightly +smaller than a frigate, so one might have up to 30 guns. +Sloops were used for carrying dispatches or passengers. +Brigs were something you built for land-locked lakes. .SH SAIL PARTICULARS Ships in .I Sail -are represented by two characters. One character represents the bow of -the ship, and the other represents the stern. Ships have nationalities -and numbers. The first ship of a nationality is number 0, the second -number 1, etc. Therefore, the first British ship in a game would be -printed as "b0". The second Brit would be "b1", and the fifth Don -would be "s4". +are represented by two characters. +One character represents the bow of +the ship, and the other represents the stern. +Ships have nationalities and numbers. +The first ship of a nationality is number 0, the second +number 1, etc. +Therefore, the first British ship in a game would be printed as "b0". +The second Brit would be "b1", and the fifth Don would be "s4". .PP Ships can set normal sails, called Battle Sails, or bend on extra canvas -called Full Sails. A ship under full sail is a beautiful sight indeed, -and it can move much faster than a ship under Battle Sails. The only -trouble is, with full sails set, there is so much tension on sail and +called Full Sails. +A ship under full sail is a beautiful sight indeed, +and it can move much faster than a ship under Battle Sails. +The only trouble is, with full sails set, there is so much tension on sail and rigging that a well aimed round shot can burst a sail into ribbons where -it would only cause a little hole in a loose sail. For this reason, -rigging damage is doubled on a ship with full sails set. Don't let -that discourage you from using full sails. I like to keep them up -right into the heat of battle. A ship -with full sails set has a capital letter for its nationality. E.g., -a Frog, "f0", with full sails set would be printed as "F0". +it would only cause a little hole in a loose sail. +For this reason, rigging damage is doubled on a ship with full sails set. +Don't let that discourage you from using full sails. +I like to keep them up right into the heat of battle. +A ship with full sails set has a capital letter for its nationality. +E.g., a Frog, "f0", with full sails set would be printed as "F0". .PP When a ship is battered into a listing hulk, the last man aboard "strikes -the colors." This ceremony is the ship's formal surrender. The nationality -character -of a surrendered ship is printed as "!". E.g., the Frog of our last example -would soon be "!0". +the colors." +This ceremony is the ship's formal surrender. +The nationality character of a surrendered ship is printed as "!". +E.g., the Frog of our last example would soon be "!0". .PP A ship has a random chance of catching fire or sinking when it reaches the -stage of listing hulk. A sinking ship has a "~" printed for its nationality, +stage of listing hulk. +A sinking ship has a "~" printed for its nationality, and a ship on fire and about to explode has a "#" printed. .PP -Captured ships become the nationality of the prize crew. Therefore, if +Captured ships become the nationality of the prize crew. +Therefore, if an American ship captures a British ship, the British ship will have an -"a" printed for its nationality. In addition, the ship number is changed -to "&","'", "(", ,")", "*", or "+" depending upon the original number, -be it 0,1,2,3,4, or 5. E.g., the "b0" captured by an American becomes the -"a&". The "s4" captured by a Frog becomes the "f*". +"a" printed for its nationality. +In addition, the ship number is changed +to "\*[Am]","'", "(", ,")", "*", or "+" depending upon the original number, +be it 0,1,2,3,4, or 5. +E.g., the "b0" captured by an American becomes the +"a\*[Am]". +The "s4" captured by a Frog becomes the "f*". .PP The ultimate example is, of course, an exploding Brit captured by an -American: "#&". +American: "#\*[Am]". .SH MOVEMENT -Movement is the most confusing part of +Movement is the most confusing part of .I Sail -to many. Ships can head in 8 directions: +to many. +Ships can head in 8 directions: .nf 0 0 0 @@ -334,26 +374,31 @@ to many. Ships can head in 8 directions: 0 0 0 .fi -The stern of a ship moves when it turns. The bow remains stationary. +The stern of a ship moves when it turns. +The bow remains stationary. Ships can always turn, regardless of the wind (unless they are becalmed). -All ships drift when they lose headway. If a ship doesn't move forward -at all for two turns, it will begin to drift. If a ship has begun to +All ships drift when they lose headway. +If a ship doesn't move forward at all for two turns, it will begin to drift. +If a ship has begun to drift, then it must move forward before it turns, if it plans to do more than make a right or left turn, which is always possible. .PP -Movement commands to +Movement commands to .I Sail -are a string of forward moves and turns. An example is "l3". It will -turn a ship left and then move it ahead 3 spaces. In the drawing above, -the "b0" made 7 successive left turns. When +are a string of forward moves and turns. +An example is "l3". +It will turn a ship left and then move it ahead 3 spaces. +In the drawing above, the "b0" made 7 successive left turns. +When .I Sail -prompts you for a move, it prints three characters of import. E.g., +prompts you for a move, it prints three characters of import. +E.g., .nf - move (7, 4): + move (7, 4): .fi -The first number is the maximum number of moves you can make, -including turns. The second number is the maximum number of turns -you can make. Between the numbers is sometimes printed a quote "'". +The first number is the maximum number of moves you can make, including turns. +The second number is the maximum number of turns you can make. +Between the numbers is sometimes printed a quote "'". If the quote is present, it means that your ship has been drifting, and you must move ahead to regain headway before you turn (see note above). Some of the possible moves for the example above are as follows: @@ -371,7 +416,8 @@ Some of the possible moves for the example above are as follows: .fi Because square riggers performed so poorly sailing into the wind, if at any point in a movement command you turn into the wind, the movement stops -there. E.g., +there. +E.g., .ne 1i .nf @@ -381,17 +427,20 @@ there. E.g., .fi Moreover, whenever you make a turn, your movement allowance drops to -min(what's left, what you would have at the new attitude). In short, -if you turn closer to the wind, you most likely won't be able to sail the -full allowance printed in the "move" prompt. +min(what's left, what you would have at the new attitude). +In short, if you turn closer to the wind, you most likely won't be able +to sail the full allowance printed in the "move" prompt. .PP -Old sailing captains had to keep an eye constantly on the wind. Captains -in +Old sailing captains had to keep an eye constantly on the wind. +Captains in .I Sail -are no different. A ship's ability to move depends on its attitude to the -wind. The best angle possible is to have the wind off your quarter, that is, -just off the stern. The direction rose on the side of the screen gives the -possible movements for your ship at all positions to the wind. Battle +are no different. +A ship's ability to move depends on its attitude to the wind. +The best angle possible is to have the wind off your quarter, that is, +just off the stern. +The direction rose on the side of the screen gives the +possible movements for your ship at all positions to the wind. +Battle sail speeds are given first, and full sail speeds are given in parenthesis. .nf @@ -400,21 +449,25 @@ sail speeds are given first, and full sail speeds are given in parenthesis. -^-3(6) /|\\ | 4(7) - 3(6) + 3(6) .fi Pretend the bow of your ship (the "^") is pointing upward and the wind is -blowing from the bottom to the top of the page. The -numbers at the bottom "3(6)" will be your speed under battle or full -sails in such a situation. If the wind is off your quarter, then you -can move "4(7)". If the wind is off your beam, "3(6)". If the wind is -off your bow, then you can only move "1(2)". Facing into the wind, you -can't move at all. Ships facing into the wind were said to be "in irons". +blowing from the bottom to the top of the page. +The numbers at the bottom "3(6)" will be your speed under battle or full +sails in such a situation. +If the wind is off your quarter, then you can move "4(7)". +If the wind is off your beam, "3(6)". +If the wind is off your bow, then you can only move "1(2)". +Facing into the wind, you can't move at all. +Ships facing into the wind were said to be "in irons". .SH WINDSPEED AND DIRECTION The windspeed and direction is displayed as a little weather vane on the -side of the screen. The number in the middle of the vane indicates the wind -speed, and the + to - indicates the wind direction. The wind blows from -the + sign (high pressure) to the - sign (low pressure). E.g., +side of the screen. +The number in the middle of the vane indicates the wind +speed, and the + to - indicates the wind direction. +The wind blows from the + sign (high pressure) to the - sign (low pressure). +E.g., .nf | @@ -426,9 +479,11 @@ The wind speeds are 0 = becalmed, 1 = light breeze, 2 = moderate breeze, 3 = fresh breeze, 4 = strong breeze, 5 = gale, 6 = full gale, 7 = hurricane. If a hurricane shows up, all ships are destroyed. .SH GRAPPLING AND FOULING -If two ships collide, they run the risk of becoming tangled together. This -is called "fouling." Fouled ships are stuck together, and neither can move. -They can unfoul each other if they want to. Boarding parties can only be +If two ships collide, they run the risk of becoming tangled together. +This is called "fouling." +Fouled ships are stuck together, and neither can move. +They can unfoul each other if they want to. +Boarding parties can only be sent across to ships when the antagonists are either fouled or grappled. .PP Ships can grapple each other by throwing grapnels into the rigging of @@ -437,8 +492,8 @@ the other. The number of fouls and grapples you have are displayed on the upper right of the screen. .SH BOARDING -Boarding was a very costly venture in terms of human life. Boarding parties -may be formed in +Boarding was a very costly venture in terms of human life. +Boarding parties may be formed in .I Sail to either board an enemy ship or to defend your own ship against attack. Men organized as Defensive Boarding Parties fight twice as hard to save @@ -447,102 +502,122 @@ their ship as men left unorganized. The boarding strength of a crew depends upon its quality and upon the number of men sent. .SH CREW QUALITY -The British seaman was world renowned for his sailing abilities. American -sailors, however, were actually the best seamen in the world. Because the -American Navy offered twice the wages of the Royal Navy, British seamen +The British seaman was world renowned for his sailing abilities. +American sailors, however, were actually the best seamen in the world. +Because the +American Navy offered twice the wages of the Royal Navy, British seamen who liked the sea defected to America by the thousands. .PP -In +In .I Sail, -crew quality is quantized into 5 energy levels. "Elite" crews can outshoot -and outfight all other sailors. "Crack" crews are next. "Mundane" crews -are average, and "Green" and "Mutinous" crews are below average. A good -rule of thumb is that "Crack" or "Elite" crews get one extra hit -per broadside compared to "Mundane" crews. Don't expect too much from +crew quality is quantized into 5 energy levels. +"Elite" crews can outshoot and outfight all other sailors. +"Crack" crews are next. +"Mundane" crews +are average, and "Green" and "Mutinous" crews are below average. +A good rule of thumb is that "Crack" or "Elite" crews get one extra hit +per broadside compared to "Mundane" crews. +Don't expect too much from "Green" crews. .pl -1 .SH BROADSIDES Your two broadsides may be loaded with four kinds of shot: grape, chain, -round, and double. You have guns and carronades in both the port and starboard -batteries. Carronades only have a range of two, so you have to get in -close to be able to fire them. You have the choice of firing at the hull -or rigging of another ship. If the range of the ship is greater than 6, +round, and double. +You have guns and carronades in both the port and starboard batteries. +Carronades only have a range of two, so you have to get in +close to be able to fire them. +You have the choice of firing at the hull or rigging of another ship. +If the range of the ship is greater than 6, then you may only shoot at the rigging. .PP The types of shot and their advantages are: .SH ROUND -Range of 10. Good for hull or rigging hits. +Range of 10. +Good for hull or rigging hits. .SH DOUBLE -Range of 1. Extra good for hull or rigging hits. +Range of 1. +Extra good for hull or rigging hits. Double takes two turns to load. .SH CHAIN -Range of 3. Excellent for tearing down rigging. +Range of 3. +Excellent for tearing down rigging. Cannot damage hull or guns, though. .SH GRAPE -Range of 1. Sometimes devastating against enemy crews. +Range of 1. +Sometimes devastating against enemy crews. .PP On the side of the screen is displayed some vital information about your ship: .nf Load D! R! - Hull 9 + Hull 9 Crew 4 4 2 - Guns 4 4 - Carr 2 2 + Guns 4 4 + Carr 2 2 Rigg 5 5 5 5 .fi "Load" shows what your port (left) and starboard (right) broadsides are -loaded with. A "!" after the type of shot indicates that it is an initial -broadside. Initial broadside were loaded with care before battle and before -the decks ran red with blood. As a consequence, initial broadsides are a -little more effective than broadsides loaded later. A "*" after the type of -shot indicates that the gun -crews are still loading it, and you cannot fire yet. "Hull" shows how much -hull you have left. "Crew" shows your three sections of crew. As your -crew dies off, your ability to fire decreases. "Guns" and "Carr" show -your port and starboard guns. As you lose guns, your ability to fire -decreases. "Rigg" shows how much rigging you have on your 3 or 4 masts. +loaded with. +A "!" after the type of shot indicates that it is an initial broadside. +Initial broadside were loaded with care before battle and before +the decks ran red with blood. +As a consequence, initial broadsides are a +little more effective than broadsides loaded later. +A "*" after the type of shot indicates that the gun +crews are still loading it, and you cannot fire yet. +"Hull" shows how much hull you have left. +"Crew" shows your three sections of crew. +As your crew dies off, your ability to fire decreases. +"Guns" and "Carr" show your port and starboard guns. +As you lose guns, your ability to fire decreases. +"Rigg" shows how much rigging you have on your 3 or 4 masts. As rigging is shot away, you lose mobility. .SH EFFECTIVENESS OF FIRE It is very dramatic when a ship fires its thunderous broadsides, but the -mere opportunity to fire them does not guarantee any hits. Many factors -influence the destructive force of a broadside. First of all, and the chief -factor, is distance. It is harder to hit a ship at range ten than it is -to hit one sloshing alongside. Next is raking. Raking fire, as -mentioned before, -can sometimes dismast a ship at range ten. Next, crew size and quality affects -the damage done by a broadside. The number of guns firing also bears on the -point, -so to speak. Lastly, weather affects the accuracy of a broadside. If the -seas are high (5 or 6), then the lower gunports of ships of the line can't -even be opened to run out the guns. This gives frigates and other flush -decked vessels an advantage in a storm. The scenario +mere opportunity to fire them does not guarantee any hits. +Many factors influence the destructive force of a broadside. +First of all, and the chief factor, is distance. +It is harder to hit a ship at range ten than it is +to hit one sloshing alongside. +Next is raking. +Raking fire, as mentioned before, can sometimes dismast a ship at range ten. +Next, crew size and quality affects the damage done by a broadside. +The number of guns firing also bears on the point, so to speak. +Lastly, weather affects the accuracy of a broadside. +If the seas are high (5 or 6), then the lower gunports +of ships of the line can't even be opened to run out the guns. +This gives frigates and other flush decked vessels an advantage in a storm. +The scenario .I Pellew vs. The Droits de L'Homme takes advantage of this peculiar circumstance. .SH REPAIRS Repairs may be made to your Hull, Guns, and Rigging at the slow rate of -two points per three turns. The message "Repairs Completed" will be -printed if no more repairs can be made. +two points per three turns. +The message "Repairs Completed" will be printed if no more repairs can be made. .SH PECULIARITIES OF COMPUTER SHIPS -Computer ships in +Computer ships in .I Sail -follow all the rules above with a few exceptions. Computer ships never -repair damage. If they did, the players could never beat them. They -play well enough as it is. As a consolation, the computer ships can fire double -shot every turn. That fluke is a good reason to keep your distance. The -.I -Driver -figures out the moves of the computer ships. It computes them with a typical -A.I. distance function and a depth first search to find the maximum "score." +follow all the rules above with a few exceptions. +Computer ships never repair damage. +If they did, the players could never beat them. +They play well enough as it is. +As a consolation, the computer ships can fire double shot every turn. +That fluke is a good reason to keep your distance. +The +.I Driver +figures out the moves of the computer ships. +It computes them with a typical A.I. distance +function and a depth first search to find the maximum "score." It seems to work fairly well, although I'll be the first to admit it isn't perfect. .SH HOW TO PLAY -Commands are given to +Commands are given to .I Sail -by typing a single character. You will then be prompted for further -input. A brief summary of the commands follows. +by typing a single character. +You will then be prompted for further input. +A brief summary of the commands follows. .br .SH COMMAND SUMMARY .nf @@ -550,7 +625,7 @@ input. A brief summary of the commands follows. 'f' Fire broadsides if they bear 'l' Reload 'L' Unload broadsides (to change ammo) - 'm' Move + 'm' Move 'i' Print the closest ship 'I' Print all ships 'F' Find a particular ship or ships (e.g. "a?" for all Americans) @@ -575,7 +650,7 @@ input. A brief summary of the commands follows. .fi .bg .SH SCENARIOS -Here is a summary of the scenarios in +Here is a summary of the scenarios in .I Sail: .br @@ -590,7 +665,8 @@ Wind from the N, blowing a fresh breeze. Wind from the S, blowing a fresh breeze. .fi -This is John Paul Jones' first famous battle. Aboard the Bonhomme +This is John Paul Jones' first famous battle. +Aboard the Bonhomme Richard, he was able to overcome the Serapis's greater firepower by quickly boarding her. .nf @@ -761,8 +837,9 @@ Wind from the N, blowing a fresh breeze. Wind from the E, blowing a gale. .fi -A scenario for you Horny fans. Remember, he sank the Natividad -against heavy odds and winds. Hint: don't try to board the Natividad, +A scenario for you Horny fans. +Remember, he sank the Natividad against heavy odds and winds. +Hint: don't try to board the Natividad, her crew is much bigger, albeit green. .nf @@ -788,8 +865,10 @@ Wind from the S, blowing a strong breeze. .nf Wind from the E, blowing a fresh breeze. -The only battle Hornblower ever lost. He was able to dismast one -ship and stern rake the others though. See if you can do as well. +.fi +The only battle Hornblower ever lost. +He was able to dismast one ship and stern rake the others though. +See if you can do as well. .nf (b) Sutherland 74 gun Ship of the Line (crack crew) (26 pts) @@ -871,7 +950,7 @@ has been a group effort. .SH AUTHOR Dave Riggle .SH CO-AUTHOR -Ed Wang +Ed Wang .SH REFITTING Craig Leres .SH CONSULTANTS @@ -881,9 +960,9 @@ Captain Happy Horatio Nelson and many valiant others... .fi -.SH "REFERENCES" +.SH REFERENCES .nf -Wooden Ships & Iron Men, by Avalon Hill +Wooden Ships \*[Am] Iron Men, by Avalon Hill Captain Horatio Hornblower Novels, (13 of them) by C.S. Forester Captain Richard Bolitho Novels, (12 of them) by Alexander Kent The Complete Works of Captain Frederick Marryat, (about 20) especially diff --git a/snake/Makefrag b/snake/Makefrag index d2a0ecd..1c10521 100644 --- a/snake/Makefrag +++ b/snake/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for snake +# +# Copyright (c) 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. snake_all: diff --git a/snake/snscore/Makefile.bsd b/snake/snscore/Makefile.bsd index 7e9fe3d..7041fb4 100644 --- a/snake/snscore/Makefile.bsd +++ b/snake/snscore/Makefile.bsd @@ -1,10 +1,11 @@ -# $NetBSD: Makefile,v 1.4 1997/10/22 05:26:25 lukem Exp $ +# $NetBSD: Makefile,v 1.7 2002/09/18 06:16:41 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 -PROG= snscore -CPPFLAGS+=-I${.CURDIR}/../snake -NOMAN= noman -HIDEGAME=hidegame +NOMAN= # defined + +PROG= snscore +CPPFLAGS+= -I${.CURDIR}/../snake +HIDEGAME= hidegame .include "../../Makefile.inc" .include diff --git a/snake/snscore/Makefrag b/snake/snscore/Makefrag index 0471caf..76aba45 100644 --- a/snake/snscore/Makefrag +++ b/snake/snscore/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for snake/snscore +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. snake_snscore_DIRS := $(GAMESDIR) $(MAN6DIR) snake_snscore_INCS := -Isnake/snake diff --git a/snake/snscore/snscore.c b/snake/snscore/snscore.c index 1b46c52..967fff3 100644 --- a/snake/snscore/snscore.c +++ b/snake/snscore/snscore.c @@ -1,4 +1,4 @@ -/* $NetBSD: snscore.c,v 1.8 1998/09/11 14:25:22 hubertf Exp $ */ +/* $NetBSD: snscore.c,v 1.13 2000/05/08 07:56:05 mycroft Exp $ */ /* * Copyright (c) 1980, 1993 @@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ #if 0 static char sccsid[] = "@(#)snscore.c 8.1 (Berkeley) 7/19/93"; #else -__RCSID("$NetBSD: snscore.c,v 1.8 1998/09/11 14:25:22 hubertf Exp $"); +__RCSID("$NetBSD: snscore.c,v 1.13 2000/05/08 07:56:05 mycroft Exp $"); #endif #endif /* not lint */ @@ -56,7 +56,7 @@ __RCSID("$NetBSD: snscore.c,v 1.8 1998/09/11 14:25:22 hubertf Exp $"); #include #include "pathnames.h" -char *recfile = _PATH_RAWSCORES; +const char *recfile = _PATH_RAWSCORES; #define MAXPLAYERS 65534 struct player { @@ -105,8 +105,9 @@ main() if (p == NULL) continue; q = p -> pw_name; - players[noplayers].name = malloc(strlen(q) + 1); - strcpy(players[noplayers].name, q); + players[noplayers].name = strdup(q); + if (players[noplayers].name == NULL) + err(1, NULL); noplayers++; } } diff --git a/tetris/Makefrag b/tetris/Makefrag index abac792..0781d23 100644 --- a/tetris/Makefrag +++ b/tetris/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for tetris +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. tetris_CLEANFILES := tetris-bsd.6 tetris_DIRS := $(GAMESDIR) $(MAN6DIR) diff --git a/tetris/input.c b/tetris/input.c index 26772cd..cae49c8 100644 --- a/tetris/input.c +++ b/tetris/input.c @@ -1,4 +1,4 @@ -/* $NetBSD: input.c,v 1.3 1996/02/06 22:47:33 jtc Exp $ */ +/* $NetBSD: input.c,v 1.8 2002/12/29 15:12:17 kristerw Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -44,6 +44,7 @@ #include #include +#include #include #include @@ -65,44 +66,41 @@ } /* - * Do a `read wait': select for reading from stdin, with timeout *tvp. + * Do a `read wait': poll for reading from stdin, with timeout *tvp. * On return, modify *tvp to reflect the amount of time spent waiting. * It will be positive only if input appeared before the time ran out; * otherwise it will be zero or perhaps negative. * - * If tvp is nil, wait forever, but return if select is interrupted. + * If tvp is nil, wait forever, but return if poll is interrupted. * * Return 0 => no input, 1 => can read() from stdin */ int rwait(tvp) - register struct timeval *tvp; + struct timeval *tvp; { - int i; - struct timeval starttv, endtv, *s; + struct pollfd set[1]; + struct timeval starttv, endtv; + int timeout; #define NILTZ ((struct timezone *)0) - /* - * Someday, select() will do this for us. - * Just in case that day is now, and no one has - * changed this, we use a temporary. - */ if (tvp) { (void) gettimeofday(&starttv, NILTZ); endtv = *tvp; - s = &endtv; + timeout = tvp->tv_sec * 1000 + tvp->tv_usec / 1000; } else - s = 0; + timeout = INFTIM; again: - i = 1; - switch (select(1, (fd_set *)&i, (fd_set *)0, (fd_set *)0, s)) { + set[0].fd = STDIN_FILENO; + set[0].events = POLLIN; + switch (poll(set, 1, timeout)) { case -1: if (tvp == 0) return (-1); if (errno == EINTR) goto again; - stop("select failed, help"); + stop("poll failed, help"); /* NOTREACHED */ case 0: /* timed out */ @@ -120,7 +118,7 @@ again: } /* - * `sleep' for the current turn time (using select). + * `sleep' for the current turn time. * Eat any input that might be available. */ void @@ -136,20 +134,6 @@ tsleep() break; } -/* - * Eat up any input (used at end of game). - */ -void -eat_input() -{ - struct timeval tv; - char c; - - do { - tv.tv_sec = tv.tv_usec = 0; - } while (rwait(&tv) && read(0, &c, 1) == 1); -} - /* * getchar with timeout. */ diff --git a/tetris/input.h b/tetris/input.h index d9616b1..8bbd0d3 100644 --- a/tetris/input.h +++ b/tetris/input.h @@ -1,4 +1,4 @@ -/* $NetBSD: input.h,v 1.2 1995/04/22 07:42:36 cgd Exp $ */ +/* $NetBSD: input.h,v 1.3 1999/01/03 02:00:17 hubertf Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -38,7 +38,6 @@ * @(#)input.h 8.1 (Berkeley) 5/31/93 */ -void eat_input __P((void)); int rwait __P((struct timeval *)); int tgetchar __P((void)); void tsleep __P((void)); diff --git a/tetris/screen.h b/tetris/screen.h index 223135d..d9e6b47 100644 --- a/tetris/screen.h +++ b/tetris/screen.h @@ -1,4 +1,4 @@ -/* $NetBSD: screen.h,v 1.3 1997/10/14 01:14:34 lukem Exp $ */ +/* $NetBSD: screen.h,v 1.6 2000/05/22 12:42:48 blymn Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -41,8 +41,8 @@ /* * Capabilities from TERMCAP (used in the score code). */ -char *SEstr; /* end standout mode */ -char *SOstr; /* begin standout mode */ +extern char *SEstr; /* end standout mode */ +extern char *SOstr; /* begin standout mode */ /* * putpad() is for padded strings with count=1. diff --git a/tetris/shapes.c b/tetris/shapes.c index 86309e2..32c7814 100644 --- a/tetris/shapes.c +++ b/tetris/shapes.c @@ -1,4 +1,4 @@ -/* $NetBSD: shapes.c,v 1.3 1997/10/12 02:03:47 lukem Exp $ */ +/* $NetBSD: shapes.c,v 1.5 2002/06/02 22:17:38 wiz Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -56,7 +56,7 @@ #define BC B_COLS /* bottom center */ #define BR B_COLS+1 /* bottom right */ -struct shape shapes[] = { +const struct shape shapes[] = { /* 0*/ { 7, { TL, TC, MR, } }, /* 1*/ { 8, { TC, TR, ML, } }, /* 2*/ { 9, { ML, MR, BC, } }, @@ -84,10 +84,10 @@ struct shape shapes[] = { */ int fits_in(shape, pos) - struct shape *shape; - register int pos; + const struct shape *shape; + int pos; { - register int *o = shape->off; + int *o = shape->off; if (board[pos] || board[pos + *o++] || board[pos + *o++] || board[pos + *o]) @@ -101,10 +101,10 @@ fits_in(shape, pos) */ void place(shape, pos, onoff) - struct shape *shape; - register int pos, onoff; + const struct shape *shape; + int pos, onoff; { - register int *o = shape->off; + int *o = shape->off; board[pos] = onoff; board[pos + *o++] = onoff; diff --git a/tetris/tetris.6.in b/tetris/tetris.6.in index 9d9a8ff..16184a1 100644 --- a/tetris/tetris.6.in +++ b/tetris/tetris.6.in @@ -1,4 +1,4 @@ -.\" $NetBSD: tetris.6,v 1.4 1997/09/01 23:26:11 mikel Exp $ +.\" $NetBSD: tetris.6,v 1.9 2002/09/26 18:32:05 wiz Exp $ .\" .\" Copyright (c) 1992, 1993 .\" The Regents of the University of California. All rights reserved. @@ -44,7 +44,7 @@ .Nd the game of tetris .Sh SYNOPSIS .Nm -.Op Fl s +.Op Fl ps .Op Fl k Ar keys .Op Fl l Ar level .Sh DESCRIPTION @@ -60,14 +60,14 @@ The default level of play is 2. .Pp The default control keys are as follows: .Pp -.Bl -tag -width "" -compact -offset indent +.Bl -tag -width "xxspacexx" -compact -offset indent .It j move left .It k rotate 1/4 turn counterclockwise .It l move right -.It +.It Aq space drop .It p pause @@ -97,6 +97,8 @@ during play. Select a level of play. .It Fl s Display the top scores. +.It Fl p +Switch on previewing of the shape that will appear next. .El .Pp .Sh PLAY @@ -108,7 +110,7 @@ at level 9, they fall 9 times per second. (As the game goes on, things speed up, no matter what your initial selection.) When this shape -.Dq "touches down" +.Dq touches down on the bottom of the field, another will appear at the top. .Pp You can move shapes to the left or right, rotate them counterclockwise, @@ -155,3 +157,5 @@ Chris Torek and Darren F. Provine. .Pp Manual adapted from the original entry written by Nancy L. Tinkham and Darren F. Provine. +.Pp +Code for previewing next shape added by Hubert Feyrer in 1999. diff --git a/tetris/tetris.h b/tetris/tetris.h index 7c35112..769f2d2 100644 --- a/tetris/tetris.h +++ b/tetris/tetris.h @@ -1,4 +1,4 @@ -/* $NetBSD: tetris.h,v 1.3 1998/09/13 15:27:30 hubertf Exp $ */ +/* $NetBSD: tetris.h,v 1.8 2000/01/01 10:15:17 jsm Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -60,7 +60,7 @@ #define B_SIZE (B_ROWS * B_COLS) typedef unsigned char cell; -cell board[B_SIZE]; /* 1 => occupied, 0 => empty */ +extern cell board[B_SIZE]; /* 1 => occupied, 0 => empty */ /* the displayed area (rows) */ #define D_FIRST 1 @@ -76,7 +76,7 @@ cell board[B_SIZE]; /* 1 => occupied, 0 => empty */ #define MINROWS 23 #define MINCOLS 40 -int Rows, Cols; /* current screen size */ +extern int Rows, Cols; /* current screen size */ /* * Translations from board coordinates to display coordinates. @@ -131,9 +131,12 @@ struct shape { int off[3]; /* offsets to other blots if center is at (0,0) */ }; -extern struct shape shapes[]; +extern const struct shape shapes[]; #define randshape() (&shapes[random() % 7]) +extern const struct shape *curshape; +extern const struct shape *nextshape; + /* * Shapes fall at a rate faster than once per second. * @@ -144,7 +147,7 @@ extern struct shape shapes[]; * The value eventually reaches a limit, and things stop going faster, * but by then the game is utterly impossible. */ -long fallrate; /* less than 1 million; smaller => faster */ +extern long fallrate; /* less than 1 million; smaller => faster */ #define faster() (fallrate -= fallrate / 3000) /* @@ -164,11 +167,12 @@ long fallrate; /* less than 1 million; smaller => faster */ * we find that it is at rest and integrate it---until then, it can * still be moved or rotated). */ -int score; /* the obvious thing */ -gid_t gid, egid; +extern int score; /* the obvious thing */ +extern gid_t gid, egid; -char key_msg[100]; +extern char key_msg[100]; +extern int showpreview; -int fits_in __P((struct shape *, int)); -void place __P((struct shape *, int, int)); -void stop __P((char *)) __attribute__((__noreturn__)); +int fits_in __P((const struct shape *, int)); +void place __P((const struct shape *, int, int)); +void stop __P((const char *)) __attribute__((__noreturn__)); diff --git a/trek/DOC/read_me.nr b/trek/DOC/read_me.nr index 18bbd04..262bfbd 100644 --- a/trek/DOC/read_me.nr +++ b/trek/DOC/read_me.nr @@ -1,4 +1,4 @@ -.\" $NetBSD: read_me.nr,v 1.2 1995/04/22 10:59:44 cgd Exp $ +.\" $NetBSD: read_me.nr,v 1.3 2001/07/22 13:34:01 wiz Exp $ .de @h 'sp 4 'tl 'TREK SETUP INSTRUCTIONS''%' @@ -196,7 +196,7 @@ There are many neat things which could go in, if there were only enough space. However, -I have specifically not gone to seperated I/D +I have specifically not gone to separated I/D space. The main reason is that I would like future versions of the game diff --git a/trek/DOC/trekmanual.nr b/trek/DOC/trekmanual.nr index 0ef5063..7f406aa 100644 --- a/trek/DOC/trekmanual.nr +++ b/trek/DOC/trekmanual.nr @@ -1,4 +1,4 @@ -.\" $NetBSD: trekmanual.nr,v 1.2 1995/04/22 10:59:45 cgd Exp $ +.\" $NetBSD: trekmanual.nr,v 1.3 2001/06/12 15:17:12 wiz Exp $ .br .po 10 .if n \!. @@ -692,7 +692,7 @@ with energy, photon torpedoes, and life support reserves. Repairs are also done faster at starbase. Any prisoners you have taken are unloaded. -You do not recieve points +You do not receive points for taking prisoners until this time. .pp diff --git a/trek/Makefrag b/trek/Makefrag index d9140b1..9c62364 100644 --- a/trek/Makefrag +++ b/trek/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for trek +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. trek_DIRS := $(GAMESDIR) $(MAN6DIR) diff --git a/trek/README.linux b/trek/README.linux index c3c3925..1fe554a 100644 --- a/trek/README.linux +++ b/trek/README.linux @@ -5,4 +5,4 @@ the Makefile. You may wish to install it somewhere; if you do, remember to update the reference to /usr/doc/trek in the man page. Joseph Myers -jsm28@cam.ac.uk +jsm@polyomino.org.uk diff --git a/trek/USD.doc/Makefile.bsd b/trek/USD.doc/Makefile.bsd index ff84826..a01b232 100644 --- a/trek/USD.doc/Makefile.bsd +++ b/trek/USD.doc/Makefile.bsd @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.2 1995/04/22 10:59:48 cgd Exp $ +# $NetBSD: Makefile,v 1.3 2003/01/05 12:34:27 pooka Exp $ # @(#)Makefile 8.1 (Berkeley) 6/8/93 DIR= usd/31.trek @@ -6,6 +6,6 @@ SRCS= trek.me MACROS= -me paper.ps: ${SRCS} - ${TBL} ${SRCS} | ${ROFF} > ${.TARGET} + ${TBL} ${SRCS} | ${ROFF} ${MACROS} > ${.TARGET} .include diff --git a/trek/abandon.c b/trek/abandon.c index cfc5e6a..872d15d 100644 --- a/trek/abandon.c +++ b/trek/abandon.c @@ -1,4 +1,4 @@ -/* $NetBSD: abandon.c,v 1.4 1997/10/12 21:24:25 christos Exp $ */ +/* $NetBSD: abandon.c,v 1.5 1999/09/08 21:45:32 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)abandon.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: abandon.c,v 1.4 1997/10/12 21:24:25 christos Exp $"); +__RCSID("$NetBSD: abandon.c,v 1.5 1999/09/08 21:45:32 jsm Exp $"); #endif #endif /* not lint */ @@ -73,7 +73,7 @@ __RCSID("$NetBSD: abandon.c,v 1.4 1997/10/12 21:24:25 christos Exp $"); /*ARGSUSED*/ void abandon(v) - int v __attribute__((unused)); + int v __attribute__((__unused__)); { struct quad *q; int i; diff --git a/trek/capture.c b/trek/capture.c index a284ba0..93a9d25 100644 --- a/trek/capture.c +++ b/trek/capture.c @@ -1,4 +1,4 @@ -/* $NetBSD: capture.c,v 1.4 1997/10/12 21:24:29 christos Exp $ */ +/* $NetBSD: capture.c,v 1.5 1999/09/08 21:45:32 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)capture.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: capture.c,v 1.4 1997/10/12 21:24:29 christos Exp $"); +__RCSID("$NetBSD: capture.c,v 1.5 1999/09/08 21:45:32 jsm Exp $"); #endif #endif /* not lint */ @@ -62,7 +62,7 @@ __RCSID("$NetBSD: capture.c,v 1.4 1997/10/12 21:24:29 christos Exp $"); /*ARGSUSED*/ void capture(v) - int v __attribute__((unused)); + int v __attribute__((__unused__)); { int i; struct kling *k; diff --git a/trek/cgetc.c b/trek/cgetc.c index 42ae660..19d8b85 100644 --- a/trek/cgetc.c +++ b/trek/cgetc.c @@ -1,4 +1,4 @@ -/* $NetBSD: cgetc.c,v 1.4 1997/10/12 21:24:30 christos Exp $ */ +/* $NetBSD: cgetc.c,v 1.5 1999/09/08 21:45:32 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)cgetc.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: cgetc.c,v 1.4 1997/10/12 21:24:30 christos Exp $"); +__RCSID("$NetBSD: cgetc.c,v 1.5 1999/09/08 21:45:32 jsm Exp $"); #endif #endif /* not lint */ @@ -46,7 +46,7 @@ __RCSID("$NetBSD: cgetc.c,v 1.4 1997/10/12 21:24:30 christos Exp $"); # include "trek.h" char cgetc(i) -int i __attribute__((unused)); +int i __attribute__((__unused__)); { return ( getchar() ); } diff --git a/trek/computer.c b/trek/computer.c index 88b8ce5..d7bf7ea 100644 --- a/trek/computer.c +++ b/trek/computer.c @@ -1,4 +1,4 @@ -/* $NetBSD: computer.c,v 1.5 1997/10/12 21:24:34 christos Exp $ */ +/* $NetBSD: computer.c,v 1.8 2000/07/03 03:57:44 matt Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,11 +38,12 @@ #if 0 static char sccsid[] = "@(#)computer.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: computer.c,v 1.5 1997/10/12 21:24:34 christos Exp $"); +__RCSID("$NetBSD: computer.c,v 1.8 2000/07/03 03:57:44 matt Exp $"); #endif #endif /* not lint */ #include +#include #include #include "trek.h" #include "getpar.h" @@ -113,12 +114,12 @@ static void prkalc __P((int, double)); /*ARGSUSED*/ void computer(v) - int v __attribute__((unused)); + int v __attribute__((__unused__)); { int ix, iy; int i, j; int tqx, tqy; - struct cvntab *r; + const struct cvntab *r; int cost; int course; double dist, time; diff --git a/trek/damage.c b/trek/damage.c index dfe29f4..2183da6 100644 --- a/trek/damage.c +++ b/trek/damage.c @@ -1,4 +1,4 @@ -/* $NetBSD: damage.c,v 1.4 1997/10/12 21:24:36 christos Exp $ */ +/* $NetBSD: damage.c,v 1.5 2002/07/20 08:36:23 grant Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)damage.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: damage.c,v 1.4 1997/10/12 21:24:36 christos Exp $"); +__RCSID("$NetBSD: damage.c,v 1.5 2002/07/20 08:36:23 grant Exp $"); #endif #endif /* not lint */ @@ -97,5 +97,5 @@ double dam; /* time to repair */ reschedule(e, e->date - Now.date + dam); return; } - errx(1, "Cannot find old damages %d\n", dev); + errx(1, "Cannot find old damages %d", dev); } diff --git a/trek/dcrept.c b/trek/dcrept.c index 41baa2b..a3e6e55 100644 --- a/trek/dcrept.c +++ b/trek/dcrept.c @@ -1,4 +1,4 @@ -/* $NetBSD: dcrept.c,v 1.4 1997/10/12 21:24:38 christos Exp $ */ +/* $NetBSD: dcrept.c,v 1.5 1999/09/08 21:45:32 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)dcrept.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: dcrept.c,v 1.4 1997/10/12 21:24:38 christos Exp $"); +__RCSID("$NetBSD: dcrept.c,v 1.5 1999/09/08 21:45:32 jsm Exp $"); #endif #endif /* not lint */ @@ -60,7 +60,7 @@ __RCSID("$NetBSD: dcrept.c,v 1.4 1997/10/12 21:24:38 christos Exp $"); /*ARGSUSED*/ void dcrept(v) - int v __attribute__((unused)); + int v __attribute__((__unused__)); { int i, f; double x; diff --git a/trek/destruct.c b/trek/destruct.c index 6050099..e3c6729 100644 --- a/trek/destruct.c +++ b/trek/destruct.c @@ -1,4 +1,4 @@ -/* $NetBSD: destruct.c,v 1.4 1997/10/12 21:24:40 christos Exp $ */ +/* $NetBSD: destruct.c,v 1.6 2000/07/03 03:57:44 matt Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,11 +38,12 @@ #if 0 static char sccsid[] = "@(#)destruct.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: destruct.c,v 1.4 1997/10/12 21:24:40 christos Exp $"); +__RCSID("$NetBSD: destruct.c,v 1.6 2000/07/03 03:57:44 matt Exp $"); #endif #endif /* not lint */ #include +#include #include #include "trek.h" #include "getpar.h" @@ -70,7 +71,7 @@ __RCSID("$NetBSD: destruct.c,v 1.4 1997/10/12 21:24:40 christos Exp $"); /*ARGSUSED*/ void destruct(v) - int v __attribute__((unused)); + int v __attribute__((__unused__)); { char checkpass[15]; int i, j; diff --git a/trek/dock.c b/trek/dock.c index 38c00ba..5af80f9 100644 --- a/trek/dock.c +++ b/trek/dock.c @@ -1,4 +1,4 @@ -/* $NetBSD: dock.c,v 1.4 1997/10/12 21:24:41 christos Exp $ */ +/* $NetBSD: dock.c,v 1.5 1999/09/08 21:45:32 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)dock.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: dock.c,v 1.4 1997/10/12 21:24:41 christos Exp $"); +__RCSID("$NetBSD: dock.c,v 1.5 1999/09/08 21:45:32 jsm Exp $"); #endif #endif /* not lint */ @@ -63,7 +63,7 @@ __RCSID("$NetBSD: dock.c,v 1.4 1997/10/12 21:24:41 christos Exp $"); /*ARGSUSED*/ void dock(v) - int v __attribute__((unused)); + int v __attribute__((__unused__)); { int i, j; int ok; @@ -137,7 +137,7 @@ dock(v) /*ARGSUSED*/ void undock(v) - int v __attribute__((unused)); + int v __attribute__((__unused__)); { struct event *e; int i; diff --git a/trek/dumpgame.c b/trek/dumpgame.c index 729fdea..b9bd050 100644 --- a/trek/dumpgame.c +++ b/trek/dumpgame.c @@ -1,4 +1,4 @@ -/* $NetBSD: dumpgame.c,v 1.6 1998/09/11 14:26:19 hubertf Exp $ */ +/* $NetBSD: dumpgame.c,v 1.7 1999/09/08 21:45:32 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)dumpgame.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: dumpgame.c,v 1.6 1998/09/11 14:26:19 hubertf Exp $"); +__RCSID("$NetBSD: dumpgame.c,v 1.7 1999/09/08 21:45:32 jsm Exp $"); #endif #endif /* not lint */ @@ -87,7 +87,7 @@ struct dump Dump_template[] = /*ARGSUSED*/ void dumpgame(v) - int v __attribute__((unused)); + int v __attribute__((__unused__)); { int version; int fd; diff --git a/trek/events.c b/trek/events.c index d06b56b..a494727 100644 --- a/trek/events.c +++ b/trek/events.c @@ -1,4 +1,4 @@ -/* $NetBSD: events.c,v 1.5 1997/10/13 22:05:26 cjs Exp $ */ +/* $NetBSD: events.c,v 1.6 2001/06/12 15:17:12 wiz Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)events.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: events.c,v 1.5 1997/10/13 22:05:26 cjs Exp $"); +__RCSID("$NetBSD: events.c,v 1.6 2001/06/12 15:17:12 wiz Exp $"); #endif #endif /* not lint */ @@ -235,7 +235,7 @@ int warp; /* set if called in a time warp */ /* report it if we can */ if (!damaged(SSRADIO)) { - printf("\nUhura: Captain, we have recieved a distress signal\n"); + printf("\nUhura: Captain, we have received a distress signal\n"); printf(" from the starbase in quadrant %d,%d.\n", ix, iy); restcancel++; diff --git a/trek/externs.c b/trek/externs.c index 00b6140..153f044 100644 --- a/trek/externs.c +++ b/trek/externs.c @@ -1,4 +1,4 @@ -/* $NetBSD: externs.c,v 1.4 1997/10/12 21:24:48 christos Exp $ */ +/* $NetBSD: externs.c,v 1.7 2001/02/05 01:12:46 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)externs.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: externs.c,v 1.4 1997/10/12 21:24:48 christos Exp $"); +__RCSID("$NetBSD: externs.c,v 1.7 2001/02/05 01:12:46 christos Exp $"); #endif #endif /* not lint */ @@ -48,7 +48,7 @@ __RCSID("$NetBSD: externs.c,v 1.4 1997/10/12 21:24:48 christos Exp $"); ** global variable definitions */ -struct device Device[NDEV] = +const struct device Device[NDEV] = { { "warp drive", "Scotty" }, { "S.R. scanners", "Scotty" }, @@ -68,7 +68,7 @@ struct device Device[NDEV] = { "*ERR 15*", "Nobody" } }; -char *Systemname[NINHAB] = +const char *const Systemname[NINHAB] = { "ERROR", "Talos IV", @@ -103,3 +103,19 @@ char *Systemname[NINHAB] = "Epsilon Eridani IV", "Exo III" }; + +struct quad Quad[NQUADS][NQUADS]; + +/* current sector map */ +char Sect[NSECTS][NSECTS]; + +struct event Event[MAXEVENTS]; /* dynamic event list; one entry per pending event */ + +struct Ship_struct Ship; +struct Game_struct Game; +struct Move_struct Move; +struct Param_struct Param; +struct Now_struct Now; +struct Etc_struct Etc; + +int Trace; diff --git a/trek/getpar.c b/trek/getpar.c index c35cd90..d5f679a 100644 --- a/trek/getpar.c +++ b/trek/getpar.c @@ -1,4 +1,4 @@ -/* $NetBSD: getpar.c,v 1.6 1997/10/13 22:12:01 cjs Exp $ */ +/* $NetBSD: getpar.c,v 1.10 2002/10/18 14:12:14 itojun Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,11 +38,12 @@ #if 0 static char sccsid[] = "@(#)getpar.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: getpar.c,v 1.6 1997/10/13 22:12:01 cjs Exp $"); +__RCSID("$NetBSD: getpar.c,v 1.10 2002/10/18 14:12:14 itojun Exp $"); #endif #endif /* not lint */ #include +#include #include #include "getpar.h" #include "trek.h" @@ -55,7 +56,7 @@ static int testterm __P((void)); int getintpar(s) -char *s; + const char *s; { int i; int n; @@ -79,7 +80,7 @@ char *s; **/ double getfltpar(s) -char *s; + const char *s; { int i; double d; @@ -102,7 +103,7 @@ char *s; ** get yes/no parameter **/ -struct cvntab Yntab[] = +const struct cvntab Yntab[] = { { "y", "es", (cmdfun)1, 1 }, { "n", "o", (cmdfun)0, 0 }, @@ -111,9 +112,9 @@ struct cvntab Yntab[] = int getynpar(s) -char *s; + const char *s; { - struct cvntab *r; + const struct cvntab *r; r = getcodpar(s, Yntab); return r->value2; @@ -124,14 +125,14 @@ char *s; ** get coded parameter **/ -struct cvntab *getcodpar(s, tab) -char *s; -struct cvntab tab[]; +const struct cvntab *getcodpar(s, tab) + const char *s; + const struct cvntab tab[]; { char input[100]; - struct cvntab *r; + const struct cvntab *r; int flag; - char *p, *q; + const char *p, *q; int c; int f; @@ -144,7 +145,7 @@ struct cvntab tab[]; if (f) cgetc(0); /* throw out the newline */ scanf("%*[ \t;]"); - if ((c = scanf("%[^ \t;\n]", input)) < 0) + if ((c = scanf("%99[^ \t;\n]", input)) < 0) exit(1); if (c == 0) continue; @@ -204,10 +205,10 @@ struct cvntab tab[]; void getstrpar(s, r, l, t) -char *s; -char *r; -int l; -char *t; + const char *s; + char *r; + int l; + const char *t; { int i; char format[20]; @@ -290,7 +291,7 @@ testterm() /* -** TEST FOR SPECIFIED DELIMETER +** TEST FOR SPECIFIED DELIMITER ** ** The standard input is scanned for the parameter. If found, ** it is thrown away and non-zero is returned. If not found, diff --git a/trek/getpar.h b/trek/getpar.h index e0e480f..dbb8314 100644 --- a/trek/getpar.h +++ b/trek/getpar.h @@ -1,4 +1,4 @@ -/* $NetBSD: getpar.h,v 1.4 1997/10/12 21:24:51 christos Exp $ */ +/* $NetBSD: getpar.h,v 1.6 1999/09/08 21:18:01 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,17 +38,17 @@ typedef void (*cmdfun) __P((int)); struct cvntab /* used for getcodpar() paramater list */ { - char *abrev; - char *full; + const char *abrev; + const char *full; cmdfun value; int value2; }; -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 getintpar __P((const char *)); +double getfltpar __P((const char *)); +int getynpar __P((const char *)); +const struct cvntab *getcodpar __P((const char *, const struct cvntab[])); +void getstrpar __P((const char *, char *, int, const char *)); int testnl __P((void)); void skiptonl __P((int)); int readdelim __P((int)); diff --git a/trek/help.c b/trek/help.c index 5f373c9..41c9413 100644 --- a/trek/help.c +++ b/trek/help.c @@ -1,4 +1,4 @@ -/* $NetBSD: help.c,v 1.4 1997/10/12 21:24:53 christos Exp $ */ +/* $NetBSD: help.c,v 1.6 1999/09/08 21:45:32 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)help.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: help.c,v 1.4 1997/10/12 21:24:53 christos Exp $"); +__RCSID("$NetBSD: help.c,v 1.6 1999/09/08 21:45:32 jsm Exp $"); #endif #endif /* not lint */ @@ -67,13 +67,13 @@ __RCSID("$NetBSD: help.c,v 1.4 1997/10/12 21:24:53 christos Exp $"); ** to drop you. After that, it's your problem. */ -char *Cntvect[3] = +const char *const Cntvect[3] = {"first", "second", "third"}; /*ARGSUSED*/ void help(v) - int v __attribute__((unused)); + int v __attribute__((__unused__)); { int i; double dist, x; diff --git a/trek/impulse.c b/trek/impulse.c index 8f4b7dd..cb4f08b 100644 --- a/trek/impulse.c +++ b/trek/impulse.c @@ -1,4 +1,4 @@ -/* $NetBSD: impulse.c,v 1.4 1997/10/12 21:24:54 christos Exp $ */ +/* $NetBSD: impulse.c,v 1.5 1999/09/08 21:45:33 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)impulse.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: impulse.c,v 1.4 1997/10/12 21:24:54 christos Exp $"); +__RCSID("$NetBSD: impulse.c,v 1.5 1999/09/08 21:45:33 jsm Exp $"); #endif #endif /* not lint */ @@ -53,7 +53,7 @@ __RCSID("$NetBSD: impulse.c,v 1.4 1997/10/12 21:24:54 christos Exp $"); /*ARGSUSED*/ void impulse(v) - int v __attribute__((unused)); + int v __attribute__((__unused__)); { int course; int power; diff --git a/trek/kill.c b/trek/kill.c index 745ccfc..1cf12a3 100644 --- a/trek/kill.c +++ b/trek/kill.c @@ -1,4 +1,4 @@ -/* $NetBSD: kill.c,v 1.5 1998/08/30 09:19:40 veego Exp $ */ +/* $NetBSD: kill.c,v 1.6 1999/07/21 13:19:11 hubertf Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)kill.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: kill.c,v 1.5 1998/08/30 09:19:40 veego Exp $"); +__RCSID("$NetBSD: kill.c,v 1.6 1999/07/21 13:19:11 hubertf Exp $"); #endif #endif /* not lint */ @@ -158,7 +158,7 @@ int f; /* f != 0 -- this quad; f < 0 -- Enterprise's fault */ { struct quad *q; struct event *e; - char *name; + const char *name; if (f) { diff --git a/trek/lose.c b/trek/lose.c index 4f0fac7..4bc2bbd 100644 --- a/trek/lose.c +++ b/trek/lose.c @@ -1,4 +1,4 @@ -/* $NetBSD: lose.c,v 1.4 1997/10/12 21:24:58 christos Exp $ */ +/* $NetBSD: lose.c,v 1.6 2001/02/05 01:12:46 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)lose.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: lose.c,v 1.4 1997/10/12 21:24:58 christos Exp $"); +__RCSID("$NetBSD: lose.c,v 1.6 2001/02/05 01:12:46 christos Exp $"); #endif #endif /* not lint */ @@ -56,7 +56,9 @@ __RCSID("$NetBSD: lose.c,v 1.4 1997/10/12 21:24:58 christos Exp $"); ** actions which need be taken are taken. */ -char *Losemsg[] = +extern jmp_buf env; + +const char *const Losemsg[] = { "You ran out of time", "You ran out of energy", @@ -77,8 +79,6 @@ void lose(why) int why; { - extern jmp_buf env; - Game.killed = 1; sleep(1); printf("\n%s\n", Losemsg[why - 1]); diff --git a/trek/lrscan.c b/trek/lrscan.c index 4645525..6056948 100644 --- a/trek/lrscan.c +++ b/trek/lrscan.c @@ -1,4 +1,4 @@ -/* $NetBSD: lrscan.c,v 1.4 1997/10/12 21:24:59 christos Exp $ */ +/* $NetBSD: lrscan.c,v 1.5 1999/09/08 21:45:33 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)lrscan.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: lrscan.c,v 1.4 1997/10/12 21:24:59 christos Exp $"); +__RCSID("$NetBSD: lrscan.c,v 1.5 1999/09/08 21:45:33 jsm Exp $"); #endif #endif /* not lint */ @@ -60,7 +60,7 @@ __RCSID("$NetBSD: lrscan.c,v 1.4 1997/10/12 21:24:59 christos Exp $"); /*ARGSUSED*/ void lrscan(v) - int v __attribute__((unused)); + int v __attribute__((__unused__)); { int i, j; struct quad *q; diff --git a/trek/main.c b/trek/main.c index c66e162..2c3598e 100644 --- a/trek/main.c +++ b/trek/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.6 1997/10/13 22:18:32 cjs Exp $ */ +/* $NetBSD: main.c,v 1.10 2001/07/22 13:34:01 wiz Exp $ */ /* * Copyright (c) 1980, 1993 @@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: main.c,v 1.6 1997/10/13 22:18:32 cjs Exp $"); +__RCSID("$NetBSD: main.c,v 1.10 2001/07/22 13:34:01 wiz Exp $"); #endif #endif /* not lint */ @@ -136,7 +136,7 @@ uid_t Mother = 51 + (51 << 8); ** ** Many things in trek are not as clear as they might be, but are ** done to reduce space. I compile with the -f and -O flags. I -** am constrained to running with non-seperated I/D space, since +** am constrained to running with non-separated I/D space, since ** we don't have doubleing point hardware here; even if we did, I ** would like trek to be available to the large number of people ** who either have an 11/40 or do not have FP hardware. I also diff --git a/trek/out.c b/trek/out.c index 1e6dc0c..c7ac084 100644 --- a/trek/out.c +++ b/trek/out.c @@ -1,4 +1,4 @@ -/* $NetBSD: out.c,v 1.5 1997/10/13 22:20:35 cjs Exp $ */ +/* $NetBSD: out.c,v 1.6 1999/07/21 13:19:11 hubertf Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)out.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: out.c,v 1.5 1997/10/13 22:20:35 cjs Exp $"); +__RCSID("$NetBSD: out.c,v 1.6 1999/07/21 13:19:11 hubertf Exp $"); #endif #endif /* not lint */ @@ -54,7 +54,7 @@ void out(dev) int dev; { - struct device *d; + const struct device *d; d = &Device[dev]; printf("%s reports %s ", d->person, d->name); diff --git a/trek/phaser.c b/trek/phaser.c index 662a9d9..8fe1925 100644 --- a/trek/phaser.c +++ b/trek/phaser.c @@ -1,4 +1,4 @@ -/* $NetBSD: phaser.c,v 1.5 1997/10/12 21:25:06 christos Exp $ */ +/* $NetBSD: phaser.c,v 1.8 2000/07/10 10:19:27 itojun Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)phaser.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: phaser.c,v 1.5 1997/10/12 21:25:06 christos Exp $"); +__RCSID("$NetBSD: phaser.c,v 1.8 2000/07/10 10:19:27 itojun Exp $"); #endif #endif /* not lint */ @@ -99,7 +99,7 @@ struct banks /*ARGSUSED*/ void phaser(v) - int v __attribute__((unused)); + int v __attribute__((__unused__)); { int i; int j; @@ -113,7 +113,7 @@ phaser(v) int n; int hitreqd[NBANKS]; struct banks bank[NBANKS]; - struct cvntab *ptr; + const struct cvntab *ptr; if (Ship.cond == DOCKED) { printf("Phasers cannot fire through starbase shields\n"); @@ -140,13 +140,13 @@ phaser(v) { if (damaged(COMPUTER)) { - printf(Device[COMPUTER].name); + printf("%s", Device[COMPUTER].name); manual++; } else if (damaged(SRSCAN)) { - printf(Device[SRSCAN].name); + printf("%s", Device[SRSCAN].name); manual++; } if (manual) diff --git a/trek/play.c b/trek/play.c index 382e532..3be6b94 100644 --- a/trek/play.c +++ b/trek/play.c @@ -1,4 +1,4 @@ -/* $NetBSD: play.c,v 1.4 1997/10/12 21:25:07 christos Exp $ */ +/* $NetBSD: play.c,v 1.7 2001/02/05 01:12:46 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)play.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: play.c,v 1.4 1997/10/12 21:25:07 christos Exp $"); +__RCSID("$NetBSD: play.c,v 1.7 2001/02/05 01:12:46 christos Exp $"); #endif #endif /* not lint */ @@ -58,7 +58,9 @@ __RCSID("$NetBSD: play.c,v 1.4 1997/10/12 21:25:07 christos Exp $"); ** on how we are doing after the move. */ -struct cvntab Comtab[] = +extern jmp_buf env; + +const struct cvntab Comtab[] = { { "abandon", "", abandon, 0 }, { "ca", "pture", capture, 0 }, @@ -89,9 +91,8 @@ struct cvntab Comtab[] = /*ARGSUSED*/ void myreset(v) - int v __attribute__((unused)); + int v __attribute__((__unused__)); { - extern jmp_buf env; longjmp(env, 1); } @@ -99,7 +100,7 @@ myreset(v) void play() { - struct cvntab *r; + const struct cvntab *r; while (1) { diff --git a/trek/rest.c b/trek/rest.c index d98666d..a2f8310 100644 --- a/trek/rest.c +++ b/trek/rest.c @@ -1,4 +1,4 @@ -/* $NetBSD: rest.c,v 1.4 1997/10/12 21:25:10 christos Exp $ */ +/* $NetBSD: rest.c,v 1.5 1999/09/08 21:45:33 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)rest.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: rest.c,v 1.4 1997/10/12 21:25:10 christos Exp $"); +__RCSID("$NetBSD: rest.c,v 1.5 1999/09/08 21:45:33 jsm Exp $"); #endif #endif /* not lint */ @@ -63,7 +63,7 @@ __RCSID("$NetBSD: rest.c,v 1.4 1997/10/12 21:25:10 christos Exp $"); /*ARGSUSED*/ void rest(v) - int v __attribute__((unused)); + int v __attribute__((__unused__)); { double t; int percent; diff --git a/trek/setup.c b/trek/setup.c index 6e381be..41875b9 100644 --- a/trek/setup.c +++ b/trek/setup.c @@ -1,4 +1,4 @@ -/* $NetBSD: setup.c,v 1.5 1997/10/12 21:25:15 christos Exp $ */ +/* $NetBSD: setup.c,v 1.7 2000/07/03 03:57:44 matt Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,12 +38,13 @@ #if 0 static char sccsid[] = "@(#)setup.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: setup.c,v 1.5 1997/10/12 21:25:15 christos Exp $"); +__RCSID("$NetBSD: setup.c,v 1.7 2000/07/03 03:57:44 matt Exp $"); #endif #endif /* not lint */ #include #include +#include #include #include #include @@ -61,7 +62,7 @@ __RCSID("$NetBSD: setup.c,v 1.5 1997/10/12 21:25:15 christos Exp $"); ** Game restart and tournament games are handled here. */ -struct cvntab Lentab[] = +const struct cvntab Lentab[] = { { "s", "hort", (cmdfun)1, 0 }, { "m", "edium", (cmdfun)2, 0 }, @@ -70,7 +71,7 @@ struct cvntab Lentab[] = { NULL, NULL, NULL, 0 } }; -struct cvntab Skitab[] = +const struct cvntab Skitab[] = { { "n", "ovice", (cmdfun)1, 0 }, { "f", "air", (cmdfun)2, 0 }, @@ -84,7 +85,7 @@ struct cvntab Skitab[] = void setup() { - struct cvntab *r; + const struct cvntab *r; int i, j; double f; int d; diff --git a/trek/setwarp.c b/trek/setwarp.c index 8d391a7..56ec60f 100644 --- a/trek/setwarp.c +++ b/trek/setwarp.c @@ -1,4 +1,4 @@ -/* $NetBSD: setwarp.c,v 1.4 1997/10/12 21:25:16 christos Exp $ */ +/* $NetBSD: setwarp.c,v 1.5 1999/09/08 21:45:33 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)setwarp.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: setwarp.c,v 1.4 1997/10/12 21:25:16 christos Exp $"); +__RCSID("$NetBSD: setwarp.c,v 1.5 1999/09/08 21:45:33 jsm Exp $"); #endif #endif /* not lint */ @@ -56,7 +56,7 @@ __RCSID("$NetBSD: setwarp.c,v 1.4 1997/10/12 21:25:16 christos Exp $"); /*ARGSUSED*/ void setwarp(v) - int v __attribute__((unused)); + int v __attribute__((__unused__)); { double warpfac; diff --git a/trek/shield.c b/trek/shield.c index 135fa58..c9a5352 100644 --- a/trek/shield.c +++ b/trek/shield.c @@ -1,4 +1,4 @@ -/* $NetBSD: shield.c,v 1.6 1998/08/30 09:19:40 veego Exp $ */ +/* $NetBSD: shield.c,v 1.7 1999/07/21 13:19:11 hubertf Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)shield.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: shield.c,v 1.6 1998/08/30 09:19:40 veego Exp $"); +__RCSID("$NetBSD: shield.c,v 1.7 1999/07/21 13:19:11 hubertf Exp $"); #endif #endif /* not lint */ @@ -63,7 +63,7 @@ __RCSID("$NetBSD: shield.c,v 1.6 1998/08/30 09:19:40 veego Exp $"); ** so you get partial hits. */ -struct cvntab Udtab[] = +const struct cvntab Udtab[] = { { "u", "p", (cmdfun)1, 0 }, { "d", "own", (cmdfun)0, 0 }, @@ -75,9 +75,9 @@ shield(f) int f; { int i; - struct cvntab *r; + const struct cvntab *r; char s[100]; - char *device, *dev2, *dev3; + const char *device, *dev2, *dev3; int ind; char *stat; diff --git a/trek/srscan.c b/trek/srscan.c index be86d14..7456d23 100644 --- a/trek/srscan.c +++ b/trek/srscan.c @@ -1,4 +1,4 @@ -/* $NetBSD: srscan.c,v 1.4 1997/10/12 21:25:19 christos Exp $ */ +/* $NetBSD: srscan.c,v 1.5 1999/07/21 13:19:11 hubertf Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)srscan.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: srscan.c,v 1.4 1997/10/12 21:25:19 christos Exp $"); +__RCSID("$NetBSD: srscan.c,v 1.5 1999/07/21 13:19:11 hubertf Exp $"); #endif #endif /* not lint */ @@ -61,7 +61,7 @@ __RCSID("$NetBSD: srscan.c,v 1.4 1997/10/12 21:25:19 christos Exp $"); ** The current quadrant is filled in on the computer chart. */ -char *Color[4] = +const char *const Color[4] = { "GREEN", "DOCKED", @@ -75,10 +75,10 @@ int f; { int i, j; int statinfo; - char *s; + const char *s; int percent; struct quad *q = NULL; - struct cvntab *p; + const struct cvntab *p; if (f >= 0 && check_out(SRSCAN)) { diff --git a/trek/systemname.c b/trek/systemname.c index bb37d5c..74ca777 100644 --- a/trek/systemname.c +++ b/trek/systemname.c @@ -1,4 +1,4 @@ -/* $NetBSD: systemname.c,v 1.4 1997/10/12 21:25:21 christos Exp $ */ +/* $NetBSD: systemname.c,v 1.5 1999/07/21 13:19:11 hubertf Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)systemname.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: systemname.c,v 1.4 1997/10/12 21:25:21 christos Exp $"); +__RCSID("$NetBSD: systemname.c,v 1.5 1999/07/21 13:19:11 hubertf Exp $"); #endif #endif /* not lint */ @@ -55,10 +55,10 @@ __RCSID("$NetBSD: systemname.c,v 1.4 1997/10/12 21:25:21 christos Exp $"); ** starsystems, etc. */ -char *systemname(q1) -struct quad *q1; +const char *systemname(q1) + const struct quad *q1; { - struct quad *q; + const struct quad *q; int i; q = q1; diff --git a/trek/torped.c b/trek/torped.c index 8ba21dc..d2305ca 100644 --- a/trek/torped.c +++ b/trek/torped.c @@ -1,4 +1,4 @@ -/* $NetBSD: torped.c,v 1.4 1997/10/12 21:25:22 christos Exp $ */ +/* $NetBSD: torped.c,v 1.6 2000/07/03 03:57:44 matt Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,11 +38,12 @@ #if 0 static char sccsid[] = "@(#)torped.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: torped.c,v 1.4 1997/10/12 21:25:22 christos Exp $"); +__RCSID("$NetBSD: torped.c,v 1.6 2000/07/03 03:57:44 matt Exp $"); #endif #endif /* not lint */ #include +#include #include #include "trek.h" #include "getpar.h" @@ -71,7 +72,7 @@ static int randcourse __P((int)); /*ARGSUSED*/ void torped(v) - int v __attribute__((unused)); + int v __attribute__((__unused__)); { int ix, iy; double x, y, dx, dy; diff --git a/trek/trek.h b/trek/trek.h index 8b96d88..eaede63 100644 --- a/trek/trek.h +++ b/trek/trek.h @@ -1,4 +1,4 @@ -/* $NetBSD: trek.h,v 1.5 1997/10/12 21:25:23 christos Exp $ */ +/* $NetBSD: trek.h,v 1.8 1999/09/17 17:06:08 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -45,12 +45,6 @@ ** ** So far as I know, nothing in here must be preinitialized to ** zero. -** -** You may have problems from the loader if you move this to a -** different machine. These things actually get allocated in each -** source file, which UNIX allows; however, you may (on other -** systems) have to change everything in here to be "extern" and -** actually allocate stuff in "externs.c" */ /* external function definitions */ @@ -90,10 +84,10 @@ struct quad /* definition for each quadrant */ */ /* ascii names of systems */ -extern char *Systemname[NINHAB]; +extern const char *const Systemname[NINHAB]; /* quadrant definition */ -struct quad Quad[NQUADS][NQUADS]; +extern struct quad Quad[NQUADS][NQUADS]; /* defines for sector map (below) */ # define EMPTY '.' @@ -106,7 +100,7 @@ struct quad Quad[NQUADS][NQUADS]; # define HOLE ' ' /* current sector map */ -char Sect[NSECTS][NSECTS]; +extern char Sect[NSECTS][NSECTS]; @@ -133,11 +127,11 @@ char Sect[NSECTS][NSECTS]; /* device names */ struct device { - char *name; /* device name */ - char *person; /* the person who fixes it */ + const char *name; /* device name */ + const char *person; /* the person who fixes it */ }; -struct device Device[NDEV]; +extern const struct device Device[NDEV]; /*************************** EVENTS ****************************/ @@ -177,7 +171,7 @@ struct event # define MAXEVENTS 25 /* max number of concurrently pending events */ -struct event Event[MAXEVENTS]; /* dynamic event list; one entry per pending event */ +extern struct event Event[MAXEVENTS]; /* dynamic event list; one entry per pending event */ /***************************** KLINGONS *******************************/ @@ -215,8 +209,8 @@ struct xy }; -extern struct cvntab Skitab[]; -extern struct cvntab Lentab[]; +extern const struct cvntab Skitab[]; +extern const struct cvntab Lentab[]; /* * note that much of the stuff in the following structs CAN NOT @@ -225,7 +219,7 @@ extern struct cvntab Lentab[]; /* information regarding the state of the starship */ -struct +struct Ship_struct { double warp; /* warp factor */ double warp2; /* warp factor squared */ @@ -245,15 +239,16 @@ struct int secty; /* sector y coord */ unsigned char cond; /* condition code */ char sinsbad; /* Space Inertial Navigation System condition */ - char *shipname; /* name of current starship */ + const char *shipname; /* name of current starship */ char ship; /* current starship */ int distressed; /* number of distress calls */ -} Ship; +}; +extern struct Ship_struct Ship; /* sinsbad is set if SINS is working but not calibrated */ /* game related information, mostly scoring */ -struct +struct Game_struct { int killk; /* number of klingons killed */ int deaths; /* number of deaths onboard Enterprise */ @@ -269,10 +264,11 @@ struct char snap; /* set if snapshot taken */ char helps; /* number of help calls */ int captives; /* total number of captives taken */ -} Game; +}; +extern struct Game_struct Game; /* per move information */ -struct +struct Move_struct { char free; /* set if a move is free */ char endgame; /* end of game flag */ @@ -280,10 +276,11 @@ struct char newquad; /* set if just entered this quadrant */ char resting; /* set if this move is a rest */ double time; /* time used this move */ -} Move; +}; +extern struct Move_struct Move; /* parametric information */ -struct +struct Param_struct { unsigned char bases; /* number of starbases */ char klings; /* number of klingons */ @@ -314,12 +311,13 @@ struct int klingcrew; /* number of Klingons in a crew */ double srndrprob; /* surrender probability */ int energylow; /* low energy mark (cond YELLOW) */ -} Param; +}; +extern struct Param_struct Param; /* Sum of damage probabilities must add to 1000 */ /* other information kept in a snapshot */ -struct +struct Now_struct { unsigned char bases; /* number of starbases */ char klings; /* number of klingons */ @@ -329,10 +327,11 @@ struct char distressed; /* number of currently distressed quadrants */ struct event *eventptr[NEVENTS]; /* pointer to event structs */ struct xy base[MAXBASES]; /* locations of starbases */ -} Now; +}; +extern struct Now_struct Now; /* Other stuff, not dumped in a snapshot */ -struct +struct Etc_struct { struct kling klingon[MAXKLQUAD]; /* sorted Klingon list */ short nkling; /* number of Klingons in this sector */ @@ -341,7 +340,8 @@ struct struct xy starbase; /* starbase in current quadrant */ char snapshot[sizeof Quad + sizeof Event + sizeof Now]; /* snapshot for time warp */ char statreport; /* set to get a status report on a srscan */ -} Etc; +}; +extern struct Etc_struct Etc; /* * eventptr is a pointer to the event[] entry of the last @@ -375,7 +375,7 @@ struct /* Trace info */ # define xTRACE 1 -int Trace; +extern int Trace; /* abandon.c */ void abandon __P((int)); @@ -459,7 +459,7 @@ void killd __P((int, int , int)); void klmove __P((int)); /* lose.c */ -void lose __P((int)); +void lose __P((int)) __attribute__((__noreturn__)); /* lrscan.c */ void lrscan __P((int)); @@ -477,8 +477,8 @@ void out __P((int)); void phaser __P((int)); /* play.c */ -void myreset __P((int)); -void play __P((void)); +void myreset __P((int)) __attribute__((__noreturn__)); +void play __P((void)) __attribute__((__noreturn__)); /* ram.c */ void ram __P((int, int )); @@ -516,7 +516,7 @@ void snova __P((int, int )); void srscan __P((int)); /* systemname.c */ -char *systemname __P((struct quad *)); +const char *systemname __P((const struct quad *)); /* torped.c */ void torped __P((int)); @@ -529,4 +529,4 @@ void dowarp __P((int)); void warp __P((int, int, double)); /* win.c */ -void win __P((void)); +void win __P((void)) __attribute__((__noreturn__)); diff --git a/trek/visual.c b/trek/visual.c index f1fe5f5..26fd5b2 100644 --- a/trek/visual.c +++ b/trek/visual.c @@ -1,4 +1,4 @@ -/* $NetBSD: visual.c,v 1.4 1997/10/12 21:25:26 christos Exp $ */ +/* $NetBSD: visual.c,v 1.5 1999/09/08 21:45:33 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)visual.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: visual.c,v 1.4 1997/10/12 21:25:26 christos Exp $"); +__RCSID("$NetBSD: visual.c,v 1.5 1999/09/08 21:45:33 jsm Exp $"); #endif #endif /* not lint */ @@ -74,7 +74,7 @@ struct xy Visdelta[11] = /*ARGSUSED*/ void visual(z) - int z __attribute__((unused)); + int z __attribute__((__unused__)); { int ix, iy; int co; diff --git a/trek/warp.c b/trek/warp.c index d221d96..8f1a47b 100644 --- a/trek/warp.c +++ b/trek/warp.c @@ -1,4 +1,4 @@ -/* $NetBSD: warp.c,v 1.6 1998/09/11 14:28:28 hubertf Exp $ */ +/* $NetBSD: warp.c,v 1.7 2001/04/25 02:33:10 simonb Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)warp.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: warp.c,v 1.6 1998/09/11 14:28:28 hubertf Exp $"); +__RCSID("$NetBSD: warp.c,v 1.7 2001/04/25 02:33:10 simonb Exp $"); #endif #endif /* not lint */ @@ -201,7 +201,7 @@ double d; /* test for just a lot of damage */ if (percent < 80) lose(L_TOOFAST); - printf("Equilibrium restored -- extreme damage occured to ship systems\n"); + printf("Equilibrium restored -- extreme damage occurred to ship systems\n"); for (i = 0; i < NDEV; i++) damage(i, (3.0 * (franf() + franf()) + 1.0) * Param.damfac[i]); Ship.shldup = 0; diff --git a/trek/win.c b/trek/win.c index 64be233..5b7c8f2 100644 --- a/trek/win.c +++ b/trek/win.c @@ -1,4 +1,4 @@ -/* $NetBSD: win.c,v 1.4 1997/10/12 21:25:28 christos Exp $ */ +/* $NetBSD: win.c,v 1.6 2001/02/05 01:12:46 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)win.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: win.c,v 1.4 1997/10/12 21:25:28 christos Exp $"); +__RCSID("$NetBSD: win.c,v 1.6 2001/02/05 01:12:46 christos Exp $"); #endif #endif /* not lint */ @@ -61,12 +61,13 @@ __RCSID("$NetBSD: win.c,v 1.4 1997/10/12 21:25:28 christos Exp $"); ** pretty off the wall. */ +extern jmp_buf env; + void win() { long s; - struct cvntab *p = NULL; - extern jmp_buf env; + const struct cvntab *p = NULL; sleep(1); printf("\nCongratulations, you have saved the Federation\n"); diff --git a/wargames/Makefile.bsd b/wargames/Makefile.bsd index 5ed35f6..47b625a 100644 --- a/wargames/Makefile.bsd +++ b/wargames/Makefile.bsd @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.7 1997/05/09 07:50:06 mycroft Exp $ +# $NetBSD: Makefile,v 1.10 2000/01/25 21:41:18 drochner Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 -NOOBJ= noobj SCRIPTS=wargames.sh +MAN= wargames.6 .include diff --git a/wargames/Makefrag b/wargames/Makefrag index c199bbd..28d4520 100644 --- a/wargames/Makefrag +++ b/wargames/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for wargames +# +# Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. wargames_DIRS := $(GAMESDIR) $(MAN6DIR) @@ -8,6 +34,3 @@ wargames_install: wargames_all $(INSTALL_SCRIPT) wargames/wargames $(INSTALL_PREFIX)$(GAMESDIR)/wargames $(HIDE_GAME) wargames $(INSTALL_MANUAL) wargames/wargames.6 - -wargames_check: wargames_all - echo "test" | wargames/wargames diff --git a/worm/Makefrag b/worm/Makefrag index aaa3d96..8a46971 100644 --- a/worm/Makefrag +++ b/worm/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for worm +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. worm_DIRS := $(GAMESDIR) $(MAN6DIR) diff --git a/worm/worm.c b/worm/worm.c index 57d2104..19a0124 100644 --- a/worm/worm.c +++ b/worm/worm.c @@ -1,4 +1,4 @@ -/* $NetBSD: worm.c,v 1.9 1998/09/13 15:27:30 hubertf Exp $ */ +/* $NetBSD: worm.c,v 1.23 2001/12/06 12:24:00 blymn Exp $ */ /* * Copyright (c) 1980, 1993 @@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ #if 0 static char sccsid[] = "@(#)worm.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: worm.c,v 1.9 1998/09/13 15:27:30 hubertf Exp $"); +__RCSID("$NetBSD: worm.c,v 1.23 2001/12/06 12:24:00 blymn Exp $"); #endif #endif /* not lint */ @@ -54,6 +54,7 @@ __RCSID("$NetBSD: worm.c,v 1.9 1998/09/13 15:27:30 hubertf Exp $"); #include #include +#include #include #include #include @@ -79,20 +80,20 @@ int running = 0; int slow = 0; int score = 0; int start_len = LENGTH; -char lastch; +int visible_len; +int lastch; char outbuf[BUFSIZ]; void crash __P((void)) __attribute__((__noreturn__)); -void display __P((struct body *, char)); +void display __P((const struct body *, char)); int main __P((int, char **)); void leave __P((int)) __attribute__((__noreturn__)); void life __P((void)); void newpos __P((struct body *)); -void process __P((char)); +void process __P((int)); void prize __P((void)); int rnd __P((int)); void setup __P((void)); -void suspend __P((int)); void wake __P((int)); int @@ -100,26 +101,36 @@ main(argc, argv) int argc; char **argv; { - char ch; /* Revoke setgid privileges */ setregid(getgid(), getgid()); - if (argc == 2) - start_len = atoi(argv[1]); - if ((start_len <= 0) || (start_len > 500)) - start_len = LENGTH; setbuf(stdout, outbuf); srand(getpid()); signal(SIGALRM, wake); signal(SIGINT, leave); signal(SIGQUIT, leave); - signal(SIGTSTP, suspend); /* process control signal */ initscr(); - crmode(); + cbreak(); noecho(); +#ifdef KEY_LEFT + keypad(stdscr, TRUE); +#endif slow = (baudrate() <= 1200); clear(); + if (COLS < 18 || LINES < 5) { + /* + * Insufficient room for the line with " Worm" and the + * score if fewer than 18 columns; insufficient room for + * anything much if fewer than 5 lines. + */ + endwin(); + errx(1, "screen too small"); + } + if (argc == 2) + start_len = atoi(argv[1]); + if ((start_len <= 0) || (start_len > ((LINES-3) * (COLS-2)) / 3)) + start_len = LENGTH; stw = newwin(1, COLS-1, 0, 0); tv = newwin(LINES-1, COLS-1, 1, 0); box(tv, '*', '*'); @@ -142,8 +153,7 @@ main(argc, argv) else { fflush(stdout); - if (read(0, &ch, 1) >= 0) - process(ch); + process(getch()); } } } @@ -152,29 +162,40 @@ void life() { struct body *bp, *np; - int i; + int i, j = 1; np = NULL; head = newlink(); - head->x = start_len+2; - head->y = 12; + if (head == NULL) + err(1, NULL); + head->x = start_len % (COLS-5) + 2; + head->y = LINES / 2; head->next = NULL; display(head, HEAD); for (i = 0, bp = head; i < start_len; i++, bp = np) { np = newlink(); + if (np == NULL) + err(1, NULL); np->next = bp; bp->prev = np; - np->x = bp->x - 1; - np->y = bp->y; + if (((bp->x <= 2) && (j == 1)) || ((bp->x >= COLS-4) && (j == -1))) { + j *= -1; + np->x = bp->x; + np->y = bp->y + 1; + } else { + np->x = bp->x - j; + np->y = bp->y; + } display(np, BODY); } tail = np; tail->prev = NULL; + visible_len = start_len + 1; } void display(pos, chr) - struct body *pos; + const struct body *pos; char chr; { wmove(tv, pos->y, pos->x); @@ -183,15 +204,20 @@ display(pos, chr) void leave(dummy) - int dummy __attribute__((unused)); + int dummy; { endwin(); + + if (dummy == 0){ /* called via crash() */ + printf("\nWell, you ran into something and the game is over.\n"); + printf("Your final score was %d\n\n", score); + } exit(0); } void wake(dummy) - int dummy __attribute__((unused)); + int dummy __attribute__((__unused__)); { signal(SIGALRM, wake); fflush(stdout); @@ -209,8 +235,15 @@ void newpos(bp) struct body * bp; { + if (visible_len == (LINES-3) * (COLS-3) - 1) { + endwin(); + + printf("\nYou won!\n"); + printf("Your final score was %d\n\n", score); + exit(0); + } do { - bp->y = rnd(LINES-3)+ 2; + bp->y = rnd(LINES-3)+ 1; bp->x = rnd(COLS-3) + 1; wmove(tv, bp->y, bp->x); } while(winch(tv) != ' '); @@ -229,7 +262,7 @@ prize() void process(ch) - char ch; + int ch; { int x,y; struct body *nh; @@ -239,18 +272,42 @@ process(ch) y = head->y; switch(ch) { - case 'h': x--; break; - case 'j': y++; break; - case 'k': y--; break; - case 'l': x++; break; +#ifdef KEY_LEFT + case KEY_LEFT: +#endif + case 'h': + x--; break; + +#ifdef KEY_DOWN + case KEY_DOWN: +#endif + case 'j': + y++; break; + +#ifdef KEY_UP + case KEY_UP: +#endif + case 'k': + y--; break; + +#ifdef KEY_RIGHT + case KEY_RIGHT: +#endif + case 'l': + x++; break; + case 'H': x--; running = RUNLEN; ch = tolower(ch); break; case 'J': y++; running = RUNLEN/2; ch = tolower(ch); break; case 'K': y--; running = RUNLEN/2; ch = tolower(ch); break; case 'L': x++; running = RUNLEN; ch = tolower(ch); break; case '\f': setup(); return; - case CNTRL('Z'): suspend(0); return; - case CNTRL('C'): crash(); return; - case CNTRL('D'): crash(); return; + + case ERR: + case CNTRL('C'): + case CNTRL('D'): + crash(); + return; + default: if (! running) alarm(1); return; } @@ -262,6 +319,7 @@ process(ch) nh = tail->next; free(tail); tail = nh; + visible_len--; } else growing--; display(head, BODY); @@ -272,12 +330,14 @@ process(ch) prize(); score += growing; running = 0; - wmove(stw, 0, 68); + wmove(stw, 0, COLS - 12); wprintw(stw, "Score: %3d", score); wrefresh(stw); } else if(ch != ' ') crash(); nh = newlink(); + if (nh == NULL) + err(1, NULL); nh->next = NULL; nh->prev = head; head->next = nh; @@ -285,6 +345,7 @@ process(ch) nh->x = x; display(nh, HEAD); head = nh; + visible_len++; if (!(slow && running)) { wmove(tv, head->y, head->x); @@ -297,30 +358,9 @@ process(ch) void crash() { - sleep(2); - clear(); - move(23, 0); - refresh(); - printf("Well, you ran into something and the game is over.\n"); - printf("Your final score was %d\n", score); leave(0); } -void -suspend(dummy) - int dummy __attribute__((unused)); -{ - move(LINES-1, 0); - refresh(); - endwin(); - fflush(stdout); - kill(getpid(), SIGTSTP); - signal(SIGTSTP, suspend); - crmode(); - noecho(); - setup(); -} - void setup() { diff --git a/worms/Makefrag b/worms/Makefrag index e279ea2..d683a9c 100644 --- a/worms/Makefrag +++ b/worms/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for worms +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. worms_DIRS := $(GAMESDIR) $(MAN6DIR) diff --git a/worms/worms.6 b/worms/worms.6 index 0d42da9..a8fd398 100644 --- a/worms/worms.6 +++ b/worms/worms.6 @@ -1,4 +1,4 @@ -.\" $NetBSD: worms.6,v 1.8 1998/04/28 06:00:52 fair Exp $ +.\" $NetBSD: worms.6,v 1.12 2002/09/26 16:12:43 wiz Exp $ .\" .\" Copyright (c) 1989, 1993 .\" The Regents of the University of California. All rights reserved. @@ -41,23 +41,30 @@ .Sh SYNOPSIS .Nm .Op Fl ft +.Op Fl d Ar delay .Op Fl l Ar length .Op Fl n Ar number .Sh DESCRIPTION A .Ux -version of the DEC-2136 program ``worms''. +version of the DEC-2136 program +.Dq worms . .Pp The options are as follows: .Bl -tag -width indent .It Fl f -Makes a ``field'' for the worm(s) to eat. +Makes a +.Dq field +for the worm(s) to eat. .It Fl t Makes each worm leave a trail behind it. +.It Fl d +Specifies a delay, in milliseconds, between each update. +This is useful for fast terminals. +Reasonable values are around 20-200. +The default is 0. .It Fl l Specifies a length for each worm; the default is 16. .It Fl n Specifies the number of worms; the default is 3. -.Sh BUGS -The lower-right-hand character position will not be updated properly -on a terminal that wraps at the right margin. +.El diff --git a/worms/worms.c b/worms/worms.c index cac4678..37e64e4 100644 --- a/worms/worms.c +++ b/worms/worms.c @@ -1,4 +1,4 @@ -/* $NetBSD: worms.c,v 1.10 1998/09/13 15:27:31 hubertf Exp $ */ +/* $NetBSD: worms.c,v 1.11 1999/07/30 02:23:27 hubertf Exp $ */ /* * Copyright (c) 1980, 1993 @@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ #if 0 static char sccsid[] = "@(#)worms.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: worms.c,v 1.10 1998/09/13 15:27:31 hubertf Exp $"); +__RCSID("$NetBSD: worms.c,v 1.11 1999/07/30 02:23:27 hubertf Exp $"); #endif #endif /* not lint */ @@ -65,15 +65,15 @@ __RCSID("$NetBSD: worms.c,v 1.10 1998/09/13 15:27:31 hubertf Exp $"); * */ #include -#include +#include +#include #include #include #include -#include #include -static struct options { +static const struct options { int nopts; int opts[3]; } @@ -167,13 +167,11 @@ static struct options { { 0, { 0, 0, 0 } } }; -#define cursor(c, r) tputs(tgoto(CM, c, r), 1, fputchar) -char *tcp; -static char flavor[] = { +static const char flavor[] = { 'O', '*', '#', '$', '%', '0', '@', '~' }; -static short xinc[] = { +static const short xinc[] = { 1, 1, 1, 0, -1, -1, -1, 0 }, yinc[] = { -1, 0, 1, 1, 1, 0, -1, -1 @@ -183,36 +181,26 @@ static struct worm { short *xpos, *ypos; } *worm; -void fputchar __P((int)); +volatile sig_atomic_t sig_caught = 0; + int main __P((int, char **)); void nomem __P((void)) __attribute__((__noreturn__)); -void onsig __P((int)) __attribute__((__noreturn__)); -int tgetent __P((char *, char *)); -int tgetflag __P((char *)); -int tgetnum __P((char *)); -char *tgetstr __P((char *, char **)); -char *tgoto __P((char *, int, int)); -int tputs __P((char *, int, void (*)(int))); +void onsig __P((int)); int main(argc, argv) int argc; char *argv[]; { - extern char *UP; int x, y, h, n; struct worm *w; - struct options *op; + const struct options *op; short *ip; - char *term; - int CO, IN, LI, last, bottom, ch, length, number, trail, Wrap; + int CO, LI, last, bottom, ch, length, number, trail; short **ref; - char *AL, *BC, *CM, *EI, *HO, *IC, *IM, *IP, *SR; - char *field, tcb[100], *mp; - struct termios ti; -#ifdef TIOCGWINSZ - struct winsize ws; -#endif + const char *field; + char *mp; + unsigned int delay = 0; /* Revoke setgid privileges */ setregid(getgid(), getgid()); @@ -222,24 +210,25 @@ main(argc, argv) number = 3; trail = ' '; field = NULL; - while ((ch = getopt(argc, argv, "fl:n:t")) != -1) + while ((ch = getopt(argc, argv, "d:fl:n:t")) != -1) switch(ch) { + case 'd': + if ((delay = (unsigned int)strtoul(optarg, (char **)NULL, 10)) < 1 || delay > 1000) + errx(1, "invalid delay (1-1000)"); + delay *= 1000; /* ms -> us */ + break; case 'f': field = "WORM"; break; case 'l': if ((length = atoi(optarg)) < 2 || length > 1024) { - (void)fprintf(stderr, - "worms: invalid length (%d - %d).\n", + errx(1, "invalid length (%d - %d).", 2, 1024); - exit(1); } break; case 'n': if ((number = atoi(optarg)) < 1) { - (void)fprintf(stderr, - "worms: invalid number of worms.\n"); - exit(1); + errx(1, "invalid number of worms."); } break; case 't': @@ -248,55 +237,19 @@ main(argc, argv) case '?': default: (void)fprintf(stderr, - "usage: worms [-ft] [-l length] [-n number]\n"); + "usage: worms [-ft] [-d delay] [-l length] [-n number]\n"); exit(1); } - if (!(term = getenv("TERM"))) { - (void)fprintf(stderr, "worms: no TERM environment variable.\n"); - exit(1); - } if (!(worm = malloc((size_t)number * sizeof(struct worm))) || !(mp = malloc((size_t)1024))) nomem(); - if (tgetent(mp, term) <= 0) { - (void)fprintf(stderr, "worms: %s: unknown terminal type.\n", - term); - exit(1); - } - tcp = tcb; - if (!(CM = tgetstr("cm", &tcp))) { - (void)fprintf(stderr, - "worms: terminal incapable of cursor motion.\n"); - exit(1); - } - AL = tgetstr("al", &tcp); - BC = tgetflag("bs") ? "\b" : tgetstr("bc", &tcp); - EI = tgetstr("ei", &tcp); - HO = tgetstr("ho", &tcp); - IC = tgetstr("ic", &tcp); - IM = tgetstr("im", &tcp); - IN = tgetflag("in"); - IP = tgetstr("ip", &tcp); - SR = tgetstr("sr", &tcp); - UP = tgetstr("up", &tcp); -#ifdef TIOCGWINSZ - if (ioctl(fileno(stdout), TIOCGWINSZ, &ws) != -1 && - ws.ws_col && ws.ws_row) { - CO = ws.ws_col; - LI = ws.ws_row; - } else -#endif - { - if ((CO = tgetnum("co")) <= 0) - CO = 80; - if ((LI = tgetnum("li")) <= 0) - LI = 24; - } + initscr(); + leaveok(stdscr, TRUE); + CO = COLS; + LI = LINES; last = CO - 1; bottom = LI - 1; - tcgetattr(fileno(stdout), &ti); - Wrap = tgetflag("am"); if (!(ip = malloc((size_t)(LI * CO * sizeof(short))))) nomem(); if (!(ref = malloc((size_t)(LI * sizeof(short *))))) @@ -307,8 +260,6 @@ main(argc, argv) } for (ip = ref[0], n = LI * CO; --n >= 0;) *ip++ = 0; - if (Wrap) - ref[bottom][last] = 1; for (n = number, w = &worm[0]; --n >= 0; w++) { w->orientation = w->head = 0; if (!(ip = malloc((size_t)(length * sizeof(short))))) @@ -330,78 +281,30 @@ main(argc, argv) (void)signal(SIGTSTP, onsig); (void)signal(SIGTERM, onsig); - tputs(tgetstr("ti", &tcp), 1, fputchar); - tputs(tgetstr("cl", &tcp), 1, fputchar); if (field) { - char *p = field; + const char *p = field; - for (y = bottom; --y >= 0;) { + for (y = LI; --y >= 0;) { for (x = CO; --x >= 0;) { - fputchar(*p++); + addch(*p++); if (!*p) p = field; } - if (!Wrap) - fputchar('\n'); - (void)fflush(stdout); - } - if (Wrap) { - if (IM && !IN) { - for (x = last; --x > 0;) { - fputchar(*p++); - if (!*p) - p = field; - } - y = *p++; - if (!*p) - p = field; - fputchar(*p); - if (BC) - tputs(BC, 1, fputchar); - else - cursor(last - 1, bottom); - tputs(IM, 1, fputchar); - if (IC) - tputs(IC, 1, fputchar); - fputchar(y); - if (IP) - tputs(IP, 1, fputchar); - tputs(EI, 1, fputchar); - } - else if (SR || AL) { - if (HO) - tputs(HO, 1, fputchar); - else - cursor(0, 0); - if (SR) - tputs(SR, 1, fputchar); - else - tputs(AL, LI, fputchar); - for (x = CO; --x >= 0;) { - fputchar(*p++); - if (!*p) - p = field; - } - } - else for (x = last; --x >= 0;) { - fputchar(*p++); - if (!*p) - p = field; - } - } - else for (x = CO; --x >= 0;) { - fputchar(*p++); - if (!*p) - p = field; + refresh(); } } for (;;) { - (void)fflush(stdout); + refresh(); + if (sig_caught) { + endwin(); + exit(0); + } + if (delay) usleep(delay); for (n = 0, w = &worm[0]; n < number; n++, w++) { if ((x = w->xpos[h = w->head]) < 0) { - cursor(x = w->xpos[h] = 0, - y = w->ypos[h] = bottom); - fputchar(flavor[n % sizeof(flavor)]); + mvaddch(y = w->ypos[h] = bottom, + x = w->xpos[h] = 0, + flavor[n % sizeof(flavor)]); ref[y][x]++; } else @@ -414,15 +317,13 @@ main(argc, argv) x1 = w->xpos[h]; y1 = w->ypos[h]; if (--ref[y1][x1] == 0) { - cursor(x1, y1); - if (trail) - fputchar(trail); + mvaddch(y1, x1, trail); } } op = &(!x ? (!y ? upleft : (y == bottom ? lowleft : left)) : (x == last ? (!y ? upright : (y == bottom ? lowright : right)) : (!y ? upper : (y == bottom ? lower : normal))))[w->orientation]; switch (op->nopts) { case 0: - (void)fflush(stdout); + refresh(); abort(); return(1); case 1: @@ -432,10 +333,9 @@ main(argc, argv) w->orientation = op->opts[(int)random() % op->nopts]; } - cursor(x += xinc[w->orientation], - y += yinc[w->orientation]); - if (!Wrap || x != last || y != bottom) - fputchar(flavor[n % sizeof(flavor)]); + mvaddch(y += yinc[w->orientation], + x += xinc[w->orientation], + flavor[n % sizeof(flavor)]); ref[w->ypos[h] = y][w->xpos[h] = x]++; } } @@ -443,23 +343,13 @@ main(argc, argv) void onsig(signo) - int signo __attribute__((unused)); + int signo __attribute__((__unused__)); { - tputs(tgetstr("cl", &tcp), 1, fputchar); - tputs(tgetstr("te", &tcp), 1, fputchar); - exit(0); -} - -void -fputchar(c) - int c; -{ - (void)putchar(c); + sig_caught = 1; } void nomem() { - (void)fprintf(stderr, "worms: not enough memory.\n"); - exit(1); + errx(1, "not enough memory."); } diff --git a/wtf/wtf.6.in b/wtf/wtf.6.in index 6f313b4..93cdc1a 100644 --- a/wtf/wtf.6.in +++ b/wtf/wtf.6.in @@ -1,4 +1,4 @@ -.\" $NetBSD: wtf.6,v 1.3 1999/07/25 20:29:04 briggs Exp $ +.\" $NetBSD: wtf.6,v 1.5 2002/09/26 16:12:44 wiz Exp $ .\" .\" Public Domain .\" @@ -15,8 +15,9 @@ .Sh DESCRIPTION The .Nm -utility displays the expansion of the acronyms -specified on the command line. If the acronym is unknown, +utility displays the expansion of the acronyms +specified on the command line. +If the acronym is unknown, .Nm will check to see if the acronym is known by the .Xr whatis 1 @@ -25,7 +26,7 @@ command. If .Dq is is specified on the command line, it will be ignored, allowing the -fairly natural +fairly natural .Dq wtf is WTF usage. .Sh ENVIRONMENT diff --git a/wtf/wtf.in b/wtf/wtf.in index aa1e369..23ac184 100755 --- a/wtf/wtf.in +++ b/wtf/wtf.in @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: wtf,v 1.5 1999/08/13 03:02:06 sommerfeld Exp $ +# $NetBSD: wtf,v 1.8 2003/02/06 15:17:01 salo Exp $ # # Public domain # @@ -12,14 +12,14 @@ if [ X"$1" = X"is" ] ; then fi if [ $# -lt 1 ] ; then - echo "Usage: $0 [is] " + echo "Usage: `basename $0` [is] " fi rv=0 while [ $# -gt 0 ] ; do target=`echo $1 | tr '[a-z]' '[A-Z]'` - ans=`sed -ne "/^$target[[:space:]]/s/^$target[[:space:]]*//p" \ - < $acronyms 2>/dev/null` + ans=`fgrep $target < $acronyms 2>/dev/null \ + | sed -ne "\|^$target[[:space:]]|s|^$target[[:space:]]*||p"` if [ "$ans" != "" ] ; then echo "$target: $ans" else diff --git a/wump/Makefile.bsd b/wump/Makefile.bsd index 0109c0e..5446078 100644 --- a/wump/Makefile.bsd +++ b/wump/Makefile.bsd @@ -1,10 +1,14 @@ -# $NetBSD: Makefile,v 1.6 1997/03/24 22:15:51 christos Exp $ +# $NetBSD: Makefile,v 1.8 1999/02/13 02:54:22 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 +.include + PROG= wump MAN= wump.6 HIDEGAME=hidegame +.if ${MKSHARE} != "no" FILES=wump.info FILESDIR=/usr/share/games +.endif .include diff --git a/wump/Makefrag b/wump/Makefrag index edc0578..87d0aa0 100644 --- a/wump/Makefrag +++ b/wump/Makefrag @@ -1,4 +1,30 @@ # Makefrag - makefile fragment for wump +# +# Copyright (c) 1997, 1998 Joseph Samuel Myers. +# 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. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. wump_DIRS := $(GAMESDIR) $(MAN6DIR) $(shell dirname $(WUMP_INFOFILE)) diff --git a/wump/wump.c b/wump/wump.c index 37f8278..fa616db 100644 --- a/wump/wump.c +++ b/wump/wump.c @@ -1,4 +1,4 @@ -/* $NetBSD: wump.c,v 1.7 1998/09/13 15:27:31 hubertf Exp $ */ +/* $NetBSD: wump.c,v 1.14 2001/08/31 07:16:22 jsm Exp $ */ /* * Copyright (c) 1989, 1993 @@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\ #if 0 static char sccsid[] = "@(#)wump.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: wump.c,v 1.7 1998/09/13 15:27:31 hubertf Exp $"); +__RCSID("$NetBSD: wump.c,v 1.14 2001/08/31 07:16:22 jsm Exp $"); #endif #endif /* not lint */ @@ -120,6 +120,7 @@ int bats_nearby __P((void)); void cave_init __P((void)); void clear_things_in_cave __P((void)); void display_room_stats __P((void)); +int gcd __P((int, int)); int getans __P((const char *)); void initialize_things_in_cave __P((void)); void instructions __P((void)); @@ -520,6 +521,18 @@ The arrow is weakly shot and can go no further!\n"); return(0); } +int +gcd(a, b) + int a, b; +{ + int r; + + r = a % b; + if (r == 0) + return (b); + return (gcd(b, r)); +} + void cave_init() { @@ -542,8 +555,14 @@ cave_init() for (j = 0; j < link_num ; ++j) cave[i].tunnel[j] = -1; - /* choose a random 'hop' delta for our guaranteed link */ - while (!(delta = random() % room_num)); + /* + * Choose a random 'hop' delta for our guaranteed link. + * To keep the cave connected, we need the greatest common divisor + * of (delta + 1) and room_num to be 1. + */ + do { + delta = (random() % (room_num - 1)) + 1; + } while (gcd(room_num, delta + 1) != 1); for (i = 1; i <= room_num; ++i) { link = ((i + delta) % room_num) + 1; /* connection */ @@ -730,7 +749,7 @@ int_compare(a, b) void instructions() { - char *pager; + const char *pager; pid_t pid; int status; int fd; @@ -749,7 +768,7 @@ puff of greasy black smoke! (poof)\n"); return; } - if (!isatty(1)) + if (!isatty(STDOUT_FILENO)) pager = "cat"; else { if (!(pager = getenv("PAGER")) || (*pager == 0)) @@ -759,7 +778,7 @@ puff of greasy black smoke! (poof)\n"); case 0: /* child */ if ((fd = open(_PATH_WUMPINFO, O_RDONLY)) == -1) err(1, "open %s", _PATH_WUMPINFO); - if (dup2(fd, 0) == -1) + if (dup2(fd, STDIN_FILENO) == -1) err(1, "dup2"); (void)execl("/bin/sh", "sh", "-c", pager, NULL); err(1, "exec sh -c %s", pager);