copy in from cvs; cvs2svn fucked up big time

git-svn-id: file:///srv/svn/joey/trunk/src/packages/bsdgames@9775 a4a2c43b-8ac3-0310-8836-e0e880c912e2
This commit is contained in:
joey
2003-12-19 19:12:08 +00:00
parent 351c8ca204
commit 51eabc017b
310 changed files with 7852 additions and 5005 deletions

View File

@@ -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 # @(#)Makefile 8.1 (Berkeley) 6/12/93
PROG= adventure PROG= adventure
@@ -8,9 +8,9 @@ HIDEGAME=hidegame
CLEANFILES+=setup data.c CLEANFILES+=setup data.c
data.c: glorkz setup data.c: glorkz setup
${.OBJDIR}/setup ${.CURDIR}/glorkz > data.c ./setup ${.CURDIR}/glorkz > data.c
setup: setup.c hdr.h setup: setup.c hdr.h
${HOST_CC} -o setup ${.CURDIR}/setup.c ${HOST_LINK.c} -o setup ${.CURDIR}/setup.c
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@@ -1,4 +1,30 @@
# Makefrag - makefile fragment for adventure # 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_CLEANFILES := data.c
adventure_DIRS := $(GAMESDIR) $(MAN6DIR) adventure_DIRS := $(GAMESDIR) $(MAN6DIR)

View File

@@ -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 * Copyright (c) 1993
@@ -42,7 +42,7 @@
static char sccsid[] = "@(#)crc.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)crc.c 8.1 (Berkeley) 5/31/93";
static char ORIGINAL_sccsid[] = "@(#)crc.c 5.2 (Berkeley) 4/4/91"; static char ORIGINAL_sccsid[] = "@(#)crc.c 5.2 (Berkeley) 4/4/91";
#else #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
#endif /* not lint */ #endif /* not lint */

View File

@@ -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 * Copyright (c) 1991, 1993
@@ -43,13 +43,14 @@
#if 0 #if 0
static char sccsid[] = "@(#)done.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)done.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
/* Re-coding of advent in C: termination routines */ /* Re-coding of advent in C: termination routines */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include "hdr.h" #include "hdr.h"
#include "extern.h" #include "extern.h"

View File

@@ -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 * Copyright (c) 1991, 1993
@@ -51,15 +51,18 @@
* *
* The data file distributed with the fortran source is assumed to be called * The data file distributed with the fortran source is assumed to be called
* "glorkz" in the directory where the program is first run. * "glorkz" in the directory where the program is first run.
*
* The original FORTRAN version can be found at
* <URL:ftp://ftp.gmd.de/if-archive/games/source/advent-original.tar.gz>.
*/ */
/* hdr.h: included by c advent files */ /* hdr.h: included by c advent files */
#include <signal.h> #include <signal.h>
int datfd; /* message file descriptor */ extern int datfd; /* message file descriptor */
volatile sig_atomic_t delhit; extern volatile sig_atomic_t delhit;
int yea; extern int yea;
extern char data_file[]; /* Virtual data file */ extern char data_file[]; /* Virtual data file */
#define TAB 011 #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 FLUSHLINE do { int flushline_ch; while ((flushline_ch = getchar()) != EOF && flushline_ch != '\n'); } while (0)
#define FLUSHLF while (next()!=LF) #define FLUSHLF while (next()!=LF)
int loc, newloc, oldloc, oldlc2, wzdark, gaveup, kq, k, k2; extern int loc, newloc, oldloc, oldlc2, wzdark, gaveup, kq, k, k2;
char *wd1, *wd2; /* the complete words */ extern char *wd1, *wd2; /* the complete words */
int verb, obj, spk; extern int verb, obj, spk;
extern int blklin; extern int blklin;
int saved, savet, mxscor, latncy; extern int saveday, savet, mxscor, latncy;
#define SHORT 50 /* How short is a demo game? */ #define SHORT 50 /* How short is a demo game? */
#define MAXSTR 20 /* max length of user's words */ #define MAXSTR 20 /* max length of user's words */
#define HTSIZE 512 /* max number of vocab 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) */ int val; /* word type &index (ktab) */
char *atab; /* pointer to actual string */ char *atab; /* pointer to actual string */
} voc[HTSIZE]; } voc[HTSIZE];
#define SEED 1815622 /* "Encryption" seed */ #define SEED 1815622 /* "Encryption" seed */
struct text struct text
#ifdef OLDSTUFF
{
int seekadr; /* DATFILE must be < 2**16 */
#endif /* OLDSTUFF */
{ {
char *seekadr;/* Msg start in virtual disk */ char *seekadr;/* Msg start in virtual disk */
int txtlen; /* length of msg starting here */ int txtlen; /* length of msg starting here */
}; };
#define RTXSIZ 205 #define RTXSIZ 205
struct text rtext[RTXSIZ]; /* random text messages */ extern struct text rtext[RTXSIZ]; /* random text messages */
#define MAGSIZ 35 #define MAGSIZ 35
struct text mtext[MAGSIZ]; /* magic messages */ extern struct text mtext[MAGSIZ]; /* magic messages */
int clsses; extern int clsses;
#define CLSMAX 12 #define CLSMAX 12
struct text ctext[CLSMAX]; /* classes of adventurer */ extern struct text ctext[CLSMAX]; /* classes of adventurer */
int cval[CLSMAX]; extern int cval[CLSMAX];
struct text ptext[101]; /* object descriptions */ extern struct text ptext[101]; /* object descriptions */
#define LOCSIZ 141 /* number of locations */ #define LOCSIZ 141 /* number of locations */
struct text ltext[LOCSIZ]; /* long loc description */ extern struct text ltext[LOCSIZ]; /* long loc description */
struct text stext[LOCSIZ]; /* short loc descriptions */ 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 */ struct travlist *next; /* ptr to next list entry */
int conditions; /* m in writeup (newloc / 1000) */ int conditions; /* m in writeup (newloc / 1000) */
int tloc; /* n in writeup (newloc % 1000) */ int tloc; /* n in writeup (newloc % 1000) */
int tverb; /* the verb that takes you there */ int tverb; /* the verb that takes you there */
} *travel[LOCSIZ], *tkk; /* travel is closer to keys(...) */ } *travel[LOCSIZ], *tkk; /* travel is closer to keys(...) */
int atloc[LOCSIZ]; extern int atloc[LOCSIZ];
int plac[101]; /* initial object placement */ extern int plac[101]; /* initial object placement */
int fixd[101], fixed[101]; /* location fixed? */ extern int fixd[101], fixed[101]; /* location fixed? */
int actspk[35]; /* rtext msg for verb <n> */ extern int actspk[35]; /* rtext msg for verb <n> */
int cond[LOCSIZ]; /* various condition bits */ extern int cond[LOCSIZ]; /* various condition bits */
extern int setbit[16]; /* bit defn masks 1,2,4,... */ extern int setbit[16]; /* bit defn masks 1,2,4,... */
int hntmax; extern int hntmax;
int hints[20][5]; /* info on hints */ extern int hints[20][5]; /* info on hints */
int hinted[20], hintlc[20]; extern int hinted[20], hintlc[20];
int place[101], prop[101], links[201]; extern int place[101], prop[101], links[201];
int abb[LOCSIZ]; extern int abb[LOCSIZ];
int maxtrs, tally, tally2; /* treasure values */ extern int maxtrs, tally, tally2; /* treasure values */
#define FALSE 0 #define FALSE 0
#define TRUE 1 #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, bird, door, pillow, snake, fissur, tablet, clam, oyster,
magzin, dwarf, knife, food, bottle, water, oil, plant, plant2, magzin, dwarf, knife, food, bottle, water, oil, plant, plant2,
axe, mirror, dragon, chasm, troll, troll2, bear, messag, axe, mirror, dragon, chasm, troll, troll2, bear, messag,
@@ -150,15 +149,15 @@ struct text
null, entrnc, dprssn, enter, stream, pour, say, lock, throw, null, entrnc, dprssn, enter, stream, pour, say, lock, throw,
find, invent; 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; odloc[7], dflag, daltlc;
int tk[21], stick, dtotal, attack; extern int tk[21], stick, dtotal, attack;
int turns, lmwarn, iwest, knfloc, detail, /* various flags and extern int turns, lmwarn, iwest, knfloc, detail, /* various flags and
* counters */ * counters */
abbnum, maxdie, numdie, holdng, dkill, foobar, bonus, clock1, abbnum, maxdie, numdie, holdng, dkill, foobar, bonus, clock1,
clock2, saved, closng, panic, closed, scorng; 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+'%') #define DECR(a,b,c,d,e) decr(a+'+',b+'-',c+'#',d+'&',e+'%')

View File

@@ -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 * Copyright (c) 1993
@@ -43,7 +43,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 6/2/93"; static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 6/2/93";
#else #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
#endif /* not lint */ #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, int setbit[16] = {1, 2, 4, 010, 020, 040, 0100, 0200, 0400, 01000, 02000, 04000,
010000, 020000, 040000, 0100000}; 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 <n> */
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 void
init() /* everything for 1st time run */ init() /* everything for 1st time run */
@@ -217,7 +281,7 @@ linkdata()
void void
trapdel(n) /* come here if he hits a del */ trapdel(n) /* come here if he hits a del */
int n __attribute__((unused)); int n __attribute__((__unused__));
{ {
delhit = 1; /* main checks, treats as QUIT */ delhit = 1; /* main checks, treats as QUIT */
signal(SIGINT, trapdel);/* catch subsequent DELs */ signal(SIGINT, trapdel);/* catch subsequent DELs */

View File

@@ -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 * Copyright (c) 1991, 1993
@@ -43,7 +43,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -361,7 +361,7 @@ rtrav()
if (locc != oldloc) { /* getting a new entry */ if (locc != oldloc) { /* getting a new entry */
t = travel[locc] = (struct travlist *) malloc(sizeof(struct travlist)); t = travel[locc] = (struct travlist *) malloc(sizeof(struct travlist));
if ( t == NULL) if ( t == NULL)
errx(1, "Out of memory!"); err(1, NULL);
/* printf("New travel list for %d\n",locc); */ /* printf("New travel list for %d\n",locc); */
entries = 0; entries = 0;
oldloc = locc; oldloc = locc;
@@ -384,7 +384,7 @@ rtrav()
if (entries++) { if (entries++) {
t = t->next = (struct travlist *) malloc(sizeof(struct travlist)); t = t->next = (struct travlist *) malloc(sizeof(struct travlist));
if (t == NULL) if (t == NULL)
errx(1, "Out of memory!"); err(1, NULL);
} }
t->tverb = rnum(); /* get verb from the file */ t->tverb = rnum(); /* get verb from the file */
t->tloc = n; /* table entry mod 1000 */ t->tloc = n; /* table entry mod 1000 */
@@ -559,7 +559,7 @@ pspeak(m, skip) /* read, decrypt an print a ptext message */
msg = &ptext[m]; msg = &ptext[m];
if ((tbuf = (char *) malloc(msg->txtlen + 1)) == NULL) 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 */ memcpy(tbuf, msg->seekadr, msg->txtlen + 1); /* Room to null */
s = tbuf; s = tbuf;

View File

@@ -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 * Copyright (c) 1991, 1993
@@ -48,7 +48,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\n\
#if 0 #if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/2/93"; static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/2/93";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -58,6 +58,7 @@ __RCSID("$NetBSD: main.c,v 1.12 1998/09/14 09:29:08 hubertf Exp $");
#include <err.h> #include <err.h>
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include "hdr.h" #include "hdr.h"
#include "extern.h" #include "extern.h"
@@ -73,7 +74,7 @@ main(argc, argv)
int rval, ll; int rval, ll;
struct text *kk; struct text *kk;
/* revoke setgid privileges */ /* revoke setgid privileges from dm */
setregid(getgid(), getgid()); setregid(getgid(), getgid());
init(); /* Initialize everything */ init(); /* Initialize everything */
@@ -451,7 +452,7 @@ l4080:
printf(" %d minutes before continuing.", latncy); printf(" %d minutes before continuing.", latncy);
if (!yes(200, 54, 54)) if (!yes(200, 54, 54))
goto l2012; goto l2012;
datime(&saved, &savet); datime(&saveday, &savet);
ciao(); /* Do we quit? */ ciao(); /* Do we quit? */
continue; /* Maybe not */ continue; /* Maybe not */
case 31: /* hours=8310 */ case 31: /* hours=8310 */

View File

@@ -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 * Copyright (c) 1991, 1993
@@ -43,10 +43,11 @@
#if 0 #if 0
static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
#include <err.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "hdr.h" #include "hdr.h"
@@ -95,7 +96,7 @@ struct savestruct save_array[] =
{&oldlc2, sizeof(oldlc2)}, {&oldlc2, sizeof(oldlc2)},
{&oldloc, sizeof(oldloc)}, {&oldloc, sizeof(oldloc)},
{&panic, sizeof(panic)}, {&panic, sizeof(panic)},
{&saved, sizeof(saved)}, {&saveday, sizeof(saveday)},
{&savet, sizeof(savet)}, {&savet, sizeof(savet)},
{&scorng, sizeof(scorng)}, {&scorng, sizeof(scorng)},
{&spk, sizeof(spk)}, {&spk, sizeof(spk)},
@@ -152,7 +153,10 @@ save(outfile) /* Two passes on data: first to get checksum,
*s = (*s ^ random()) & 0xFF; /* Lightly encrypt */ *s = (*s ^ random()) & 0xFF; /* Lightly encrypt */
fwrite(p->address, p->width, 1, out); fwrite(p->address, p->width, 1, out);
} }
fclose(out); if (fclose(out) != 0) {
warn("writing %s", outfile);
return 1;
}
return 0; return 0;
} }

View File

@@ -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 * Copyright (c) 1991, 1993
@@ -36,17 +36,14 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <sys/cdefs.h>
#ifndef lint #ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1991, 1993\n\ static const char copyright[] __attribute__((__unused__)) = "@(#) Copyright (c) 1991, 1993\n\
The Regents of the University of California. All rights reserved.\n"); The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
#if 0 #if 0
static char sccsid[] = "@(#)setup.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)setup.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #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" #define SIG2 " * Sterday, 6 Thrimidge S.R. 1993, 15:24"
#include <stdio.h> #include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <err.h>
#include "hdr.h" /* SEED lives in there; keep them coordinated. */ #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 YES 1
#define NO 0 #define NO 0
#define LINE 10 /* How many values do we get on a line? */ #define LINE 10 /* How many values do we get on a line? */
int main __P((int, char *[])); int main(int, char *[]);
int int
main(argc, argv) main(argc, argv)
@@ -85,11 +83,16 @@ main(argc, argv)
FILE *infile; FILE *infile;
int c, count, linestart; int c, count, linestart;
if (argc != 2) if (argc != 2) {
errx(1, USAGE); fprintf(stderr, USAGE);
exit(1);
}
if ((infile = fopen(argv[1], "r")) == NULL) if ((infile = fopen(argv[1], "r")) == NULL) {
err(1, "Can't read file %s", argv[1]); 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("/*\n * data.c: created by setup from the ascii data file.");
puts(SIG1); puts(SIG1);
puts(SIG2); puts(SIG2);
@@ -121,5 +124,10 @@ main(argc, argv)
} }
puts("\n\t0\n};"); puts("\n\t0\n};");
fclose(infile); fclose(infile);
fflush(stdout);
if (ferror(stdout)) {
perror("error writing standard output");
exit(1);
}
exit(0); exit(0);
} }

View File

@@ -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 * Copyright (c) 1991, 1993
@@ -43,13 +43,14 @@
#if 0 #if 0
static char sccsid[] = "@(#)subr.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)subr.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
/* Re-coding of advent in C: subroutines from main */ /* Re-coding of advent in C: subroutines from main */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include "hdr.h" #include "hdr.h"
#include "extern.h" #include "extern.h"

View File

@@ -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 * Copyright (c) 1991, 1993
@@ -43,7 +43,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)vocab.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)vocab.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -165,7 +165,7 @@ vocab(word, type, value) /* look up or store a word */
h->val = value; h->val = value;
h->atab = malloc(length(word)); h->atab = malloc(length(word));
if (h->atab == NULL) if (h->atab == NULL)
errx(1, "Out of memory!"); err(1, NULL);
for (s = word, t = h->atab; *s;) for (s = word, t = h->atab; *s;)
*t++ = *s++ ^ '='; *t++ = *s++ ^ '=';
*t = 0 ^ '='; *t = 0 ^ '=';

View File

@@ -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 * Copyright (c) 1991, 1993
@@ -43,7 +43,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)wizard.c 8.1 (Berkeley) 6/2/93"; static char sccsid[] = "@(#)wizard.c 8.1 (Berkeley) 6/2/93";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -91,7 +91,7 @@ Start()
int d, t, delay; int d, t, delay;
datime(&d, &t); datime(&d, &t);
delay = (d - saved) * 1440 + (t - savet); /* good for about a delay = (d - saveday) * 1440 + (t - savet); /* good for about a
* month */ * month */
if (delay >= latncy) { if (delay >= latncy) {
@@ -137,7 +137,7 @@ ciao()
printf("What would you like to call the saved version?\n"); printf("What would you like to call the saved version?\n");
/* XXX - should use fgetln to avoid arbitrary limit */ /* XXX - should use fgetln to avoid arbitrary limit */
for (c = fname;; c++) { for (c = fname; c < fname + sizeof fname - 1; c++) {
int ch; int ch;
ch = getchar(); ch = getchar();
if (ch == '\n' || ch == EOF) if (ch == '\n' || ch == EOF)

View File

@@ -1,4 +1,30 @@
# Makefrag - makefile fragment for arithmetic # 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) arithmetic_DIRS := $(GAMESDIR) $(MAN6DIR)

View File

@@ -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 .\" Copyright (c) 1989, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@@ -38,7 +38,7 @@
.\" .\"
.Dd May 31, 1993 .Dd May 31, 1993
.Dt ARITHMETIC 6 .Dt ARITHMETIC 6
.Os BSD 4 .Os
.Sh NAME .Sh NAME
.Nm arithmetic .Nm arithmetic
.Nd quiz on simple arithmetic .Nd quiz on simple arithmetic
@@ -81,7 +81,8 @@ divide by or subtract will be between 0 and
.Ar range . .Ar range .
(Of course, (Of course,
.Nm .Nm
will not ask you to divide by 0.) The default will not ask you to divide by 0.)
The default
.I range .I range
is 10. is 10.
.El .El

View File

@@ -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 * Copyright (c) 1989, 1993
@@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
#if 0 #if 0
static char sccsid[] = "@(#)arithmetic.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)arithmetic.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -94,7 +94,7 @@ int main __P((int, char *[]));
int opnum __P((int)); int opnum __P((int));
void penalise __P((int, int, int)); void penalise __P((int, int, int));
int problem __P((void)); int problem __P((void));
void showstats __P((void)); void showstats __P((int));
void usage __P((void)) __attribute__((__noreturn__)); void usage __P((void)) __attribute__((__noreturn__));
const char keylist[] = "+-x/"; const char keylist[] = "+-x/";
@@ -106,6 +106,8 @@ int nright, nwrong;
time_t qtime; time_t qtime;
#define NQUESTS 20 #define NQUESTS 20
extern char *__progname; /* from crt0.o */
/* /*
* Select keys from +-x/ to be asked addition, subtraction, multiplication, * Select keys from +-x/ to be asked addition, subtraction, multiplication,
* and division problems. More than one key may be given. The default is * and division problems. More than one key may be given. The default is
@@ -118,8 +120,6 @@ main(argc, argv)
int argc; int argc;
char **argv; char **argv;
{ {
extern char *optarg;
extern int optind;
int ch, cnt; int ch, cnt;
/* Revoke setgid privileges */ /* Revoke setgid privileges */
@@ -157,7 +157,7 @@ main(argc, argv)
for (cnt = NQUESTS; cnt--;) for (cnt = NQUESTS; cnt--;)
if (problem() == EOF) if (problem() == EOF)
exit(0); exit(0);
showstats(); showstats(0);
} }
/* NOTREACHED */ /* NOTREACHED */
} }
@@ -165,15 +165,16 @@ main(argc, argv)
/* Handle interrupt character. Print score and exit. */ /* Handle interrupt character. Print score and exit. */
void void
intr(dummy) intr(dummy)
int dummy __attribute__((unused)); int dummy __attribute__((__unused__));
{ {
showstats(); showstats(1);
exit(0); exit(0);
} }
/* Print score. Original `arithmetic' had a delay after printing it. */ /* Print score. Original `arithmetic' had a delay after printing it. */
void void
showstats() showstats(bool_sigint)
int bool_sigint;
{ {
if (nright + nwrong > 0) { if (nright + nwrong > 0) {
(void)printf("\n\nRights %d; Wrongs %d; Score %d%%", (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", (void)printf("\nTotal time %ld seconds; %.1f seconds per problem\n\n",
(long)qtime, (float)qtime / nright); (long)qtime, (float)qtime / nright);
} }
if(!bool_sigint) {
(void)printf("Press RETURN to continue...\n");
while(!getchar()) ;
}
(void)printf("\n"); (void)printf("\n");
} }
@@ -388,9 +393,7 @@ opnum(op)
void void
usage() 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); __progname);
exit(1); exit(1);
} }

View File

@@ -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 # @(#)Makefile 8.1 (Berkeley) 5/31/93
SUBDIR= common_source backgammon teachgammon SUBDIR= common_source .WAIT backgammon teachgammon
all-backgammon all-teachgammon: all-common_source
.include <bsd.subdir.mk> .include <bsd.subdir.mk>

View File

@@ -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;\ .include <bsd.own.mk>
printf "xxx: .MAKE\n\t@echo \$${.OBJDIR}\n" | ${MAKE} -s -f-
LIBCOMMON != cd ${.CURDIR}/../common_source; ${PRINTOBJDIR}
CPPFLAGS+=-DV7 -I${.CURDIR}/../common_source CPPFLAGS+=-DV7 -I${.CURDIR}/../common_source
DPADD+= ${LIBCOMMON}/libcommon.a ${LIBTERMCAP} DPADD+= ${LIBCOMMON}/libcommon.a ${LIBTERMCAP}
LDADD+= -L${LIBCOMMON} -lcommon -ltermcap LDADD+= -L${LIBCOMMON} -lcommon -ltermcap

View File

@@ -1,4 +1,30 @@
# Makefrag - makefile fragment for backgammon # 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: backgammon_all:

View File

@@ -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 NOLINKLIB= # defined
SRCS= allow.c board.c check.c fancy.c init.c odds.c one.c save.c subs.c \ NOLINT= # defined
table.c NOPIC= # defined
NOPROFILE= # defined
NOPROFILE= noprofile LIB= common
NOPIC= nopic SRCS= allow.c board.c check.c fancy.c init.c odds.c \
one.c save.c subs.c table.c
# only needed during build
libinstall::
.include <bsd.lib.mk> .include <bsd.lib.mk>

View File

@@ -1,4 +1,30 @@
# Makefrag - makefile fragment for backgammon/common_source # 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_EXEC_PATH := $(GAMESDIR)/backgammon
backgammon_common_source_TEACH_PATH := $(GAMESDIR)/teachgammon backgammon_common_source_TEACH_PATH := $(GAMESDIR)/teachgammon

View File

@@ -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 * Copyright (c) 1980, 1993
@@ -146,7 +146,7 @@ void cline __P((void));
int count __P((void)); int count __P((void));
void curmove __P((int, int)); void curmove __P((int, int));
int dotable __P((char, int)); int dotable __P((char, int));
void errexit __P((const char *)); void errexit __P((const char *)) __attribute__((__noreturn__));
void fancyc __P((int)); void fancyc __P((int));
void fboard __P((void)); void fboard __P((void));
void fixcol __P((int, int, int, int, int)); void fixcol __P((int, int, int, int, int));
@@ -168,7 +168,7 @@ int movokay __P((int));
void newline __P((void)); void newline __P((void));
void newpos __P((void)); void newpos __P((void));
void nexturn __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 odds __P((int, int, int));
void proll __P((void)); void proll __P((void));
int quit __P((void)); int quit __P((void));

View File

@@ -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 * Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)board.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)board.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */

View File

@@ -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 * Copyright (c) 1980, 1993
@@ -38,14 +38,14 @@
#if 0 #if 0
static char sccsid[] = "@(#)fancy.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)fancy.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
#include "back.h" #include "back.h"
char PC; /* padding character */ extern char PC; /* padding character */
char *BC; /* backspace sequence */ extern char *BC; /* backspace sequence */
char *CD; /* clear to end of screen sequence */ char *CD; /* clear to end of screen sequence */
char *CE; /* clear to end of line sequence */ char *CE; /* clear to end of line sequence */
char *CL; /* clear screen sequence */ char *CL; /* clear screen sequence */
@@ -54,7 +54,7 @@ char *HO; /* home cursor sequence */
char *MC; /* column cursor movement map */ char *MC; /* column cursor movement map */
char *ML; /* row cursor movement map */ char *ML; /* row cursor movement map */
char *ND; /* forward cursor sequence */ char *ND; /* forward cursor sequence */
char *UP; /* up cursor sequence */ extern char *UP; /* up cursor sequence */
int lHO; /* length of HO */ int lHO; /* length of HO */
int lBC; /* length of BC */ int lBC; /* length of BC */

View File

@@ -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 * Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -67,7 +67,7 @@ int tflag = 0; /* cursor addressing flag */
int iroll = 0; /* special flag for inputting rolls */ int iroll = 0; /* special flag for inputting rolls */
int rfl = 0; int rfl = 0;
const char *const color[] = {"White", "Red", "white", "red"}; const char *const color[] = {"White", "Red", "white", "red"};
const char *const *Colorptr; const char *const *Colorptr;

View File

@@ -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 * Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -111,7 +111,7 @@ save(n)
close(fdesc); close(fdesc);
if (yorn(0)) { if (yorn(0)) {
unlink(fname); unlink(fname);
fdesc = creat(fname, 0700); fdesc = creat(fname, 0600);
break; break;
} else { } else {
cflag = 1; cflag = 1;

View File

@@ -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 * Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)subs.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)subs.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -84,7 +84,7 @@ addbuf(c)
buffnum = 0; buffnum = 0;
} }
outbuff[buffnum] = c; outbuff[buffnum] = c;
return 0; return (0);
} }
void void
@@ -325,7 +325,7 @@ getarg(arg)
* the game is being recovered */ * the game is being recovered */
s = *arg; s = *arg;
while (s[0] != NULL && s[0][0] == '-') { while (*s && s[0][0] == '-') {
switch (s[0][1]) { switch (s[0][1]) {
/* don't ask if rules or instructions needed */ /* don't ask if rules or instructions needed */
@@ -447,7 +447,7 @@ fixtty(t)
void void
getout(dummy) getout(dummy)
int dummy __attribute__((unused)); int dummy __attribute__((__unused__));
{ {
/* go to bottom of screen */ /* go to bottom of screen */
if (tflag) { if (tflag) {

View File

@@ -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 * Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */

View File

@@ -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 # @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= teachgammon NOMAN= # defined
SRCS= data.c teach.c ttext1.c ttext2.c tutor.c
NOMAN= noman PROG= teachgammon
SRCS= data.c teach.c ttext1.c ttext2.c tutor.c
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@@ -1,4 +1,30 @@
# Makefrag - makefile fragment for backgammon/teachgammon # 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_DEFS := -DV7
backgammon_teachgammon_DIRS := $(GAMESDIR) $(MAN6DIR) backgammon_teachgammon_DIRS := $(GAMESDIR) $(MAN6DIR)

View File

@@ -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 * Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)data.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)data.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */

View File

@@ -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 * Copyright (c) 1980, 1993
@@ -43,17 +43,13 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
#if 0 #if 0
static char sccsid[] = "@(#)teach.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)teach.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
#include "back.h" #include "back.h"
#include "tutor.h" #include "tutor.h"
#ifndef NCURSES_VERSION
extern speed_t ospeed; /* tty output speed for termlib */
#endif
const char *const helpm[] = { const char *const helpm[] = {
"\nEnter a space or newline to roll, or", "\nEnter a space or newline to roll, or",
" b to display the board", " b to display the board",
@@ -69,7 +65,7 @@ const char *const contin[] = {
int int
main(argc, argv) main(argc, argv)
int argc __attribute__((unused)); int argc __attribute__((__unused__));
char *argv[]; char *argv[];
{ {
int i; int i;
@@ -160,7 +156,7 @@ leave()
else else
writec('\n'); writec('\n');
fixtty(&old); 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"); writel("Help! Backgammon program is missing\007!!\n");
exit(-1); exit(1);
} }

View File

@@ -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 * Copyright (c) 1980, 1993
@@ -38,15 +38,15 @@
#if 0 #if 0
static char sccsid[] = "@(#)ttext1.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)ttext1.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
#include "back.h" #include "back.h"
#include "tutor.h" #include "tutor.h"
const char *opts = " QIMRHEDSPT"; const char *const opts = " QIMRHEDSPT";
const char *prompt = "-->"; const char *const prompt = "-->";
const char *const list[] = { const char *const list[] = {
"\n\n\tI\tIntroduction to Backgammon", "\n\n\tI\tIntroduction to Backgammon",

View File

@@ -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 * Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)ttext2.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)ttext2.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */

View File

@@ -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 * Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)tutor.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)tutor.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */

View File

@@ -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 * Copyright (c) 1980, 1993
@@ -58,9 +58,9 @@ extern const char *const lastch[];
extern const char *const list[]; extern const char *const list[];
extern int maxmoves; extern int maxmoves;
extern const char *const moves[]; extern const char *const moves[];
extern const char *opts; extern const char *const opts;
extern const char *const prog[]; extern const char *const prog[];
extern const char *prompt; extern const char *const prompt;
extern const char *const removepiece[]; extern const char *const removepiece[];
extern const char *const stragy[]; extern const char *const stragy[];
extern const struct situatn test[]; extern const struct situatn test[];

View File

@@ -1,4 +1,30 @@
# Makefrag - makefile fragment for banner # 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) banner_DIRS := $(GAMESDIR) $(MAN6DIR)

View File

@@ -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 .\" Copyright (c) 1980, 1993, 1995
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@@ -57,8 +57,8 @@ suitable for a narrow terminal.
The output should be printed on paper of the appropriate width, The output should be printed on paper of the appropriate width,
with no breaks between the pages. with no breaks between the pages.
.Sh BUGS .Sh BUGS
Several ASCII characters are not defined, notably <, >, [, ], \\, Several ASCII characters are not defined, notably \*[Lt], \*[Gt], [, ], \\,
^, _, {, }, |, and ~. Also, the characters ", ', and & are funny ^, _, {, }, |, and ~. Also, the characters ", ', and \*[Am] are funny
looking (but in a useful way.) looking (but in a useful way.)
.Pp .Pp
The The
@@ -67,4 +67,4 @@ option is implemented by skipping some rows and columns.
The smaller it gets, the grainier the output. The smaller it gets, the grainier the output.
Sometimes it runs letters together. Sometimes it runs letters together.
.Sh AUTHOR .Sh AUTHOR
Mark Horton .An Mark Horton

View File

@@ -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 * Copyright (c) 1980, 1993, 1994
@@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993, 1994\n\
#if 0 #if 0
static char sccsid[] = "@(#)banner.c 8.4 (Berkeley) 4/29/95"; static char sccsid[] = "@(#)banner.c 8.4 (Berkeley) 4/29/95";
#else #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
#endif /* not lint */ #endif /* not lint */

View File

@@ -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 # @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= battlestar 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 \ 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 globals.c dayfile.c nightfile.c dayobjs.c nightobjs.c words.c
MAN= battlestar.6 MAN= battlestar.6

View File

@@ -1,5 +1,32 @@
# Makefrag - makefile fragment for battlestar # 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_DIRS := $(GAMESDIR) $(MAN6DIR)
battlestar_all: battlestar/battlestar battlestar/battlestar.6 battlestar_all: battlestar/battlestar battlestar/battlestar.6

View File

@@ -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 .\" Copyright (c) 1983, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@@ -33,7 +33,7 @@
.\" .\"
.\" @(#)battlestar.6 8.1 (Berkeley) 5/31/93 .\" @(#)battlestar.6 8.1 (Berkeley) 5/31/93
.\" .\"
.Dd May 31, 1993 .Dd September 7, 2000
.Dt BATTLESTAR 6 .Dt BATTLESTAR 6
.Os .Os
.Sh NAME .Sh NAME
@@ -42,17 +42,15 @@
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl r .Op Fl r
.Op saved-file .Op Ar saved-file
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm .Nm
is an adventure game in the classic style. However, it's slightly less is an adventure game in the classic style.
of a However, it's slightly less of a puzzle and more a game of exploration.
puzzle and more a game of exploration. There are a few magical words There are a few magical words in the game, but on the whole, simple English
in the game, but on the whole, simple English
should suffice to make one's desires understandable to the parser. should suffice to make one's desires understandable to the parser.
.Sh THE SETTING .Sh THE SETTING
In the days before the darkness came, when battlestars ruled the In the days before the darkness came, when battlestars ruled the heavens...
heavens...
.Bd -literal -offset indent .Bd -literal -offset indent
Three He made and gave them to His daughters, Three He made and gave them to His daughters,
Beautiful nymphs, the goddesses of the waters. 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. Three to rule the world and purge the skies with thunder.
.Ed .Ed
.Pp .Pp
In those times great wizards were known and their powers were beyond In those times great wizards were known and their powers were beyond belief.
belief. They could take any object from thin air, and, uttering the They could take any object from thin air, and, uttering the word
word
.Sq su .Sq su
could disappear. could disappear.
.Pp .Pp
In those times men were known for their lust of gold and desire to 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 wear fine weapons.
withstand a laser blast. Swords and coats of mail were fashioned that could withstand a laser blast.
.Pp .Pp
But when the darkness fell, the rightful reigns were toppled. Swords But when the darkness fell, the rightful reigns were toppled.
and helms and heads of state went rolling across the grass. The entire Swords and helms and heads of state went rolling across the grass.
fleet of battlestars was reduced to a single ship. The entire fleet of battlestars was reduced to a single ship.
.Sh SAMPLE COMMANDS .Sh SAMPLE COMMANDS
.Bd -literal -offset indent .Bd -literal -offset indent
take --- take an object take --- take an object
@@ -85,19 +82,19 @@ draw --- carry an object you are wearing
puton --- take an object and wear it puton --- take an object and wear it
take off -- draw an object and drop it take off -- draw an object and drop it
throw <object> <direction> throw \*[Lt]object\*[Gt] \*[Lt]direction\*[Gt]
! <shell esc> ! \*[Lt]shell esc\*[Gt]
.Ed .Ed
.Sh IMPLIED OBJECTS .Sh IMPLIED OBJECTS
.Bd -literal -offset indent .Bd -literal -offset indent
>-: take watermelon \*[Gt]-: take watermelon
watermelon: watermelon:
Taken. Taken.
>-: eat \*[Gt]-: eat
watermelon: watermelon:
Eaten. Eaten.
>-: take knife and sword and apple, drop all \*[Gt]-: take knife and sword and apple, drop all
knife: knife:
Taken. Taken.
broadsword: broadsword:
@@ -110,31 +107,49 @@ broadsword:
Dropped. Dropped.
apple: apple:
Dropped. Dropped.
>-: get \*[Gt]-: get
knife: knife:
Taken. Taken.
.Ed .Ed
.Pp .Pp
Notice that the "shadow" of the next word stays around if you 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 want to take advantage of it.
"drop" That is, saying "take knife" and then "drop"
will drop the knife you just took. will drop the knife you just took.
.Sh SCORE & INVEN .Sh SCORE \*[Am] INVEN
The two commands "score" and "inven" will print out your current status The two commands
in the game. .Dq score
and
.Dq inven
will print out your current status in the game.
.Sh SAVING A GAME .Sh SAVING A GAME
The command "save" will save your game in a file, by default called The command
".Bstar" in your home directory. You .Dq save
can recover a saved game by using the 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 .Fl r
option when you start up the option when you start up the
game, or by giving the name of the saved file as an argument. 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 .Sh DIRECTIONS
The compass directions N, S, E, and W can be used if you have a compass. 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 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. stand for Right, Left, Ahead, and Back.
Directions printed in room descriptions are 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 .Sh HISTORY
I wrote Battlestar in 1979 in order to experiment with the niceties of I wrote Battlestar in 1979 in order to experiment with the niceties of
the C Language. 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! code, so don't send me any hate mail about it!
Instead, enjoy art for art's sake! Instead, enjoy art for art's sake!
.Sh AUTHOR .Sh AUTHOR
David Riggle .An David Riggle
.Sh INSPIRATION & ASSISTANCE .Sh INSPIRATION \*[Am] ASSISTANCE
.Bl -item -compact .Bl -item -compact
.It .It
Chris Guthrie Chris Guthrie
@@ -154,7 +169,7 @@ Kevin Brown
.It .It
Edward Wang Edward Wang
.It .It
Ken Arnold & Company Ken Arnold \*[Am] Company
.El .El
.Sh BUGS .Sh BUGS
Countless. Countless.

View File

@@ -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 * Copyright (c) 1983, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
#if 0 #if 0
static char sccsid[] = "@(#)battlestar.c 8.2 (Berkeley) 4/28/95"; static char sccsid[] = "@(#)battlestar.c 8.2 (Berkeley) 4/28/95";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -70,12 +70,16 @@ main(argc, argv)
open_score_file(); open_score_file();
setregid(getgid(), getgid()); setregid(getgid(), getgid());
initialize((argc < 2) ? NULL : (strcmp(argv[1], "-r") ? argv[1] if (argc < 2)
: (argv[2] ? argv[2] initialize(NULL);
: DEFAULT_SAVE_FILE))); else if (strcmp(argv[1], "-r") == 0)
initialize((argc > 2) ? argv[2] : DEFAULT_SAVE_FILE);
else
initialize(argv[1]);
start: start:
news(); news();
beenthere[position]++; if (beenthere[position] <= ROOMDESC)
beenthere[position]++;
if (notes[LAUNCHED]) if (notes[LAUNCHED])
crash(); /* decrements fuel & crash */ crash(); /* decrements fuel & crash */
if (matchlight) { if (matchlight) {
@@ -92,7 +96,7 @@ start:
run: run:
next = getcom(mainbuf, sizeof mainbuf, ">-: ", next = getcom(mainbuf, sizeof mainbuf, ">-: ",
"Please type in something."); "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); next = getword(next, words[wordcount], -1);
parse(); parse();
switch (cypher()) { switch (cypher()) {
@@ -101,6 +105,6 @@ run:
case 0: case 0:
goto start; goto start;
default: default:
exit(1); /* Shouldn't happen */ errx(1, "bad return from cypher(): please submit a bug report");
} }
} }

View File

@@ -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 * Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)cypher.c 8.2 (Berkeley) 4/28/95"; static char sccsid[] = "@(#)cypher.c 8.2 (Berkeley) 4/28/95";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -51,64 +51,82 @@ cypher()
int junk; int junk;
int lflag = -1; int lflag = -1;
char buffer[10]; char buffer[10];
char *filename; char *filename, *rfilename;
size_t filename_len; size_t filename_len;
while (wordtype[wordnumber] == ADJS)
wordnumber++;
while (wordnumber <= wordcount) { 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]) { switch (wordvalue[wordnumber]) {
case AUXVERB:
/*
* Take the following word as the verb (e.g.
* "make love", "climb up").
*/
wordnumber++;
continue;
case UP: case UP:
if (location[position].access || wiz || tempwiz) { if (location[position].access || wiz || tempwiz) {
if (!location[position].access) if (!location[position].access)
puts("Zap! A gust of wind lifts you up."); puts("Zap! A gust of wind lifts you up.");
if (!move(location[position].up, AHEAD)) if (!moveplayer(location[position].up, AHEAD))
return (-1); return (-1);
} else { } else {
puts("There is no way up"); puts("There is no way up.");
return (-1); return (-1);
} }
lflag = 0; lflag = 0;
break; break;
case DOWN: case DOWN:
if (!move(location[position].down, AHEAD)) if (!moveplayer(location[position].down, AHEAD))
return (-1); return (-1);
lflag = 0; lflag = 0;
break; break;
case LEFT: case LEFT:
if (!move(left, LEFT)) if (!moveplayer(left, LEFT))
return (-1); return (-1);
lflag = 0; lflag = 0;
break; break;
case RIGHT: case RIGHT:
if (!move(right, RIGHT)) if (!moveplayer(right, RIGHT))
return (-1); return (-1);
lflag = 0; lflag = 0;
break; break;
case AHEAD: case AHEAD:
if (!move(ahead, AHEAD)) if (!moveplayer(ahead, AHEAD))
return (-1); return (-1);
lflag = 0; lflag = 0;
break; break;
case BACK: case BACK:
if (!move(back, BACK)) if (!moveplayer(back, BACK))
return (-1); return (-1);
lflag = 0; lflag = 0;
break; break;
case SHOOT: case SHOOT:
if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
int things;
things = 0;
for (n = 0; n < NUMOFOBJECTS; n++) for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(location[position].objects, n) && objsht[n]) { if (testbit(location[position].objects, n) && objsht[n]) {
things++;
wordvalue[wordnumber + 1] = n; wordvalue[wordnumber + 1] = n;
wordnumber = shoot(); wordnumber = shoot();
} }
if (!things)
puts("Nothing to shoot at!");
wordnumber++; wordnumber++;
wordnumber++; wordnumber++;
} else } else
@@ -117,8 +135,11 @@ cypher()
case TAKE: case TAKE:
if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
int things;
things = 0;
for (n = 0; n < NUMOFOBJECTS; n++) for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(location[position].objects, n) && objsht[n]) { if (testbit(location[position].objects, n) && objsht[n]) {
things++;
wordvalue[wordnumber + 1] = n; wordvalue[wordnumber + 1] = n;
/* Some objects (type NOUNS) /* Some objects (type NOUNS)
* have special treatment in * have special treatment in
@@ -138,6 +159,7 @@ cypher()
switch(n) { switch(n) {
case BATHGOD: case BATHGOD:
wordvalue[wordnumber + 1] = NORMGOD; wordvalue[wordnumber + 1] = NORMGOD;
/* FALLTHROUGH */
case NORMGOD: case NORMGOD:
case AMULET: case AMULET:
case MEDALION: case MEDALION:
@@ -154,120 +176,160 @@ cypher()
} }
wordnumber++; wordnumber++;
wordnumber++; wordnumber++;
if (!things)
puts("Nothing to take!");
} else } else
take(location[position].objects); take(location[position].objects);
break; break;
case DROP: case DROP:
if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
int things;
things = 0;
for (n = 0; n < NUMOFOBJECTS; n++) for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(inven, n)) { if (testbit(inven, n)) {
things++;
wordvalue[wordnumber + 1] = n; wordvalue[wordnumber + 1] = n;
wordnumber = drop("Dropped"); wordnumber = drop("Dropped");
} }
wordnumber++; wordnumber++;
wordnumber++; wordnumber++;
if (!things)
puts("Nothing to drop!");
} else } else
drop("Dropped"); drop("Dropped");
break; break;
case KICK: case KICK:
case THROW: case THROW:
if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
int things, wv;
things = 0;
wv = wordvalue[wordnumber];
for (n = 0; n < NUMOFOBJECTS; n++) for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(inven, n) || if (testbit(inven, n) ||
(testbit(location[position].objects, n) && objsht[n])) { (testbit(location[position].objects, n) && objsht[n])) {
things++;
wordvalue[wordnumber + 1] = n; wordvalue[wordnumber + 1] = n;
wordnumber = throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown"); wordnumber = throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
} }
wordnumber += 2; wordnumber += 2;
if (!things)
printf("Nothing to %s!\n", wv == KICK ? "kick" : "throw");
} else } else
throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown"); throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
break; break;
case TAKEOFF: case TAKEOFF:
if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
int things;
things = 0;
for (n = 0; n < NUMOFOBJECTS; n++) for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(wear, n)) { if (testbit(wear, n)) {
things++;
wordvalue[wordnumber + 1] = n; wordvalue[wordnumber + 1] = n;
wordnumber = takeoff(); wordnumber = takeoff();
} }
wordnumber += 2; wordnumber += 2;
if (!things)
puts("Nothing to take off!");
} else } else
takeoff(); takeoff();
break; break;
case DRAW: case DRAW:
if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
int things;
things = 0;
for (n = 0; n < NUMOFOBJECTS; n++) for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(wear, n)) { if (testbit(wear, n)) {
things++;
wordvalue[wordnumber + 1] = n; wordvalue[wordnumber + 1] = n;
wordnumber = draw(); wordnumber = draw();
} }
wordnumber += 2; wordnumber += 2;
if (!things)
puts("Nothing to draw!");
} else } else
draw(); draw();
break; break;
case PUTON: case PUTON:
if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
int things;
things = 0;
for (n = 0; n < NUMOFOBJECTS; n++) for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(location[position].objects, n) && objsht[n]) { if (testbit(location[position].objects, n) && objsht[n]) {
things++;
wordvalue[wordnumber + 1] = n; wordvalue[wordnumber + 1] = n;
wordnumber = puton(); wordnumber = puton();
} }
wordnumber += 2; wordnumber += 2;
if (!things)
puts("Nothing to put on!");
} else } else
puton(); puton();
break; break;
case WEARIT: case WEARIT:
if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
int things;
things = 0;
for (n = 0; n < NUMOFOBJECTS; n++) for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(inven, n)) { if (testbit(inven, n)) {
things++;
wordvalue[wordnumber + 1] = n; wordvalue[wordnumber + 1] = n;
wordnumber = wearit(); wordnumber = wearit();
} }
wordnumber += 2; wordnumber += 2;
if (!things)
puts("Nothing to wear!");
} else } else
wearit(); wearit();
break; break;
case EAT: case EAT:
if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) { if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
int things;
things = 0;
for (n = 0; n < NUMOFOBJECTS; n++) for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(inven, n)) { if (testbit(inven, n)) {
things++;
wordvalue[wordnumber + 1] = n; wordvalue[wordnumber + 1] = n;
wordnumber = eat(); wordnumber = eat();
} }
wordnumber += 2; wordnumber += 2;
if (!things)
puts("Nothing to eat!");
} else } else
eat(); eat();
break; break;
case PUT: case PUT:
put(); put();
break; break;
case INVEN: case INVEN:
if (ucard(inven)) { if (ucard(inven)) {
puts("You are holding:\n"); puts("You are holding:\n");
for (n = 0; n < NUMOFOBJECTS; n++) for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(inven, n)) if (testbit(inven, n))
printf("\t%s\n", objsht[n]); printf("\t%s\n", objsht[n]);
printf("\n= %d kilogram%s (%d%%)\n", carrying, (carrying == 1 ? "." : "s."), (WEIGHT ? carrying * 100 / WEIGHT : -1)); if (WEIGHT == 0)
printf("Your arms are %d%% full.\n", encumber * 100 / CUMBER); 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 } else
puts("You aren't carrying anything."); 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.")); printf("\nYou can still carry up to %d kilogram%s\n", WEIGHT, (WEIGHT == 1 ? "." : "s."));
} else } else
puts("\nYou are in perfect health."); puts("\nYou are in perfect health.");
wordnumber++;
break; break;
case USE: case USE:
lflag = use(); lflag = use();
break; 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: case LOOK:
if (!notes[CANTSEE] || testbit(inven, LAMPON) || if (!notes[CANTSEE] || testbit(inven, LAMPON) ||
testbit(location[position].objects, LAMPON) testbit(location[position].objects, LAMPON)
@@ -369,18 +449,31 @@ cypher()
break; break;
case SAVE: case SAVE:
printf("\nSave file name (default %s) ", printf("\nSave file name (default %s): ",
DEFAULT_SAVE_FILE); DEFAULT_SAVE_FILE);
filename = fgetln(stdin, &filename_len); filename = fgetln(stdin, &filename_len);
if (filename_len == 0 if (filename_len == 0
|| (filename_len == 1 && filename[0] == '\n')) || (filename_len == 1 && filename[0] == '\n'))
save(DEFAULT_SAVE_FILE, rfilename = save_file_name(DEFAULT_SAVE_FILE,
strlen(DEFAULT_SAVE_FILE)); strlen(DEFAULT_SAVE_FILE));
else { else {
if (filename[filename_len - 1] == '\n') if (filename[filename_len - 1] == '\n')
filename_len--; 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; break;
case FOLLOW: case FOLLOW:
@@ -461,7 +554,6 @@ cypher()
return (-1); return (-1);
break; break;
} }
if (wordnumber < wordcount && *words[wordnumber++] == ',') if (wordnumber < wordcount && *words[wordnumber++] == ',')
continue; continue;

File diff suppressed because it is too large Load Diff

View File

@@ -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 * Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)dayobjs.c 8.2 (Berkeley) 4/28/95"; static char sccsid[] = "@(#)dayobjs.c 8.2 (Berkeley) 4/28/95";
#else #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
#endif /* not lint */ #endif /* not lint */

View File

@@ -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 * Copyright (c) 1983, 1993
@@ -35,8 +35,6 @@
* @(#)externs.h 8.1 (Berkeley) 5/31/93 * @(#)externs.h 8.1 (Berkeley) 5/31/93
*/ */
#include <sys/time.h>
#include <ctype.h> #include <ctype.h>
#include <err.h> #include <err.h>
#include <pwd.h> #include <pwd.h>
@@ -44,6 +42,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h>
#include <unistd.h> #include <unistd.h>
#define BITS (8 * sizeof (int)) #define BITS (8 * sizeof (int))
@@ -188,6 +187,10 @@
#define BURY 1050 #define BURY 1050
#define JUMP 1051 #define JUMP 1051
#define KICK 1052 #define KICK 1052
#define OPEN 1053
#define VERBOSE 1054
#define BRIEF 1055
#define AUXVERB 1056
/* injuries */ /* injuries */
#define ARM 6 /* broken arm */ #define ARM 6 /* broken arm */
@@ -207,6 +210,9 @@
#define DUG 5 #define DUG 5
#define NUMOFNOTES 6 #define NUMOFNOTES 6
/* Number of times room description shown. */
#define ROOMDESC 3
/* fundamental constants */ /* fundamental constants */
#define NUMOFROOMS 275 #define NUMOFROOMS 275
#define NUMOFWORDS ((NUMOFOBJECTS + BITS - 1) / BITS) #define NUMOFWORDS ((NUMOFOBJECTS + BITS - 1) / BITS)
@@ -222,6 +228,19 @@
#define MAXWEIGHT 60 #define MAXWEIGHT 60
#define MAXCUMBER 10 #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 { struct room {
const char *name; const char *name;
int link[8]; int link[8];
@@ -238,7 +257,7 @@ struct room {
}; };
extern struct room dayfile[]; extern struct room dayfile[];
extern struct room nightfile[]; extern struct room nightfile[];
struct room *location; extern struct room *location;
/* object characteristics */ /* object characteristics */
extern const char *const objdes[NUMOFOBJECTS]; extern const char *const objdes[NUMOFOBJECTS];
@@ -246,55 +265,62 @@ extern const char *const objsht[NUMOFOBJECTS];
extern const char *const ouch[NUMOFINJURIES]; extern const char *const ouch[NUMOFINJURIES];
extern const int objwt[NUMOFOBJECTS]; extern const int objwt[NUMOFOBJECTS];
extern const int objcumber[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 */ /* current input line */
#define WORDLEN 15
#define NWORD 20 /* words per line */ #define NWORD 20 /* words per line */
char words[NWORD][15]; extern char words[NWORD][WORDLEN];
int wordvalue[NWORD]; extern int wordvalue[NWORD];
int wordtype[NWORD]; extern int wordtype[NWORD];
int wordcount, wordnumber; extern int wordcount, wordnumber;
/* state of the game */ /* state of the game */
int ourtime; extern int ourtime;
int position; extern int position;
int direction; extern int direction;
int left, right, ahead, back; extern int left, right, ahead, back;
int ourclock, fuel, torps; extern int ourclock, fuel, torps;
int carrying, encumber; extern int carrying, encumber;
int rythmn; extern int rythmn;
extern int followfight; extern int followfight;
int ate; extern int ate;
int snooze; extern int snooze;
int meetgirl; extern int meetgirl;
extern int followgod; extern int followgod;
int godready; extern int godready;
extern int win; extern int win;
int wintime; extern int wintime;
int wiz; extern int wiz;
int tempwiz; extern int tempwiz;
int matchlight; extern int matchlight, matchcount;
extern int matchcount; extern int loved;
int loved; extern int pleasure, power, ego;
int pleasure, power, ego;
extern int WEIGHT; extern int WEIGHT;
extern int CUMBER; extern int CUMBER;
int notes[NUMOFNOTES]; extern int notes[NUMOFNOTES];
unsigned int inven[NUMOFWORDS]; extern unsigned int inven[NUMOFWORDS];
unsigned int wear[NUMOFWORDS]; extern unsigned int wear[NUMOFWORDS];
char beenthere[NUMOFROOMS + 1]; extern char beenthere[NUMOFROOMS + 1];
char injuries[NUMOFINJURIES]; extern char injuries[NUMOFINJURIES];
extern int verbose;
char username[9]; extern const char *username;
struct wlist { struct wlist {
const char *string; const char *string;
int value, article; int value, article;
struct wlist *next; struct wlist *next;
}; };
#define HASHSIZE 256
#define HASHMUL 81
#define HASHMASK (HASHSIZE - 1)
struct wlist *hashtab[HASHSIZE];
extern struct wlist wlist[]; extern struct wlist wlist[];
struct objs { struct objs {
@@ -306,10 +332,8 @@ extern const struct objs nightobjs[];
#define DEFAULT_SAVE_FILE ".Bstar" #define DEFAULT_SAVE_FILE ".Bstar"
void blast __P((void));
void bury __P((void)); void bury __P((void));
int card __P((const char *, int)); int card __P((const char *, int));
int checkout __P((const char *));
void chime __P((void)); void chime __P((void));
void convert __P((int)); void convert __P((int));
void crash __P((void)); void crash __P((void));
@@ -317,19 +341,18 @@ int cypher __P((void));
void die __P((void)) __attribute__((__noreturn__)); void die __P((void)) __attribute__((__noreturn__));
void diesig __P((int)) __attribute__((__noreturn__)); void diesig __P((int)) __attribute__((__noreturn__));
void dig __P((void)); void dig __P((void));
void dooropen __P((void));
int draw __P((void)); int draw __P((void));
void drink __P((void)); void drink __P((void));
int drive __P((void)); int drive __P((void));
int drop __P((const char *)); int drop __P((const char *));
int eat __P((void)); int eat __P((void));
void endfly __P((void));
int fight __P((int, int)); int fight __P((int, int));
int follow __P((void)); 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 give __P((void));
int hash __P((const char *));
void initialize __P((const char *)); void initialize __P((const char *));
void install __P((struct wlist *));
int jump __P((void)); int jump __P((void));
void kiss __P((void)); void kiss __P((void));
int land __P((void)); int land __P((void));
@@ -337,40 +360,32 @@ int launch __P((void));
void light __P((void)); void light __P((void));
void live __P((void)) __attribute__((__noreturn__)); void live __P((void)) __attribute__((__noreturn__));
void love __P((void)); void love __P((void));
int move __P((int, int)); int moveplayer __P((int, int));
void moveenemy __P((int));
void murder __P((void)); void murder __P((void));
void news __P((void)); void news __P((void));
void newway __P((int)); void newway __P((int));
void notarget __P((void));
void open_score_file __P((void)); void open_score_file __P((void));
void parse __P((void)); void parse __P((void));
void post __P((char)); void post __P((char));
void printobjs __P((void)); void printobjs __P((void));
int put __P((void)); int put __P((void));
int puton __P((void)); int puton __P((void));
const char *rate __P((void));
void ravage __P((void)); void ravage __P((void));
void restore __P((const char *, size_t)); void restore __P((const char *));
int ride __P((void)); int ride __P((void));
void save __P((const char *, size_t)); void save __P((const char *));
void screen __P((void)); char *save_file_name __P((const char *, size_t));
int shoot __P((void)); int shoot __P((void));
void succumb __P((int));
int take __P((unsigned int[])); int take __P((unsigned int[]));
int takeoff __P((void)); int takeoff __P((void));
void target __P((void));
int throw __P((const char *)); int throw __P((const char *));
const char *truedirec __P((int, char));
int ucard __P((const unsigned int *)); int ucard __P((const unsigned int *));
int use __P((void)); int use __P((void));
int visual __P((void)); int visual __P((void));
int wearit __P((void)); int wearit __P((void));
void whichway __P((struct room)); void whichway __P((struct room));
int wizard __P((const char *));
void wordinit __P((void)); void wordinit __P((void));
void writedes __P((void)); void writedes __P((void));
int zzz __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 *));

View File

@@ -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 * Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)fly.c 8.2 (Berkeley) 4/28/95"; static char sccsid[] = "@(#)fly.c 8.2 (Berkeley) 4/28/95";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -46,20 +46,27 @@ __RCSID("$NetBSD: fly.c,v 1.6 1997/10/11 02:07:20 lukem Exp $");
#undef UP #undef UP
#include <curses.h> #include <curses.h>
#define abs(a) ((a) < 0 ? -(a) : (a))
#define MIDR (LINES/2 - 1) #define MIDR (LINES/2 - 1)
#define MIDC (COLS/2 - 1) #define MIDC (COLS/2 - 1)
int row, column; static int row, column;
int dr = 0, dc = 0; static int dr = 0, dc = 0;
char destroyed; static char destroyed;
int ourclock = 120; /* time for all the flights in the game */ int ourclock = 120; /* time for all the flights in the game */
char cross = 0; static char cross = 0;
sig_t oldsig; 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) succumb(dummy)
int dummy __attribute__((unused)); int dummy __attribute__((__unused__));
{ {
if (oldsig == SIG_DFL) { if (oldsig == SIG_DFL) {
endfly(); endfly();
@@ -80,7 +87,7 @@ visual()
return (0); return (0);
} }
oldsig = signal(SIGINT, succumb); oldsig = signal(SIGINT, succumb);
crmode(); cbreak();
noecho(); noecho();
screen(); screen();
row = rnd(LINES - 3) + 1; row = rnd(LINES - 3) + 1;
@@ -178,7 +185,7 @@ visual()
} }
} }
void static void
screen() screen()
{ {
int r, c, n; int r, c, n;
@@ -195,7 +202,7 @@ screen()
refresh(); refresh();
} }
void static void
target() target()
{ {
int n; int n;
@@ -208,7 +215,7 @@ target()
} }
} }
void static void
notarget() notarget()
{ {
int n; int n;
@@ -221,7 +228,7 @@ notarget()
} }
} }
void static void
blast() blast()
{ {
int n; int n;
@@ -243,9 +250,9 @@ blast()
alarm(1); alarm(1);
} }
void static void
moveenemy(dummy) moveenemy(dummy)
int dummy __attribute__((unused)); int dummy __attribute__((__unused__));
{ {
double d; double d;
int oldr, oldc; int oldr, oldc;
@@ -283,7 +290,7 @@ moveenemy(dummy)
alarm(1); alarm(1);
} }
void static void
endfly() endfly()
{ {
alarm(0); alarm(0);

View File

@@ -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 * Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)getcom.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)getcom.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -53,6 +53,8 @@ getcom(buf, size, prompt, error)
for (;;) { for (;;) {
fputs(prompt, stdout); fputs(prompt, stdout);
if (fgets(buf, size, stdin) == 0) { if (fgets(buf, size, stdin) == 0) {
if (feof(stdin))
die();
clearerr(stdin); clearerr(stdin);
continue; continue;
} }
@@ -63,6 +65,12 @@ getcom(buf, size, prompt, error)
if (error) if (error)
puts(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); return (buf);
} }
@@ -76,6 +84,9 @@ getword(buf1, buf2, flag)
char *buf1, *buf2; char *buf1, *buf2;
int flag; int flag;
{ {
int cnt;
cnt = 1;
while (isspace(*buf1)) while (isspace(*buf1))
buf1++; buf1++;
if (*buf1 != ',') { if (*buf1 != ',') {
@@ -83,24 +94,34 @@ getword(buf1, buf2, flag)
*buf2 = 0; *buf2 = 0;
return (0); return (0);
} }
while (*buf1 && !isspace(*buf1) && *buf1 != ',') while (cnt < WORDLEN && *buf1 && !isspace(*buf1) && *buf1 != ',')
if (flag < 0) if (flag < 0) {
if (isupper(*buf1)) if (isupper(*buf1)) {
*buf2++ = tolower(*buf1++); *buf2++ = tolower(*buf1++);
else cnt++;
} else {
*buf2++ = *buf1++; *buf2++ = *buf1++;
else cnt++;
if (flag > 0) }
if (islower(*buf1)) } else if (flag > 0) {
*buf2++ = toupper(*buf1++); if (islower(*buf1)) {
else *buf2++ = toupper(*buf1++);
*buf2++ = *buf1++; cnt++;
else } else {
*buf2++ = *buf1++; *buf2++ = *buf1++;
cnt++;
}
} else {
*buf2++ = *buf1++;
cnt++;
}
if (cnt == WORDLEN)
while (*buf1 && !isspace(*buf1))
buf1++;
} else } else
*buf2++ = *buf1++; *buf2++ = *buf1++;
*buf2 = 0; *buf2 = '\0';
while (isspace(*buf1)) while (isspace(*buf1))
buf1++; buf1++;
return (*buf1 ? buf1 : 0); return (*buf1 ? buf1 : NULL);
} }

View File

@@ -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 * Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)globals.c 8.2 (Berkeley) 4/28/95"; static char sccsid[] = "@(#)globals.c 8.2 (Berkeley) 4/28/95";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -48,11 +48,11 @@ int WEIGHT = MAXWEIGHT;
int CUMBER = MAXCUMBER; int CUMBER = MAXCUMBER;
const char *const objdes[NUMOFOBJECTS] = { const char *const objdes[NUMOFOBJECTS] = {
"There is a knife here", "There is a knife here.",
"There is an exquisitely crafted sword and scabbard here.", "There are an exquisitely crafted sword and scabbard here.",
0, /* can land from here */ NULL, /* Can land from here. */
"There is a fierce woodsman here brandishing a heavy mallet.", "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.", "There is a bloody meat cleaver here.",
"A rusty broadsword is lying here.", "A rusty broadsword is lying here.",
"There is an ancient coat of finely woven mail 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.", "There is a Viper ready for launch here.",
"A kerosene lantern is burning luridly here.", "A kerosene lantern is burning luridly here.",
"An old pair of shoes has been discarded here.", "An old pair of shoes has been discarded here.",
0, /* cylon */ NULL, /* Cylon. */
"There is a pair of pajamas here.", "There is a pair of pajamas here.",
"A kingly robe of royal purple and spun gold is draped here.", "A kingly robe of royal purple and spun gold is draped here.",
"There is a strange golden amulet on the floor 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.", "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.", "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.", "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 length of heavy chain here.",
"There is a stout rope here.", "There is a stout rope here.",
"There is a pair of Levi's here.", "There is a pair of Levi's here.",
"A bloody mace is lying on the ground here.", "A bloody mace is lying on the ground here.",
"There is a shovel here.", "There is a shovel here.",
"A long, sharp halberd is propped up 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.", "Wreckage and smoldering debris from a crash litter the ground here.",
"A woodland Elf armed with a shield and deadly halberd lunges toward you!", "A woodland Elf armed with a shield and deadly halberd lunges toward you!",
"I think I hear footsteps behind us.", "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.", "There is a colorful pink potion in a small crystal vial here.",
"A gold bracelet is on the ground 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.'", "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!'", "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!", "You are flying through an asteroid field!",
"A planet is nearby.", "A planet is nearby.",
"The ground is charred here.", "The ground is charred here.",
"There is a thermonuclear warhead here.", "There is a thermonuclear warhead here.",
"The fragile, beautiful young goddess lies here. You murdered her horribly.", "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.", "The native girl's body is lying here.",
"A native girl is sitting here.", "A native girl is sitting here.",
"A gorgeous white stallion is standing here.", "A gorgeous white stallion is standing here.",
@@ -118,7 +118,7 @@ const char *const objdes[NUMOFOBJECTS] = {
const char *const objsht[NUMOFOBJECTS] = { const char *const objsht[NUMOFOBJECTS] = {
"knife", "knife",
"fine sword", "fine sword",
0, NULL, /* Can land from here. */
"Woodsman", "Woodsman",
"two-handed sword", "two-handed sword",
"meat cleaver", "meat cleaver",
@@ -130,7 +130,7 @@ const char *const objsht[NUMOFOBJECTS] = {
"viper", "viper",
"lantern", "lantern",
"shoes", "shoes",
0, NULL, /* Cylon. */
"pajamas", "pajamas",
"robe", "robe",
"amulet", "amulet",
@@ -139,8 +139,8 @@ const char *const objsht[NUMOFOBJECTS] = {
"woodsman's body", "woodsman's body",
"wooden mallet", "wooden mallet",
"laser", "laser",
0, NULL, /* Bathing goddess. */
0, NULL, /* Goddess. */
"grenade", "grenade",
"chain", "chain",
"rope", "rope",
@@ -149,12 +149,12 @@ const char *const objsht[NUMOFOBJECTS] = {
"shovel", "shovel",
"halberd", "halberd",
"compass", "compass",
0, NULL, /* Crash debris. */
"Elf", "Elf",
0, NULL, /* Footsteps. */
"coins", "coins",
"match book", "match book",
0, NULL, /* Man and dwarf. */
"papayas", "papayas",
"pineapple", "pineapple",
"kiwi", "kiwi",
@@ -163,18 +163,18 @@ const char *const objsht[NUMOFOBJECTS] = {
"ring", "ring",
"potion", "potion",
"bracelet", "bracelet",
0, NULL, /* Swarthy woman. */
0, NULL, /* Swarthy woman (with message). */
"Dark Lord", "Dark Lord",
0, NULL, /* Old-timer. */
0, NULL, /* Asteroid field. */
0, NULL, /* Planet nearby. */
0, NULL, /* Charred ground. */
"warhead", "warhead",
"goddess's body", "goddess's body",
"old timer's body", "old-timer's body",
"girl's body", "girl's body",
0, NULL, /* Native girl. */
"stallion", "stallion",
"car", "car",
"pot of jewels", "pot of jewels",
@@ -220,7 +220,61 @@ const int objcumber[NUMOFOBJECTS] = {
10, 8, 8, 10, 10, 3, 1, 2 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 win = 1;
int matchcount = 20; int matchcount = 20;
int followgod = -1; int followgod = -1;
int followfight = -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;

View File

@@ -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 * Copyright (c) 1983, 1993
@@ -38,26 +38,31 @@
#if 0 #if 0
static char sccsid[] = "@(#)init.c 8.4 (Berkeley) 4/30/95"; static char sccsid[] = "@(#)init.c 8.4 (Berkeley) 4/30/95";
#else #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
#endif /* not lint */ #endif /* not lint */
#include "extern.h" #include "extern.h"
static int checkout __P((const char *));
static const char *getutmp __P((void));
static int wizard __P((const char *));
void void
initialize(startup) initialize(filename)
const char *startup; const char *filename;
{ {
const struct objs *p; const struct objs *p;
char *savefile;
puts("Version 4.2, fall 1984."); puts("Version 4.2, fall 1984.");
puts("First Adventure game written by His Lordship, the honorable"); puts("First Adventure game written by His Lordship, the honorable");
puts("Admiral D.W. Riggle\n"); puts("Admiral D.W. Riggle\n");
location = dayfile; location = dayfile;
srand(getpid()); srand(getpid());
getutmp(username); username = getutmp();
wordinit(); wordinit();
if (startup == NULL) { if (filename == NULL) {
direction = NORTH; direction = NORTH;
ourtime = 0; ourtime = 0;
snooze = CYCLE * 1.5; snooze = CYCLE * 1.5;
@@ -67,23 +72,29 @@ initialize(startup)
torps = TORPEDOES; torps = TORPEDOES;
for (p = dayobjs; p->room != 0; p++) for (p = dayobjs; p->room != 0; p++)
setbit(location[p->room].objects, p->obj); setbit(location[p->room].objects, p->obj);
} else } else {
restore(startup, strlen(startup)); savefile = save_file_name(filename, strlen(filename));
restore(savefile);
free(savefile);
}
wiz = wizard(username); wiz = wizard(username);
signal(SIGINT, diesig); signal(SIGINT, diesig);
} }
void static const char *
getutmp(uname) getutmp()
char *uname;
{ {
struct passwd *ptr; struct passwd *ptr;
ptr = getpwuid(getuid()); 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", "riggle",
"chris", "chris",
"edward", "edward",
@@ -94,14 +105,14 @@ const char *const list[] = { /* hereditary wizards */
0 0
}; };
const char *const badguys[] = { static const char *const badguys[] = {
"wnj", "wnj",
"root", "root",
"ted", "ted",
0 0
}; };
int static int
wizard(uname) wizard(uname)
const char *uname; const char *uname;
{ {
@@ -112,7 +123,7 @@ wizard(uname)
return flag; return flag;
} }
int static int
checkout(uname) checkout(uname)
const char *uname; const char *uname;
{ {

View File

@@ -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 * Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)misc.c 8.2 (Berkeley) 4/28/95"; static char sccsid[] = "@(#)misc.c 8.2 (Berkeley) 4/28/95";
#else #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
#endif /* not lint */ #endif /* not lint */

File diff suppressed because it is too large Load Diff

View File

@@ -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 * Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)nightobjs.c 8.2 (Berkeley) 4/28/95"; static char sccsid[] = "@(#)nightobjs.c 8.2 (Berkeley) 4/28/95";
#else #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
#endif /* not lint */ #endif /* not lint */

View File

@@ -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 * Copyright (c) 1983, 1993
@@ -38,12 +38,22 @@
#if 0 #if 0
static char sccsid[] = "@(#)parse.c 8.2 (Berkeley) 4/28/95"; static char sccsid[] = "@(#)parse.c 8.2 (Berkeley) 4/28/95";
#else #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
#endif /* not lint */ #endif /* not lint */
#include "extern.h" #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 void
wordinit() wordinit()
{ {
@@ -53,7 +63,7 @@ wordinit()
install(w); install(w);
} }
int static int
hash(s) hash(s)
const char *s; const char *s;
{ {
@@ -67,7 +77,7 @@ hash(s)
return hashval; return hashval;
} }
struct wlist * static struct wlist *
lookup(s) lookup(s)
const char *s; const char *s;
{ {
@@ -79,7 +89,7 @@ lookup(s)
return NULL; return NULL;
} }
void static void
install(wp) install(wp)
struct wlist *wp; struct wlist *wp;
{ {
@@ -98,6 +108,7 @@ parse()
{ {
struct wlist *wp; struct wlist *wp;
int n; int n;
int flag;
wordnumber = 0; /* for cypher */ wordnumber = 0; /* for cypher */
for (n = 0; n <= wordcount; n++) { for (n = 0; n <= wordcount; n++) {
@@ -109,4 +120,72 @@ parse()
wordtype[n] = wp->article; 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;
}
}
} }

View File

@@ -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 * Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)room.c 8.2 (Berkeley) 4/28/95"; static char sccsid[] = "@(#)room.c 8.2 (Berkeley) 4/28/95";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -52,12 +52,15 @@ writedes()
int c; int c;
printf("\n\t%s\n", location[position].name); printf("\n\t%s\n", location[position].name);
if (beenthere[position] < 3) { if (beenthere[position] < ROOMDESC || verbose) {
compass = NORTH; compass = NORTH;
for (p = location[position].desc; (c = *p++) != 0;) for (p = location[position].desc; (c = *p++) != 0;)
if (c != '-' && c != '*' && c != '+') if (c != '-' && c != '*' && c != '+') {
putchar(c); if (c == '=')
else { putchar('-');
else
putchar(c);
} else {
if (c != '*') if (c != '*')
printf(truedirec(compass, c)); printf(truedirec(compass, c));
compass++; compass++;

View File

@@ -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 * Copyright (c) 1983, 1993
@@ -38,51 +38,24 @@
#if 0 #if 0
static char sccsid[] = "@(#)save.c 8.2 (Berkeley) 4/28/95"; static char sccsid[] = "@(#)save.c 8.2 (Berkeley) 4/28/95";
#else #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
#endif /* not lint */ #endif /* not lint */
#include "extern.h" #include "extern.h"
void void
restore(filename, len) restore(filename)
const char *filename; const char *filename;
size_t len;
{ {
char *home;
char *home1;
int n; int n;
int tmp; int tmp;
size_t tmpl;
FILE *fp; FILE *fp;
if (memchr(filename, '/', len)) { if (filename == NULL)
home1 = malloc(len + 1); exit(1); /* Error determining save file name. */
if (home1 == NULL) if ((fp = fopen(filename, "r")) == 0) {
errx(1, "out of memory"); err(1, "fopen %s", filename);
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);
} }
fread(&WEIGHT, sizeof WEIGHT, 1, fp); fread(&WEIGHT, sizeof WEIGHT, 1, fp);
fread(&CUMBER, sizeof CUMBER, 1, fp); fread(&CUMBER, sizeof CUMBER, 1, fp);
@@ -120,54 +93,25 @@ restore(filename, len)
fread(&power, sizeof power, 1, fp); fread(&power, sizeof power, 1, fp);
/* We must check the last read, to catch truncated save files */ /* We must check the last read, to catch truncated save files */
if (fread(&ego, sizeof ego, 1, fp) < 1) 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); fclose(fp);
free(home1);
} }
void void
save(filename, len) save(filename)
const char *filename; const char *filename;
size_t len;
{ {
char *home;
char *home1;
int n; int n;
int tmp; int tmp;
size_t tmpl;
FILE *fp; FILE *fp;
if (memchr(filename, '/', len)) { if (filename == NULL)
home1 = malloc(len + 1); return; /* Error determining save file name. */
if (home1 == NULL) if ((fp = fopen(filename, "w")) == NULL) {
errx(1, "out of memory"); warn("fopen %s", filename);
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);
return; return;
} }
printf("Saved in %s.\n", home1); printf("Saved in %s.\n", filename);
fwrite(&WEIGHT, sizeof WEIGHT, 1, fp); fwrite(&WEIGHT, sizeof WEIGHT, 1, fp);
fwrite(&CUMBER, sizeof CUMBER, 1, fp); fwrite(&CUMBER, sizeof CUMBER, 1, fp);
fwrite(&ourclock, sizeof ourclock, 1, fp); fwrite(&ourclock, sizeof ourclock, 1, fp);
@@ -205,7 +149,55 @@ save(filename, len)
fwrite(&ego, sizeof ego, 1, fp); fwrite(&ego, sizeof ego, 1, fp);
fflush(fp); fflush(fp);
if (ferror(fp)) if (ferror(fp))
warn("fwrite %s", home1); warn("fwrite %s", filename);
fclose(fp); 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;
} }

View File

@@ -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 * Copyright (c) 1983, 1993
@@ -38,176 +38,183 @@
#if 0 #if 0
static char sccsid[] = "@(#)words.c 8.2 (Berkeley) 4/28/95"; static char sccsid[] = "@(#)words.c 8.2 (Berkeley) 4/28/95";
#else #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
#endif /* not lint */ #endif /* not lint */
#include "extern.h" #include "extern.h"
struct wlist wlist[] = { struct wlist wlist[] = {
{"knife", KNIFE, OBJECT}, { "knife", KNIFE, OBJECT, NULL },
{"sword", SWORD, NOUNS}, { "sword", SWORD, NOUNS, NULL },
{"scabbard", SWORD, OBJECT}, { "scabbard", SWORD, OBJECT, NULL },
{"fine", SWORD, OBJECT}, { "fine", SWORD, OBJECT, NULL },
{"two-handed", TWO_HANDED, OBJECT}, { "two-handed", TWO_HANDED, OBJECT, NULL },
{"cleaver", CLEAVER, OBJECT}, { "cleaver", CLEAVER, OBJECT, NULL },
{"broadsword", BROAD, OBJECT}, { "broadsword", BROAD, OBJECT, NULL },
{"mail", MAIL, OBJECT}, { "mail", MAIL, OBJECT, NULL },
{"coat", MAIL, OBJECT}, { "coat", MAIL, OBJECT, NULL },
{"helmet", HELM, OBJECT}, { "helmet", HELM, OBJECT, NULL },
{"shield", SHIELD, OBJECT}, { "shield", SHIELD, OBJECT, NULL },
{"maid", MAID, OBJECT}, { "maid", MAID, OBJECT, NULL },
{"maid's", MAID, OBJECT}, { "maid's", MAID, OBJECT, NULL },
{"body", BODY, NOUNS}, { "body", BODY, NOUNS, NULL },
{"viper", VIPER, OBJECT}, { "viper", VIPER, OBJECT, NULL },
{"lamp", LAMPON, OBJECT}, { "lamp", LAMPON, OBJECT, NULL },
{"lantern", LAMPON, OBJECT}, { "lantern", LAMPON, OBJECT, NULL },
{"shoes", SHOES, OBJECT}, { "shoes", SHOES, OBJECT, NULL },
{"pajamas", PAJAMAS, OBJECT}, { "pajamas", PAJAMAS, OBJECT, NULL },
{"robe", ROBE, OBJECT}, { "robe", ROBE, OBJECT, NULL },
{"amulet", AMULET, NOUNS}, { "amulet", AMULET, NOUNS, NULL },
{"medallion", MEDALION, NOUNS}, { "medallion", MEDALION, NOUNS, NULL },
{"talisman", TALISMAN, NOUNS}, { "talisman", TALISMAN, NOUNS, NULL },
{"woodsman", DEADWOOD, OBJECT}, { "woodsman", DEADWOOD, OBJECT, NULL },
{"woodsman's", DEADWOOD, OBJECT}, { "woodsman's", DEADWOOD, OBJECT, NULL },
{"mallet", MALLET, OBJECT}, { "mallet", MALLET, OBJECT, NULL },
{"laser", LASER, OBJECT}, { "laser", LASER, OBJECT, NULL },
{"pistol", LASER, OBJECT}, { "pistol", LASER, OBJECT, NULL },
{"blaster", LASER, OBJECT}, { "blaster", LASER, OBJECT, NULL },
{"gun", LASER, OBJECT}, { "gun", LASER, OBJECT, NULL },
{"goddess", NORMGOD, NOUNS}, { "goddess", NORMGOD, NOUNS, NULL },
{"grenade", GRENADE, OBJECT}, { "grenade", GRENADE, OBJECT, NULL },
{"chain", CHAIN, OBJECT}, { "chain", CHAIN, OBJECT, NULL },
{"rope", ROPE, OBJECT}, { "rope", ROPE, OBJECT, NULL },
{"levis", LEVIS, OBJECT}, { "levis", LEVIS, OBJECT, NULL },
{"pants", LEVIS, OBJECT}, { "pants", LEVIS, OBJECT, NULL },
{"mace", MACE, OBJECT}, { "mace", MACE, OBJECT, NULL },
{"shovel", SHOVEL, OBJECT}, { "shovel", SHOVEL, OBJECT, NULL },
{"halberd", HALBERD, OBJECT}, { "halberd", HALBERD, OBJECT, NULL },
{"compass", COMPASS, OBJECT}, { "compass", COMPASS, OBJECT, NULL },
{"elf", ELF, OBJECT}, { "elf", ELF, OBJECT, NULL },
{"coins", COINS, OBJECT}, { "coins", COINS, OBJECT, NULL },
{"matches", MATCHES, OBJECT}, { "matches", MATCHES, OBJECT, NULL },
{"match", MATCHES, OBJECT}, { "match", MATCHES, OBJECT, NULL },
{"book", MATCHES, OBJECT}, { "book", MATCHES, OBJECT, NULL },
{"man", MAN, NOUNS}, { "man", MAN, NOUNS, NULL },
{"papayas", PAPAYAS, OBJECT}, { "papaya", PAPAYAS, OBJECT, NULL },
{"pineapple", PINEAPPLE, OBJECT}, { "papayas", PAPAYAS, OBJECT, NULL },
{"kiwi", KIWI, OBJECT}, { "pineapple", PINEAPPLE, OBJECT, NULL },
{"coconuts", COCONUTS, OBJECT}, { "kiwi", KIWI, OBJECT, NULL },
{"mango", MANGO, OBJECT}, { "coconut", COCONUTS, OBJECT, NULL },
{"ring", RING, OBJECT}, { "coconuts", COCONUTS, OBJECT, NULL },
{"potion", POTION, OBJECT}, { "mango", MANGO, OBJECT, NULL },
{"bracelet", BRACELET, OBJECT}, { "ring", RING, OBJECT, NULL },
{"timer", TIMER, NOUNS}, { "potion", POTION, OBJECT, NULL },
{"bomb", BOMB, OBJECT}, { "bracelet", BRACELET, OBJECT, NULL },
{"warhead", BOMB, OBJECT}, { "timer", TIMER, NOUNS, NULL },
{"girl", NATIVE, NOUNS}, { "bomb", BOMB, OBJECT, NULL },
{"native", NATIVE, NOUNS}, { "warhead", BOMB, OBJECT, NULL },
{"horse", HORSE, OBJECT}, { "girl", NATIVE, NOUNS, NULL },
{"stallion", HORSE, OBJECT}, { "native", NATIVE, NOUNS, NULL },
{"car", CAR, OBJECT}, { "horse", HORSE, OBJECT, NULL },
{"volare", CAR, OBJECT}, { "stallion", HORSE, OBJECT, NULL },
{"pot", POT, OBJECT}, { "car", CAR, OBJECT, NULL },
{"jewels", POT, OBJECT}, { "volare", CAR, OBJECT, NULL },
{"bar", BAR, OBJECT}, { "pot", POT, OBJECT, NULL },
{"diamond", BLOCK, OBJECT}, { "jewels", POT, OBJECT, NULL },
{"block", BLOCK, OBJECT}, { "bar", BAR, OBJECT, NULL },
{"up", UP, VERB}, { "diamond", BLOCK, OBJECT, NULL },
{"u", UP, VERB}, { "block", BLOCK, OBJECT, NULL },
{"down", DOWN, VERB}, { "up", UP, VERB, NULL },
{"d", DOWN, VERB}, { "u", UP, VERB, NULL },
{"ahead", AHEAD, VERB}, { "down", DOWN, VERB, NULL },
{"a", AHEAD, VERB}, { "d", DOWN, VERB, NULL },
{"back", BACK, VERB}, { "ahead", AHEAD, VERB, NULL },
{"b", BACK, VERB}, { "a", AHEAD, VERB, NULL },
{"right", RIGHT, VERB}, { "back", BACK, VERB, NULL },
{"r", RIGHT, VERB}, { "b", BACK, VERB, NULL },
{"left", LEFT, VERB}, { "right", RIGHT, VERB, NULL },
{"l", LEFT, VERB}, { "r", RIGHT, VERB, NULL },
{"take", TAKE, VERB}, { "left", LEFT, VERB, NULL },
{"get", TAKE, VERB}, { "l", LEFT, VERB, NULL },
{"use", USE, VERB}, { "take", TAKE, VERB, NULL },
{"look", LOOK, VERB}, { "get", TAKE, VERB, NULL },
{"lo", LOOK, VERB}, { "use", USE, VERB, NULL },
{"quit", QUIT, VERB}, { "look", LOOK, VERB, NULL },
{"q", QUIT, VERB}, { "lo", LOOK, VERB, NULL },
{"su", SU, VERB}, { "quit", QUIT, VERB, NULL },
{"drop", DROP, VERB}, { "q", QUIT, VERB, NULL },
{"draw", DRAW, VERB}, { "su", SU, VERB, NULL },
{"pull", DRAW, VERB}, { "drop", DROP, VERB, NULL },
{"carry", DRAW, VERB}, { "draw", DRAW, VERB, NULL },
{"wear", WEARIT, VERB}, { "pull", DRAW, VERB, NULL },
{"sheathe", WEARIT, VERB}, { "carry", DRAW, VERB, NULL },
{"put", PUT, VERB}, { "wear", WEARIT, VERB, NULL },
{"buckle", PUT, VERB}, { "sheathe", WEARIT, VERB, NULL },
{"strap", PUT, VERB}, { "put", PUT, VERB, NULL },
{"tie", PUT, VERB}, { "buckle", PUT, VERB, NULL },
{"inven", INVEN, VERB}, { "strap", PUT, VERB, NULL },
{"i", INVEN, VERB}, { "tie", PUT, VERB, NULL },
{"everything", EVERYTHING, OBJECT}, { "inven", INVEN, VERB, NULL },
{"all", EVERYTHING, OBJECT}, { "i", INVEN, VERB, NULL },
{"and", AND, CONJ}, { "everything", EVERYTHING, OBJECT, NULL },
{"kill", KILL, VERB}, { "all", EVERYTHING, OBJECT, NULL },
{"fight", KILL, VERB}, { "and", AND, CONJ, NULL },
{"ravage", RAVAGE, VERB}, { ",", AND, CONJ, NULL },
{"rape", RAVAGE, VERB}, { "kill", KILL, VERB, NULL },
{"undress", UNDRESS, VERB}, { "fight", KILL, VERB, NULL },
{"throw", THROW, VERB}, { "ravage", RAVAGE, VERB, NULL },
{"launch", LAUNCH, VERB}, { "rape", RAVAGE, VERB, NULL },
{"land", LANDIT, VERB}, { "undress", UNDRESS, VERB, NULL },
{"light", LIGHT, VERB}, { "throw", THROW, VERB, NULL },
{"strike", LIGHT, VERB}, { "launch", LAUNCH, VERB, NULL },
{"follow", FOLLOW, VERB}, { "land", LANDIT, VERB, NULL },
{"chase", FOLLOW, VERB}, { "light", LIGHT, VERB, NULL },
{"kiss", KISS, VERB}, { "strike", LIGHT, VERB, NULL },
{"love", LOVE, VERB}, { "follow", FOLLOW, VERB, NULL },
{"fuck", LOVE, VERB}, { "chase", FOLLOW, VERB, NULL },
{"give", GIVE, VERB}, { "kiss", KISS, VERB, NULL },
{"smite", SMITE, VERB}, { "love", LOVE, VERB, NULL },
{"attack", SMITE, VERB}, { "fuck", LOVE, VERB, NULL },
{"swing", SMITE, VERB}, { "give", GIVE, VERB, NULL },
{"stab", SMITE, VERB}, { "smite", SMITE, VERB, NULL },
{"slice", SMITE, VERB}, { "attack", SMITE, VERB, NULL },
{"cut", SMITE, VERB}, { "swing", SMITE, VERB, NULL },
{"hack", SMITE, VERB}, { "stab", SMITE, VERB, NULL },
{"shoot", SHOOT, VERB}, { "slice", SMITE, VERB, NULL },
{"blast", SHOOT, VERB}, { "cut", SMITE, VERB, NULL },
{"on", ON, PREPS}, { "hack", SMITE, VERB, NULL },
{"off", OFF, PREPS}, { "shoot", SHOOT, VERB, NULL },
{"time", TIME, VERB}, { "blast", SHOOT, VERB, NULL },
{"sleep", SLEEP, VERB}, { "open", OPEN, VERB, NULL },
{"dig", DIG, VERB}, { "unlock", OPEN, VERB, NULL },
{"eat", EAT, VERB}, { "on", ON, PREPS, NULL },
{"swim", SWIM, VERB}, { "off", OFF, PREPS, NULL },
{"drink", DRINK, VERB}, { "time", TIME, VERB, NULL },
{"door", DOOR, NOUNS}, { "sleep", SLEEP, VERB, NULL },
{"save", SAVE, VERB}, { "dig", DIG, VERB, NULL },
{"ride", RIDE, VERB}, { "eat", EAT, VERB, NULL },
{"mount", RIDE, VERB}, { "swim", SWIM, VERB, NULL },
{"drive", DRIVE, VERB}, { "drink", DRINK, VERB, NULL },
{"start", DRIVE, VERB}, { "door", DOOR, NOUNS, NULL },
{"score", SCORE, VERB}, { "verbose", VERBOSE, VERB, NULL },
{"points", SCORE, VERB}, { "brief", BRIEF, VERB, NULL },
{"bury", BURY, VERB}, { "save", SAVE, VERB, NULL },
{"jump", JUMP, VERB}, { "ride", RIDE, VERB, NULL },
{"kick", KICK, VERB}, { "mount", RIDE, VERB, NULL },
{"kerosene", 0, ADJS}, { "drive", DRIVE, VERB, NULL },
{"plumed", 0, ADJS}, { "start", DRIVE, VERB, NULL },
{"ancient", 0, ADJS}, { "score", SCORE, VERB, NULL },
{"golden", 0, ADJS}, { "points", SCORE, VERB, NULL },
{"gold", 0, ADJS}, { "bury", BURY, VERB, NULL },
{"ostrich", 0, ADJS}, { "jump", JUMP, VERB, NULL },
{"rusty", 0, ADJS}, { "kick", KICK, VERB, NULL },
{"old", 0, ADJS}, { "kerosene", 0, ADJS, NULL },
{"dented", 0, ADJS}, { "plumed", 0, ADJS, NULL },
{"blue", 0, ADJS}, { "ancient", 0, ADJS, NULL },
{"purple", 0, ADJS}, { "golden", 0, ADJS, NULL },
{"kingly", 0, ADJS}, { "gold", 0, ADJS, NULL },
{"the", 0, ADJS}, { "ostrich", 0, ADJS, NULL },
{"climb", 0, ADJS}, { "rusty", 0, ADJS, NULL },
{"move", 0, ADJS}, { "old", 0, ADJS, NULL },
{"make", 0, ADJS}, { "dented", 0, ADJS, NULL },
{"to", 0, ADJS}, { "blue", 0, ADJS, NULL },
{0} { "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 }
}; };

View File

@@ -1,4 +1,30 @@
# Makefrag - makefile fragment for bcd # 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) bcd_DIRS := $(GAMESDIR) $(MAN6DIR)
@@ -8,6 +34,3 @@ bcd_install: bcd_all
$(INSTALL_BINARY) bcd/bcd $(INSTALL_PREFIX)$(GAMESDIR)/bcd $(INSTALL_BINARY) bcd/bcd $(INSTALL_PREFIX)$(GAMESDIR)/bcd
$(HIDE_GAME) bcd $(HIDE_GAME) bcd
$(INSTALL_MANUAL) bcd/bcd.6 $(INSTALL_MANUAL) bcd/bcd.6
bcd_check: bcd_all
date | bcd/bcd

View File

@@ -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 * Copyright (c) 1989, 1993
@@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
#if 0 #if 0
static char sccsid[] = "@(#)bcd.c 8.2 (Berkeley) 3/20/94"; static char sccsid[] = "@(#)bcd.c 8.2 (Berkeley) 3/20/94";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -83,6 +83,7 @@ __RCSID("$NetBSD: bcd.c,v 1.7 1997/10/10 09:54:18 lukem Exp $");
#include <sys/types.h> #include <sys/types.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <unistd.h> #include <unistd.h>
@@ -128,7 +129,7 @@ const u_short holes[256] = {
#define bit(w,i) ((w)&(1<<(i))) #define bit(w,i) ((w)&(1<<(i)))
int main __P((int, char *[])); int main __P((int, char *[]));
void printcard __P((char *)); void printcard __P((unsigned char *));
int int
main(argc, argv) main(argc, argv)
@@ -147,10 +148,10 @@ main(argc, argv)
if (argc > 1) { if (argc > 1) {
while (--argc) while (--argc)
printcard(*++argv); printcard((unsigned char *)*++argv);
} else } else
while (fgets(cardline, sizeof(cardline), stdin)) while (fgets(cardline, sizeof(cardline), stdin))
printcard(cardline); printcard((unsigned char *)cardline);
exit(0); exit(0);
} }
@@ -158,17 +159,17 @@ main(argc, argv)
void void
printcard(str) printcard(str)
char *str; unsigned char *str;
{ {
static const char rowchars[] = " 123456789"; static const char rowchars[] = " 123456789";
int i, row; int i, row;
unsigned char *p; unsigned char *p;
/* ruthlessly remove newlines and truncate at 48 characters. */ /* ruthlessly remove newlines and truncate at 48 characters. */
if ((p = strchr(str, '\n'))) if ((p = (unsigned char *)strchr((char *)str, '\n')))
*p = '\0'; *p = '\0';
if (strlen(str) > COLUMNS) if (strlen((char *)str) > COLUMNS)
str[COLUMNS] = '\0'; str[COLUMNS] = '\0';
/* make string upper case. */ /* make string upper case. */

View File

@@ -1,18 +1,23 @@
# $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 # @(#)Makefile 8.1 (Berkeley) 6/11/93
.include <bsd.own.mk>
SUBDIR= boggle mkdict mkindex SUBDIR= boggle mkdict mkindex
MKDICT!=cd $(.CURDIR)/mkdict; \ MKDICTDIR!= cd $(.CURDIR)/mkdict; ${PRINTOBJDIR}
printf "xxx: .MAKE\n\t@echo \$${.OBJDIR}/mkdict\n" | ${MAKE} -s -f- MKDICT=${MKDICTDIR}/mkdict
MKINDEX!=cd $(.CURDIR)/mkindex; \ MKINDEXDIR!= cd $(.CURDIR)/mkindex; ${PRINTOBJDIR}
printf "xxx: .MAKE\n\t@echo \$${.OBJDIR}/mkindex\n" | ${MAKE} -s -f- MKINDEX=${MKINDEXDIR}/mkindex
WORDS=${.CURDIR}/../../share/dict/web2 WORDS=${NETBSDSRCDIR}/share/dict/web2
FILES=dictionary dictindex DICTFILES=dictionary dictindex
.if ${MKSHARE} != "no"
FILES=${DICTFILES}
FILESDIR=/usr/share/games/boggle FILESDIR=/usr/share/games/boggle
CLEANFILES+=${FILES} .endif
CLEANFILES+=${DICTFILES}
all: ${FILES} realall: ${FILES}
${MKDICT}: ${MKDICT}:
@cd ${.CURDIR}/mkdict && ${MAKE} @cd ${.CURDIR}/mkdict && ${MAKE}
@@ -20,7 +25,6 @@ ${MKDICT}:
${MKINDEX}: ${MKINDEX}:
@cd ${.CURDIR}/mkindex && ${MAKE} @cd ${.CURDIR}/mkindex && ${MAKE}
dictionary: ${WORDS} ${MKDICT} dictionary: ${WORDS} ${MKDICT}
rm -f ${.TARGET} rm -f ${.TARGET}
${MKDICT} < ${WORDS} > ${.TARGET} ${MKDICT} < ${WORDS} > ${.TARGET}

View File

@@ -1,4 +1,30 @@
# Makefrag - makefile fragment for boggle # 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: boggle_all:

View File

@@ -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 # @(#)Makefile 8.1 (Berkeley) 6/11/93
PROG= mkdict NOMAN= # defined
HOST_CPPFLAGS+=-I${.CURDIR}/../boggle
NOMAN= noman
# XXX for "make depend" HOSTPROG= mkdict
CPPFLAGS+=-I${.CURDIR}/../boggle HOST_CPPFLAGS+= -I${.CURDIR}/../boggle
# only needed during build .include <bsd.hostprog.mk>
proginstall::
# Override these rules for cross-compilation
.c.o:
${HOST_COMPILE.c} ${.IMPSRC}
${PROG}: ${OBJS}
${HOST_LINK.c} -o ${.TARGET} ${OBJS}
.include <bsd.prog.mk>

View File

@@ -1,10 +1,36 @@
# Makefrag - makefile fragment for boggle/mkdict # 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_CLEANFILES := dictionary
# boggle_mkdict_DICTSRC is the dictionary that will be used to construct the # boggle_mkdict_DICTSRC is the dictionary that will be used to construct the
# word list used by boggle. # word list used by boggle.
boggle_mkdict_DICTSRC := hangman/words boggle_mkdict_DICTSRC := $(DICTIONARY_SRC)
boggle_mkdict_DIRS := $(BOGGLE_DIR) boggle_mkdict_DIRS := $(BOGGLE_DIR)
boggle_mkdict_INCS := -Iboggle/boggle boggle_mkdict_INCS := -Iboggle/boggle

View File

@@ -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 * Copyright (c) 1993
@@ -36,17 +36,15 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <sys/cdefs.h>
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1993\n\
The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef 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 #if 0
static char sccsid[] = "@(#)mkdict.c 8.1 (Berkeley) 6/11/93"; static char sccsid[] = "@(#)mkdict.c 8.1 (Berkeley) 6/11/93";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -62,11 +60,10 @@ __RCSID("$NetBSD: mkdict.c,v 1.3 1997/10/11 02:12:21 lukem Exp $");
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <err.h>
#include "bog.h" #include "bog.h"
int main __P((int, char *[])); int main(int, char *[]);
int int
main(argc, argv) main(argc, argv)
@@ -85,7 +82,7 @@ main(argc, argv)
for (nwords = 1; for (nwords = 1;
fgets(buf[current], MAXWORDLEN + 1, stdin) != NULL; ++nwords) { fgets(buf[current], MAXWORDLEN + 1, stdin) != NULL; ++nwords) {
if ((p = strchr(buf[current], '\n')) == NULL) { 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') while ((ch = getc(stdin)) != EOF && ch != '\n')
; ;
if (ch == EOF) if (ch == EOF)
@@ -125,6 +122,11 @@ main(argc, argv)
prev = !prev; prev = !prev;
current = !current; 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); exit(0);
} }

View File

@@ -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 # @(#)Makefile 8.1 (Berkeley) 6/11/93
PROG= mkindex NOMAN= # defined
HOST_CPPFLAGS+=-I${.CURDIR}/../boggle
NOMAN= noman
# XXX for "make depend" HOSTPROG= mkindex
CPPFLAGS+=-I${.CURDIR}/../boggle HOST_CPPFLAGS+= -I${.CURDIR}/../boggle
# only needed during build .include <bsd.hostprog.mk>
proginstall::
# Override these rules for cross-compilation
.c.o:
${HOST_COMPILE.c} ${.IMPSRC}
${PROG}: ${OBJS}
${HOST_LINK.c} -o ${.TARGET} ${OBJS}
.include <bsd.prog.mk>

View File

@@ -1,4 +1,30 @@
# Makefrag - makefile fragment for boggle/mkindex # 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_CLEANFILES := dictindex
boggle_mkindex_DIRS := $(BOGGLE_DIR) boggle_mkindex_DIRS := $(BOGGLE_DIR)

View File

@@ -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 * Copyright (c) 1993
@@ -36,17 +36,15 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <sys/cdefs.h>
#ifndef lint #ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1993\n\ static const char copyright[] __attribute__((__unused__)) = "@(#) Copyright (c) 1993\n\
The Regents of the University of California. All rights reserved.\n"); The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
#if 0 #if 0
static char sccsid[] = "@(#)mkindex.c 8.1 (Berkeley) 6/11/93"; static char sccsid[] = "@(#)mkindex.c 8.1 (Berkeley) 6/11/93";
#else #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
#endif /* not lint */ #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" #include "bog.h"
int main __P((void)); int main(void);
char *nextword __P((FILE *, char *, int *, int *)); char *nextword(FILE *, char *, int *, int *);
int int
main(void) main(void)
{ {
int clen, rlen, prev; int clen, rlen, prev, i;
long off, start; long off, start;
char buf[MAXWORDLEN + 1]; char buf[MAXWORDLEN + 1];
@@ -69,14 +67,29 @@ main(void)
off = start = 0L; off = start = 0L;
while (nextword(stdin, buf, &clen, &rlen) != NULL) { while (nextword(stdin, buf, &clen, &rlen) != NULL) {
if (*buf != prev) { 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') if (prev != '\0')
printf("%c %6ld %6ld\n", prev, start, off - 1); 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; prev = *buf;
start = off; start = off;
} }
off += clen + 1; off += clen + 1;
} }
printf("%c %6ld %6ld\n", prev, start, off - 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); exit(0);
} }

View File

@@ -1,4 +1,30 @@
# Makefrag - makefile fragment for caesar # 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) caesar_DIRS := $(GAMESDIR) $(MAN6DIR)
@@ -11,6 +37,3 @@ caesar_install: caesar_all
$(HIDE_GAME) rot13 $(HIDE_GAME) rot13
$(INSTALL_MANUAL) caesar/caesar.6 $(INSTALL_MANUAL) caesar/caesar.6
$(INSTALL_MANUAL) caesar.6 rot13.6 $(INSTALL_MANUAL) caesar.6 rot13.6
#caesar_check: caesar_all
# caesar/caesar <fortune/datfiles/fortunes-o.fake.rot13

View File

@@ -1,4 +1,4 @@
.\" $NetBSD: caesar.6,v 1.6 1997/11/12 00:48:29 mrg Exp $ .\" $NetBSD: caesar.6,v 1.8 2002/09/26 18:31:59 wiz Exp $
.\" .\"
.\" Copyright (c) 1989, 1991, 1993 .\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@@ -39,14 +39,14 @@
.Sh NAME .Sh NAME
.Nm caesar , .Nm caesar ,
.Nm rot13 .Nm rot13
.Nd decrypt caesar cyphers .Nd decrypt caesar ciphers
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Ar rotation .Op Ar rotation
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Nm .Nm
utility attempts to decrypt caesar cyphers using English letter frequency utility attempts to decrypt caesar ciphers using English letter frequency
statistics. statistics.
.Nm .Nm
reads from the standard input and writes to the standard output. reads from the standard input and writes to the standard output.
@@ -66,8 +66,7 @@ Their frequencies as a percentage are as follows:
.Bd -filled -offset indent .Bd -filled -offset indent
E(13), T(10.5), A(8.1), O(7.9), N(7.1), R(6.8), I(6.3), S(6.1), H(5.2), E(13), T(10.5), A(8.1), O(7.9), N(7.1), R(6.8), I(6.3), S(6.1), H(5.2),
D(3.8), L(3.4), F(2.9), C(2.7), M(2.5), U(2.4), G(2), D(3.8), L(3.4), F(2.9), C(2.7), M(2.5), U(2.4), G(2),
P(1.9), Y(1.9), P(1.9), Y(1.9), W(1.5), B(1.4), V(.9), K(.4), X(.15), J(.13), Q(.11), Z(.07).
W(1.5), B(1.4), V(.9), K(.4), X(.15), J(.13), Q(.11), Z(.07).
.Ed .Ed
.Pp .Pp
Rotated postings to Rotated postings to

View File

@@ -1,4 +1,4 @@
# $NetBSD: rot13.sh,v 1.2 1995/03/21 15:08:23 cgd Exp $ # $NetBSD: rot13.sh,v 1.6 2000/04/24 15:42:40 simonb Exp $
# #
# Copyright (c) 1992, 1993 # Copyright (c) 1992, 1993
# The Regents of the University of California. All rights reserved. # The Regents of the University of California. All rights reserved.

View File

@@ -1,4 +1,30 @@
# Makefrag - makefile fragment for canfield # Makefrag - makefile fragment for canfield
#
# 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.
canfield_all: canfield_all:

View File

@@ -1,9 +1,7 @@
# $NetBSD: Makefile,v 1.2 1997/10/03 10:25:35 mrg Exp $ # $NetBSD: Makefile,v 1.3 1999/02/13 23:53:57 lukem Exp $
NOPROG= yes SCRIPTS= countmail
FILES= countmail SCRIPTSDIR= /usr/games
FILESDIR= /usr/games MAN= countmail.6
FILESMODE= 555
MAN= countmail.6
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@@ -1,4 +1,30 @@
# Makefrag - makefile fragment for countmail # 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) countmail_DIRS := $(GAMESDIR) $(MAN6DIR)

View File

@@ -1,8 +1,8 @@
#!/bin/sh #!/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. # All rights reserved.
# #
# This code is derived from software contributed to The NetBSD Foundation # This code is derived from software contributed to The NetBSD Foundation
@@ -61,125 +61,103 @@ v=$1
#done #done
#exec 0<&- #exec 0<&-
result= set --
g=0 g=0
v=000$v
while :; do while :; do
case $v in case $v in
0 | '') break ;; '' | 0 | 00) break ;;
?) v=00$v ;;
??) v=0$v ;;
esac
case $v in
*000) ;; *000) ;;
*) *)
case $g in case $g in
0) ;; 0) x= ;;
1) val=THOUSAND ;; 1) x=THOUSAND ;;
2) val=MILLION ;; 2) x=MILLION ;;
3) val=BILLION ;; 3) x=BILLION ;;
4) val=TRILLION ;; 4) x=TRILLION ;;
5) val=QUADRILLION ;; 5) x=QUADRILLION ;;
6) val=QUINTILLION ;; 6) x=QUINTILLION ;;
7) val=SEXTILLION ;; 7) x=SEXTILLION ;;
8) val=SEPTILLION ;; 8) x=SEPTILLION ;;
*) *)
echo "YOU HAVE TOO MUCH MAIL!" 1>&2 echo "YOU HAVE TOO MUCH MAIL!" 1>&2
exit 1 exit 1
;; ;;
esac esac
case $g in case $v in
0) ;; *10) y=TEN ;;
*) result="$val $result" ;; *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 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 esac
g=$(($g + 1)) 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%%???} v=${v%%???}
done done
plural=S p=S
case "$result" in case "$*" in
"") result=ZERO ;; "") set ZERO ;;
"ONE ") plural= ;; ONE) p= ;;
esac esac
set -- $result
echo "$*! echo "$*!
$* NEW MAIL MESSAGE$plural! $* MAIL MESSAGE$p!
HAHAHAHAHA!" HAHAHAHAHA!"

View File

@@ -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 # @(#)Makefile 8.1 (Berkeley) 5/31/93
.include <bsd.own.mk>
PROG= cribbage PROG= cribbage
DPADD= ${LIBCURSES} DPADD= ${LIBCURSES}
LDADD= -lcurses LDADD= -lcurses
@@ -8,8 +10,10 @@ SRCS= extern.c crib.c cards.c instr.c io.c score.c support.c
MAN= cribbage.6 MAN= cribbage.6
HIDEGAME=hidegame HIDEGAME=hidegame
SETGIDGAME=yes SETGIDGAME=yes
.if ${MKSHARE} != "no"
FILES= cribbage.n FILES= cribbage.n
FILESNAME=cribbage.instr FILESNAME=cribbage.instr
FILESDIR=/usr/share/games FILESDIR=/usr/share/games
.endif
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@@ -1,4 +1,30 @@
# Makefrag - makefile fragment for cribbage # 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)) cribbage_DIRS := $(GAMESDIR) $(MAN6DIR) $(shell dirname $(CRIBBAGE_INSTRFILE))

View File

@@ -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 * Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)cards.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)cards.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */

View File

@@ -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 * Copyright (c) 1980, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
#if 0 #if 0
static char sccsid[] = "@(#)crib.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)crib.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -76,6 +76,8 @@ main(argc, argv)
f = fopen(_PATH_LOG, "a"); f = fopen(_PATH_LOG, "a");
if (f == NULL) if (f == NULL)
warn("fopen %s", _PATH_LOG); warn("fopen %s", _PATH_LOG);
if (f != NULL && fileno(f) < 3)
exit(1);
/* Revoke setgid privileges */ /* Revoke setgid privileges */
setregid(getgid(), getgid()); setregid(getgid(), getgid());
@@ -110,7 +112,7 @@ main(argc, argv)
initscr(); initscr();
(void)signal(SIGINT, rint); (void)signal(SIGINT, rint);
crmode(); cbreak();
noecho(); noecho();
Playwin = subwin(stdscr, PLAY_Y, PLAY_X, 0, 0); Playwin = subwin(stdscr, PLAY_Y, PLAY_X, 0, 0);
@@ -130,7 +132,7 @@ main(argc, argv)
mvcur(0, COLS - 1, LINES - 1, 0); mvcur(0, COLS - 1, LINES - 1, 0);
fflush(stdout); fflush(stdout);
instructions(); instructions();
crmode(); cbreak();
noecho(); noecho();
clear(); clear();
refresh(); refresh();
@@ -194,8 +196,6 @@ makeboard()
void void
gamescore() gamescore()
{ {
extern int Lastscore[];
if (pgames || cgames) { if (pgames || cgames) {
mvprintw(SCORE_Y + 1, SCORE_X + 28, "Games: %3d", pgames); mvprintw(SCORE_Y + 1, SCORE_X + 28, "Games: %3d", pgames);
mvprintw(SCORE_Y + 7, SCORE_X + 28, "Games: %3d", cgames); mvprintw(SCORE_Y + 7, SCORE_X + 28, "Games: %3d", cgames);

View File

@@ -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 .\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@@ -45,9 +45,9 @@
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm .Nm
plays the card game cribbage, with the program playing one hand plays the card game cribbage, with the program playing one hand
and the user the other. The program will initially ask the user if and the user the other.
the rules of the game are needed \- if so, it will print out The program will initially ask the user if the rules of the game are
the appropriate section from needed \(en if so, it will print out the appropriate section from
.Em According to Hoyle .Em According to Hoyle
with with
.Xr more 1 . .Xr more 1 .
@@ -57,10 +57,10 @@ options include:
.Bl -tag -width indent .Bl -tag -width indent
.It Fl e .It Fl e
When the player makes a mistake scoring his hand or crib, provide an When the player makes a mistake scoring his hand or crib, provide an
explanation of the correct score. (This is especially useful for explanation of the correct score.
beginning players.) (This is especially useful for beginning players.)
.It Fl q .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. users who have played the game without specifying this option.
.It Fl r .It Fl r
Instead of asking the player to cut the deck, the program will randomly 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 , .Dq once around ,
to 61) or a long game ( to 61) or a long game (
.Dq twice around , .Dq twice around ,
to 121). A to 121).
response of A response of
.Sq Ic s .Sq Ic s
will result in a short game, any other response will will result in a short game, any other response will play a long game.
play a long game.
.Pp .Pp
At the start of the first game, the program At the start of the first game, the program
asks the player to cut the deck to determine who gets the asks the player to cut the deck to determine who gets the first crib.
first crib. The user should respond with a number between 0 and The user should respond with a number between 0 and
51, indicating how many cards down the deck is to be cut. The player 51, indicating how many cards down the deck is to be cut.
who cuts the lower ranked card gets the first crib. The player who cuts the lower ranked card gets the first crib.
If more than one game is played, the If more than one game is played, the
loser of the previous game gets the first crib in the current game. loser of the previous game gets the first crib in the current game.
.Pp .Pp
For each hand, the program first prints the player's hand, For each hand, the program first prints the player's hand,
whose crib it is, and then asks the player whose crib it is, and then asks the player
to discard two cards into the crib. The cards are prompted for to discard two cards into the crib.
one per line, and are typed as explained below. The cards are prompted for one per line, and are typed as explained below.
.Pp .Pp
After discarding, the program cuts the deck (if it is the player's 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 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 .Pp
After cutting the deck, play starts with the non-dealer (the person After cutting the deck, play starts with the non-dealer (the person
who doesn't have the crib) leading the first card. who doesn't have the crib) leading the first card.
Play continues, as per cribbage, until all cards are exhausted. The Play continues, as per cribbage, until all cards are exhausted.
program keeps track of the scoring of all points and the total of The program keeps track of the scoring of all points and the total of
the cards on the table. the cards on the table.
.Pp .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 score his hand (and the crib, if it is his) by printing out the
appropriate cards (and the cut card enclosed in brackets). appropriate cards (and the cut card enclosed in brackets).
Play continues until one player reaches the game limit (61 or 121). 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 to typing the lowest legal value; when cutting the deck this
is equivalent to choosing the top card. is equivalent to choosing the top card.
.Pp .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: as one of:
.Sq a , .Sq a ,
.Sq 2 , .Sq 2 ,
@@ -159,7 +160,8 @@ A card may be specified as:
or: or:
.Dq Ao rank Ac of Aq suit . .Dq Ao rank Ac of Aq suit .
If the single letter rank and suit designations are used, the space 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. 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 .Dq 2H, 4D, 5C, 6H, JC, and KD
@@ -177,7 +179,7 @@ the following could be typed:
.Sq king diamonds , .Sq king diamonds ,
.Sq king of diamonds . .Sq king of diamonds .
.Sh FILES .Sh FILES
.Bl -tag -width @gamesdir@/cribbage -compact .Bl -tag -width @cribbage_instrfile@ -compact
.It Pa @gamesdir@/cribbage .It Pa @gamesdir@/cribbage
.It Pa @cribbage_scorefile@ .It Pa @cribbage_scorefile@
.It Pa @cribbage_instrfile@ .It Pa @cribbage_instrfile@

View File

@@ -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 * Copyright (c) 1980, 1993
@@ -59,9 +59,10 @@ extern BOOLEAN rflag; /* if all cuts random */
extern BOOLEAN quiet; /* if suppress random mess */ extern BOOLEAN quiet; /* if suppress random mess */
extern BOOLEAN playing; /* currently playing game */ 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 adjust __P((const CARD [], CARD));
int anymove __P((const CARD [], int, int)); int anymove __P((const CARD [], int, int));
int anysumto __P((const CARD [], int, 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 makeboard __P((void));
void makedeck __P((CARD [])); void makedeck __P((CARD []));
void makeknown __P((const CARD [], int)); 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 msgcard __P((CARD, BOOLEAN));
int msgcrd __P((CARD, BOOLEAN, const char *, BOOLEAN)); int msgcrd __P((CARD, BOOLEAN, const char *, BOOLEAN));
int number __P((int, int, const char *)); int number __P((int, int, const char *));

View File

@@ -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 * Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)extern.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)extern.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -52,7 +52,7 @@ BOOLEAN iwon = FALSE; /* if comp won last game */
BOOLEAN quiet = FALSE; /* if suppress random mess */ BOOLEAN quiet = FALSE; /* if suppress random mess */
BOOLEAN rflag = FALSE; /* if all cuts random */ BOOLEAN rflag = FALSE; /* if all cuts random */
char expl[128]; /* explanation */ char explan[128]; /* explanation */
int cgames = 0; /* number games comp won */ int cgames = 0; /* number games comp won */
int cscore = 0; /* comp score in this game */ int cscore = 0; /* comp score in this game */

View File

@@ -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 * Copyright (c) 1990, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)instr.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)instr.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -90,7 +90,7 @@ instructions()
_exit(1); _exit(1);
} }
execl("/bin/sh", "sh", "-c", path, NULL); execl("/bin/sh", "sh", "-c", path, NULL);
warn("%s", ""); warn(NULL);
_exit(1); _exit(1);
default: default:
do { do {

View File

@@ -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 * Copyright (c) 1980, 1993
@@ -38,24 +38,19 @@
#if 0 #if 0
static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
#include <ctype.h> #include <ctype.h>
#include <curses.h> #include <curses.h>
#include <signal.h> #include <signal.h>
#include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <termios.h> #include <termios.h>
#include <unistd.h> #include <unistd.h>
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include "deck.h" #include "deck.h"
#include "cribbage.h" #include "cribbage.h"
#include "cribcur.h" #include "cribcur.h"
@@ -392,21 +387,11 @@ int Mpos = 0;
static int Newpos = 0; static int Newpos = 0;
void void
#if __STDC__
msg(const char *fmt, ...) msg(const char *fmt, ...)
#else
msg(fmt, va_alist)
char *fmt;
va_dcl
#endif
{ {
va_list ap; va_list ap;
#if __STDC__
va_start(ap, fmt); va_start(ap, fmt);
#else
va_start(ap);
#endif
(void)vsprintf(&Msgbuf[Newpos], fmt, ap); (void)vsprintf(&Msgbuf[Newpos], fmt, ap);
Newpos = strlen(Msgbuf); Newpos = strlen(Msgbuf);
va_end(ap); va_end(ap);
@@ -418,21 +403,11 @@ msg(fmt, va_alist)
* Add things to the current message * Add things to the current message
*/ */
void void
#if __STDC__
addmsg(const char *fmt, ...) addmsg(const char *fmt, ...)
#else
addmsg(fmt, va_alist)
char *fmt;
va_dcl
#endif
{ {
va_list ap; va_list ap;
#if __STDC__
va_start(ap, fmt); va_start(ap, fmt);
#else
va_start(ap);
#endif
(void)vsprintf(&Msgbuf[Newpos], fmt, ap); (void)vsprintf(&Msgbuf[Newpos], fmt, ap);
Newpos = strlen(Msgbuf); Newpos = strlen(Msgbuf);
va_end(ap); va_end(ap);
@@ -612,7 +587,7 @@ getline()
void void
rint(signo) rint(signo)
int signo __attribute__((unused)); int signo __attribute__((__unused__));
{ {
bye(); bye();
exit(1); exit(1);

View File

@@ -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 * Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -122,7 +122,7 @@ scorehand(hand, starter, n, crb, do_explain)
CARD h[(CINHAND + 1)]; CARD h[(CINHAND + 1)];
char buf[32]; char buf[32];
expl[0] = '\0'; /* initialize explanation */ explan[0] = '\0'; /* initialize explanation */
score = 0; score = 0;
flag = TRUE; flag = TRUE;
k = hand[0].suit; k = hand[0].suit;
@@ -132,29 +132,29 @@ scorehand(hand, starter, n, crb, do_explain)
if (hand[i].suit == starter.suit) { if (hand[i].suit == starter.suit) {
score++; score++;
if (do_explain) if (do_explain)
strcat(expl, "His Nobs"); strcat(explan, "His Nobs");
} }
h[i] = hand[i]; h[i] = hand[i];
} }
if (flag && n >= CINHAND) { if (flag && n >= CINHAND) {
if (do_explain && expl[0] != '\0') if (do_explain && explan[0] != '\0')
strcat(expl, ", "); strcat(explan, ", ");
if (starter.suit == k) { if (starter.suit == k) {
score += 5; score += 5;
if (do_explain) if (do_explain)
strcat(expl, "Five-flush"); strcat(explan, "Five-flush");
} else } else
if (!crb) { if (!crb) {
score += 4; score += 4;
if (do_explain && expl[0] != '\0') if (do_explain && explan[0] != '\0')
strcat(expl, ", Four-flush"); strcat(explan, ", Four-flush");
else else
strcpy(expl, "Four-flush"); strcpy(explan, "Four-flush");
} }
} }
if (do_explain && expl[0] != '\0') if (do_explain && explan[0] != '\0')
strcat(expl, ", "); strcat(explan, ", ");
h[n] = starter; h[n] = starter;
sorthand(h, n + 1); /* sort by rank */ sorthand(h, n + 1); /* sort by rank */
i = 2 * fifteens(h, n + 1); i = 2 * fifteens(h, n + 1);
@@ -162,9 +162,9 @@ scorehand(hand, starter, n, crb, do_explain)
if (do_explain) { if (do_explain) {
if (i > 0) { if (i > 0) {
(void) sprintf(buf, "%d points in fifteens", i); (void) sprintf(buf, "%d points in fifteens", i);
strcat(expl, buf); strcat(explan, buf);
} else } else
strcat(expl, "No fifteens"); strcat(explan, "No fifteens");
} }
i = pairuns(h, n + 1); i = pairuns(h, n + 1);
score += i; score += i;
@@ -172,9 +172,9 @@ scorehand(hand, starter, n, crb, do_explain)
if (i > 0) { if (i > 0) {
(void) sprintf(buf, ", %d points in pairs, %d in runs", (void) sprintf(buf, ", %d points in pairs, %d in runs",
pairpoints, runpoints); pairpoints, runpoints);
strcat(expl, buf); strcat(explan, buf);
} else } else
strcat(expl, ", No pairs/runs"); strcat(explan, ", No pairs/runs");
} }
return (score); return (score);
} }
@@ -354,7 +354,7 @@ pegscore(crd, tbl, n, sum)
int int
adjust(cb, tnv) adjust(cb, tnv)
const CARD cb[]; const CARD cb[];
CARD tnv __attribute__((unused)); CARD tnv __attribute__((__unused__));
{ {
long scr; long scr;
int i, c0, c1; int i, c0, c1;

View File

@@ -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 * Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)support.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)support.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -152,7 +152,7 @@ plyrhand(hand, s)
msg("You should have taken %d, not %d!", i, j); msg("You should have taken %d, not %d!", i, j);
} }
if (explain) if (explain)
msg("Explanation: %s", expl); msg("Explanation: %s", explan);
do_wait(); do_wait();
} else } else
win = chkscr(&pscore, i); win = chkscr(&pscore, i);

View File

@@ -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 # @(#)Makefile 8.1 (Berkeley) 5/31/93
.include <bsd.own.mk>
# -DLOG log games # -DLOG log games
PROG= dm PROG= dm
SRCS= dm.c utmpentry.c
MAN= dm.8 dm.conf.5 MAN= dm.8 dm.conf.5
# shouldn't be necessary; just in case. # shouldn't be necessary; just in case.
BINGRP= games BINGRP= games
BINMODE=2555 BINMODE=2555
.PATH.c: ${NETBSDSRCDIR}/usr.bin/who
CPPFLAGS+=-I${NETBSDSRCDIR}/usr.bin/who -DSUPPORT_UTMPX -DSUPPORT_UTMP
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@@ -1,7 +1,33 @@
# Makefrag - makefile fragment for dm # 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 # Add -DLOG if you want logging
dm_DEFS := # -DLOG dm_DEFS := $(GETLOADAVG_DEFS) # -DLOG
dm_DIRS := $(GAMESDIR) $(MAN8DIR) $(MAN5DIR) dm_DIRS := $(GAMESDIR) $(MAN8DIR) $(MAN5DIR)
dm_all: dm/dm dm/dm.8 dm/dm.conf.5 dm_all: dm/dm dm/dm.8 dm/dm.conf.5

View File

@@ -10,4 +10,4 @@ Add -DLOG to the DEFS in the Makefile if you want logging of games
playing. playing.
Joseph S. Myers Joseph S. Myers
jsm28@cam.ac.uk jsm@polyomino.org.uk

View File

@@ -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 .\" Copyright (c) 1987, 1991, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@@ -48,7 +48,7 @@ is a program used to regulate game playing.
.Nm .Nm
expects to be invoked with the name of a game that a user wishes to play. expects to be invoked with the name of a game that a user wishes to play.
This is done by creating symbolic links to This is done by creating symbolic links to
.Nm "" , .Nm ,
in the directory in the directory
.Pa @gamesdir@ .Pa @gamesdir@
for all of the regulated games. for all of the regulated games.
@@ -63,8 +63,7 @@ program.
determines if the requested game is available and, if so, runs it. determines if the requested game is available and, if so, runs it.
The file The file
.Pa @dm_configfile@ .Pa @dm_configfile@
controls the conditions under which games may controls the conditions under which games may be run.
be run.
.Pp .Pp
The file The file
.Pa @dm_nogamesfile@ .Pa @dm_nogamesfile@
@@ -99,7 +98,7 @@ running the games setgid
First, all games that allow users to run First, all games that allow users to run
.Ux .Ux
commands should carefully 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. those commands.
Probably more important is that Probably more important is that
.Nm .Nm

12
dm/dm.c
View File

@@ -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 * Copyright (c) 1987, 1993
@@ -43,7 +44,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993\n\
#if 0 #if 0
static char sccsid[] = "@(#)dm.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)dm.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -83,7 +84,7 @@ int users __P((void));
int int
main(argc, argv) main(argc, argv)
int argc __attribute__((unused)); int argc __attribute__((__unused__));
char *argv[]; char *argv[];
{ {
char *cp; char *cp;
@@ -116,10 +117,7 @@ play(args)
{ {
char pbuf[MAXPATHLEN]; char pbuf[MAXPATHLEN];
(void)strncpy(pbuf, _PATH_HIDE, sizeof(pbuf) - 1); snprintf(pbuf, sizeof(pbuf), "%s%s", _PATH_HIDE, game);
(void)strncpy(pbuf + sizeof(_PATH_HIDE) - 1, game,
sizeof(pbuf) - sizeof(_PATH_HIDE) - 1);
pbuf[sizeof(pbuf) - 1] = '\0';
if (priority > 0) /* < 0 requires root */ if (priority > 0) /* < 0 requires root */
(void)setpriority(PRIO_PROCESS, 0, priority); (void)setpriority(PRIO_PROCESS, 0, priority);
execv(pbuf, args); execv(pbuf, args);

View File

@@ -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 .\" Copyright (c) 1988, 1991, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@@ -35,7 +35,7 @@
.\" .\"
.Dd May 31, 1993 .Dd May 31, 1993
.Dt DM.CONF 5 .Dt DM.CONF 5
.Os BSD 4.2 .Os
.Sh NAME .Sh NAME
.Nm dm.conf .Nm dm.conf
.Nd dungeon master configuration file .Nd dungeon master configuration file
@@ -59,8 +59,7 @@ Entries consist of two white-space separated fields: the string
.Em badtty .Em badtty
and the ttyname as returned by and the ttyname as returned by
.Xr ttyname 3 . .Xr ttyname 3 .
For example, For example, to keep the uucp dialout,
to keep the uucp dialout,
.Dq tty19 , .Dq tty19 ,
from being used for games, the entry would be: from being used for games, the entry would be:
.Bd -literal -offset indent .Bd -literal -offset indent
@@ -94,17 +93,14 @@ in no game limitation or priority based on that field.
.Pp .Pp
The game The game
.Em default .Em default
controls the settings for controls the settings for any game not otherwise listed, and must be the last
any game not otherwise listed, and must be the last
.Em game .Em game
entry in the file. entry in the file.
Priorities may not be negative. Priorities may not be negative.
For example, the following entries For example, the following entries limits the game
limits the game
.Dq hack .Dq hack
to running only when the system has 10 or less to running only when the system has 10 or less users and a load average of 5
users and a load average of 5 or less; all other games may be run any time or less; all other games may be run any time the system has 15 or less users.
the system has 15 or less users.
.Bd -literal -offset indent .Bd -literal -offset indent
game hack 5 10 * game hack 5 10 *
game default * 15 * game default * 15 *

View File

@@ -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 # @(#)Makefile 8.1 (Berkeley) 5/31/93
# For MKCRYPTO
.include <bsd.own.mk>
PRIMES= ${NETBSDSRCDIR}/games/primes
PROG= factor PROG= factor
SRCS= factor.c pr_tbl.c 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 MAN= factor.6
MLINKS+=factor.6 primes.6 MLINKS+=factor.6 primes.6
.PATH: ${.CURDIR}/../primes .PATH: ${PRIMES}
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@@ -1,4 +1,30 @@
# Makefrag - makefile fragment for factor # 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() # _GNU_SOURCE for isblank()
factor_DEFS := -D_GNU_SOURCE factor_DEFS := -D_GNU_SOURCE
@@ -11,6 +37,3 @@ factor_install: factor_all
$(INSTALL_BINARY) factor/factor $(INSTALL_PREFIX)$(GAMESDIR)/factor $(INSTALL_BINARY) factor/factor $(INSTALL_PREFIX)$(GAMESDIR)/factor
$(HIDE_GAME) factor $(HIDE_GAME) factor
$(INSTALL_MANUAL) factor/factor.6 $(INSTALL_MANUAL) factor/factor.6
factor_check: factor_all
factor/factor 69300

View File

@@ -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 * Copyright (c) 1989, 1993
@@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
#if 0 #if 0
static char sccsid[] = "@(#)factor.c 8.4 (Berkeley) 5/4/95"; static char sccsid[] = "@(#)factor.c 8.4 (Berkeley) 5/4/95";
#else #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
#endif /* not lint */ #endif /* not lint */
@@ -69,14 +69,29 @@ __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. * If no args are given, the list of numbers are read from stdin.
*/ */
#include <err.h>
#include <ctype.h> #include <ctype.h>
#include <err.h>
#include <errno.h> #include <errno.h>
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#ifdef HAVE_OPENSSL
#include <openssl/bn.h>
#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" #include "primes.h"
/* /*
@@ -88,18 +103,51 @@ __RCSID("$NetBSD: factor.c,v 1.8 1998/09/13 15:27:27 hubertf Exp $");
extern const ubig prime[]; extern const ubig prime[];
extern const ubig *pr_limit; /* largest prime in the prime array */ extern const ubig *pr_limit; /* largest prime in the prime array */
int main __P((int, char *[])); #define PRIME_CHECKS 5
void pr_fact __P((ubig)); /* print factors of a value */
void usage __P((void)) __attribute__((__noreturn__)); #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 int
main(argc, argv) main(int argc, char *argv[])
int argc;
char *argv[];
{ {
ubig val; BIGNUM *val;
int ch; 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 */ /* Revoke setgid privileges */
setregid(getgid(), getgid()); setregid(getgid(), getgid());
@@ -126,12 +174,8 @@ main(argc, argv)
continue; continue;
if (*p == '-') if (*p == '-')
errx(1, "negative numbers aren't permitted."); errx(1, "negative numbers aren't permitted.");
errno = 0; if (BN_dec2bn(&val, buf) == 0)
val = strtoul(buf, &p, 10); errx(1, "%s: illegal numeric format.", argv[0]);
if (errno)
err(1, "%s", buf);
if (*p != '\n')
errx(1, "%s: illegal numeric format.", buf);
pr_fact(val); pr_fact(val);
} }
/* Factor the arguments. */ /* Factor the arguments. */
@@ -139,11 +183,7 @@ main(argc, argv)
for (; *argv != NULL; ++argv) { for (; *argv != NULL; ++argv) {
if (argv[0][0] == '-') if (argv[0][0] == '-')
errx(1, "negative numbers aren't permitted."); errx(1, "negative numbers aren't permitted.");
errno = 0; if (BN_dec2bn(&val, argv[0]) == 0)
val = strtoul(argv[0], &p, 10);
if (errno)
err(1, "%s", argv[0]);
if (*p != '\0')
errx(1, "%s: illegal numeric format.", argv[0]); errx(1, "%s: illegal numeric format.", argv[0]);
pr_fact(val); pr_fact(val);
} }
@@ -164,49 +204,152 @@ main(argc, argv)
* Factors are printed with leading tabs. * Factors are printed with leading tabs.
*/ */
void void
pr_fact(val) pr_fact(BIGNUM *val)
ubig val; /* Factor this value. */
{ {
const ubig *fact; /* The factor found. */ const ubig *fact; /* The factor found. */
/* Firewall - catch 0 and 1. */ /* 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); exit(0);
if (val == 1) { if (BN_is_one(val)) {
(void)printf("1: 1\n"); printf("1: 1\n");
return; return;
} }
/* Factor value. */ /* 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. */ /* Look for the smallest factor. */
do { do {
if (val % (long)*fact == 0) if (BN_mod_word(val, (BN_ULONG)*fact) == 0)
break; break;
} while (++fact <= pr_limit); } while (++fact <= pr_limit);
/* Watch for primes larger than the table. */ /* Watch for primes larger than the table. */
if (fact > pr_limit) { 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; break;
} }
/* Divide factor out until none are left. */ /* Divide factor out until none are left. */
do { do {
(void)printf(" %lu", *fact); printf(" %lu", *fact);
val /= (long)*fact; BN_div_word(val, (BN_ULONG)*fact);
} while ((val % (long)*fact) == 0); } while (BN_mod_word(val, (BN_ULONG)*fact) == 0);
/* Let the user know we're doing something. */ /* 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 void
usage() usage(void)
{ {
(void)fprintf(stderr, "usage: factor [value ...]\n"); fprintf(stderr, "usage: factor [value ...]\n");
exit (0); 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

View File

@@ -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 # @(#)Makefile 8.1 (Berkeley) 5/31/93
.include <bsd.own.mk>
PROG= fish PROG= fish
MAN= fish.6 MAN= fish.6
HIDEGAME=hidegame HIDEGAME=hidegame
.if ${MKSHARE} != "no"
FILES=fish.instr FILES=fish.instr
FILESDIR=/usr/share/games FILESDIR=/usr/share/games
.endif
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@@ -1,4 +1,30 @@
# Makefrag - makefile fragment for fish # 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)) fish_DIRS := $(GAMESDIR) $(MAN6DIR) $(shell dirname $(FISH_INSTRFILE))

View File

@@ -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 .\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@@ -38,7 +38,8 @@
.Os .Os
.Sh NAME .Sh NAME
.Nm fish .Nm fish
.Nd play ``Go Fish'' .Nd play
.Dq Go Fish
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl p .Op Fl p

View File

@@ -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 * Copyright (c) 1990, 1993
@@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 1993\n\
#if 0 #if 0
static char sccsid[] = "@(#)fish.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)fish.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #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 RANKS 13
#define HANDSIZE 7 #define HANDSIZE 7
#define CARDS 4 #define CARDS 4
#define TOTCARDS RANKS * CARDS
#define USER 1 #define USER 1
#define COMPUTER 0 #define COMPUTER 0
@@ -77,8 +78,9 @@ const char *const cards[] = {
#define PRC(card) (void)printf(" %s", cards[card]) #define PRC(card) (void)printf(" %s", cards[card])
int promode; int promode;
int asked[RANKS], comphand[RANKS], deck[RANKS]; int asked[RANKS], comphand[RANKS], deck[TOTCARDS];
int userasked[RANKS], userhand[RANKS]; int userasked[RANKS], userhand[RANKS];
int curcard = TOTCARDS;
void chkwinner __P((int, const int *)); void chkwinner __P((int, const int *));
int compmove __P((void)); int compmove __P((void));
@@ -164,13 +166,13 @@ usermove()
for (;;) { for (;;) {
(void)printf("You ask me for: "); (void)printf("You ask me for: ");
(void)fflush(stdout); (void)fflush(stdout);
if (fgets(buf, BUFSIZ, stdin) == NULL) if (fgets(buf, sizeof(buf), stdin) == NULL)
exit(0); exit(0);
if (buf[0] == '\0') if (buf[0] == '\0')
continue; continue;
if (buf[0] == '\n') { if (buf[0] == '\n') {
(void)printf("%d cards in my hand, %d in the pool.\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)printf("My books:");
(void)countbooks(comphand); (void)countbooks(comphand);
continue; continue;
@@ -270,9 +272,7 @@ drawcard(player, hand)
{ {
int card; int card;
while (deck[card = nrandom(RANKS)] == 0); ++hand[card = deck[--curcard]];
++hand[card];
--deck[card];
if (player == USER || hand[card] == CARDS) { if (player == USER || hand[card] == CARDS) {
printplayer(player); printplayer(player);
(void)printf("drew %s", cards[card]); (void)printf("drew %s", cards[card]);
@@ -423,19 +423,21 @@ countbooks(hand)
void void
init() init()
{ {
int i, rank; int i, j, temp;
for (i = 0; i < RANKS; ++i) for (i = 0; i < TOTCARDS; ++i)
deck[i] = CARDS; deck[i] = i % RANKS;
for (i = 0; i < HANDSIZE; ++i) { for (i = 0; i < TOTCARDS - 1; ++i) {
while (!deck[rank = nrandom(RANKS)]); j = nrandom(TOTCARDS-i);
++userhand[rank]; if (j == 0)
--deck[rank]; continue;
temp = deck[i];
deck[i] = deck[i+j];
deck[i+j] = temp;
} }
for (i = 0; i < HANDSIZE; ++i) { for (i = 0; i < HANDSIZE; ++i) {
while (!deck[rank = nrandom(RANKS)]); ++userhand[deck[--curcard]];
++comphand[rank]; ++comphand[deck[--curcard]];
--deck[rank];
} }
} }

View File

@@ -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 # @(#)Makefile 8.1 (Berkeley) 5/31/93
SUBDIR= fortune strfile datfiles SUBDIR= fortune strfile .WAIT datfiles
all-datfiles: all-strfile
.include <bsd.subdir.mk> .include <bsd.subdir.mk>

Some files were not shown because too many files have changed in this diff Show More