diff options
Diffstat (limited to 'adventure')
-rw-r--r-- | adventure/Makefile | 4 | ||||
-rw-r--r-- | adventure/crc.c | 14 | ||||
-rw-r--r-- | adventure/done.c | 10 | ||||
-rw-r--r-- | adventure/extern.h | 131 | ||||
-rw-r--r-- | adventure/hdr.h | 13 | ||||
-rw-r--r-- | adventure/init.c | 137 | ||||
-rw-r--r-- | adventure/io.c | 49 | ||||
-rw-r--r-- | adventure/main.c | 49 | ||||
-rw-r--r-- | adventure/save.c | 133 | ||||
-rw-r--r-- | adventure/subr.c | 44 | ||||
-rw-r--r-- | adventure/vocab.c | 33 | ||||
-rw-r--r-- | adventure/wizard.c | 42 |
12 files changed, 447 insertions, 212 deletions
diff --git a/adventure/Makefile b/adventure/Makefile index 85c820c4..b4b0b352 100644 --- a/adventure/Makefile +++ b/adventure/Makefile @@ -1,10 +1,10 @@ -# $NetBSD: Makefile,v 1.4 1997/04/19 06:59:34 thorpej Exp $ +# $NetBSD: Makefile,v 1.5 1997/08/11 14:06:10 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 6/12/93 +WARNS?= 1 PROG= adventure SRCS= main.c init.c done.c save.c subr.c vocab.c wizard.c io.c data.c crc.c MAN= adventure.6 -CFLAGS+=-traditional-cpp HIDEGAME=hidegame CLEANFILES+=setup data.c diff --git a/adventure/crc.c b/adventure/crc.c index 45e43036..718907a8 100644 --- a/adventure/crc.c +++ b/adventure/crc.c @@ -1,4 +1,4 @@ -/* $NetBSD: crc.c,v 1.2 1995/03/21 12:04:59 cgd Exp $ */ +/* $NetBSD: crc.c,v 1.3 1997/08/11 14:06:11 christos Exp $ */ /*- * Copyright (c) 1993 @@ -36,18 +36,19 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)crc.c 8.1 (Berkeley) 5/31/93"; static char ORIGINAL_sccsid[] = "@(#)crc.c 5.2 (Berkeley) 4/4/91"; #else -static char rcsid[] = "$NetBSD: crc.c,v 1.2 1995/03/21 12:04:59 cgd Exp $"; +__RCSID("$NetBSD: crc.c,v 1.3 1997/08/11 14:06:11 christos Exp $"); #endif #endif /* not lint */ -typedef unsigned long u_long; +#include "extern.h" -u_long crctab[] = { +unsigned long crctab[] = { 0x7fffffff, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, @@ -110,15 +111,16 @@ u_long crctab[] = { * it. */ -u_long crcval; +unsigned long crcval; int step; +void crc_start() { crcval = step = 0; } -u_long crc(ptr, nr) /* Process nr bytes at a time; ptr points to them */ +unsigned long crc(ptr, nr) /* Process nr bytes at a time; ptr points to them */ char *ptr; int nr; { diff --git a/adventure/done.c b/adventure/done.c index 464d606f..2340d2ee 100644 --- a/adventure/done.c +++ b/adventure/done.c @@ -1,4 +1,4 @@ -/* $NetBSD: done.c,v 1.2 1995/03/21 12:05:01 cgd Exp $ */ +/* $NetBSD: done.c,v 1.3 1997/08/11 14:06:12 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -38,18 +38,22 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)done.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: done.c,v 1.2 1995/03/21 12:05:01 cgd Exp $"; +__RCSID("$NetBSD: done.c,v 1.3 1997/08/11 14:06:12 christos Exp $"); #endif #endif /* not lint */ /* Re-coding of advent in C: termination routines */ +#include <stdio.h> #include "hdr.h" +#include "extern.h" +int score() /* sort of like 20000 */ { register int scor,i; mxscor=scor=0; @@ -86,6 +90,7 @@ score() /* sort of like 20000 */ return(scor); } +void done(entry) /* entry=1 means goto 13000 */ /* game is over */ int entry; /* entry=2 means goto 20000 */ /* 3=19000 */ { register int i,sc; @@ -114,6 +119,7 @@ int entry; /* entry=2 means goto 20000 */ /* 3=19000 */ } +int die(entry) /* label 90 */ int entry; { register int i; diff --git a/adventure/extern.h b/adventure/extern.h new file mode 100644 index 00000000..6da0d42a --- /dev/null +++ b/adventure/extern.h @@ -0,0 +1,131 @@ +/* $NetBSD: extern.h,v 1.1 1997/08/11 14:06:13 christos Exp $ */ + +/* + * Copyright (c) 1997 Christos Zoulas. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christos Zoulas. + * 4. 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. + */ + +/* crc.c */ +void crc_start __P((void)); +unsigned long crc __P((char *, int)); + +/* done.c */ +int score __P((void)); +void done __P((int)); +int die __P((int)); + +/* init.c */ +void init __P((char *)); +char *decr __P((int, int, int, int, int)); +void linkdata __P((void)); +void trapdel __P((int)); +void startup __P((void)); + +/* io.c */ +void getin __P((char **, char **)); +int confirm __P((char *)); +int yes __P((int, int, int)); +int yesm __P((int, int, int)); +int next __P((void)); +void rdata __P((void)); +int rnum __P((void)); +void rdesc __P((int)); +void rtrav __P((void)); +int twrite __P((int)); +void rvoc __P((void)); +void rlocs __P((void)); +void rdflt __P((void)); +void rliq __P((void)); +void rhints __P((void)); +void rspeak __P((int)); +void mspeak __P((int)); +struct text; +void speak __P((struct text *)); +void pspeak __P((int, int)); + +/* main.c */ +int main __P((int, char **)); + +/* save.c */ +int save __P((char *)); +int restore __P((char *)); + +/* setup.c */ +int main __P((int, char *[])); +void fatal __P((char *, int)); + +/* subr.c */ +int toting __P((int)); +int here __P((int)); +int at __P((int)); +int liq2 __P((int)); +int liq __P((int)); +int liqloc __P((int)); +int bitset __P((int, int)); +int forced __P((int)); +int dark __P((int)); +int pct __P((int)); +int fdwarf __P((void)); +int march __P((void)); +int mback __P((void)); +int specials __P((void)); +int trbridge __P((void)); +int badmove __P((void)); +int bug __P((int)) __attribute__((__noreturn__)); +int checkhints __P((void)); +int trsay __P((void)); +int trtake __P((void)); +int dropper __P((void)); +int trdrop __P((void)); +int tropen __P((void)); +int trkill __P((void)); +int trtoss __P((void)); +int trfeed __P((void)); +int trfill __P((void)); +int closing __P((void)); +int caveclose __P((void)); + +/* vocab.c */ +void dstroy __P((int)); +void juggle __P((int)); +void move __P((int, int)); +int put __P((int, int, int)); +void carry __P((int, int)); +void drop __P((int, int)); +int vocab __P((char *, int, int)); +void copystr __P((char *, char *)); +int weq __P((char *, char *)); +int length __P((char *)); +void prht __P((void)); + +/* wizard.c */ +void datime __P((int *, int *)); +void poof __P((void)); +int Start __P((int)); +int wizard __P((void)); +void ciao __P((char *)); +int ran __P((int)); diff --git a/adventure/hdr.h b/adventure/hdr.h index 6e1440b8..dad807e2 100644 --- a/adventure/hdr.h +++ b/adventure/hdr.h @@ -1,4 +1,4 @@ -/* $NetBSD: hdr.h,v 1.2 1995/03/21 12:05:02 cgd Exp $ */ +/* $NetBSD: hdr.h,v 1.3 1997/08/11 14:06:14 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -86,7 +86,7 @@ struct hashtab /* hash table for vocabulary */ struct text #ifdef OLDSTUFF { int seekadr; /* DATFILE must be < 2**16 */ -#endif OLDSTUFF +#endif /* OLDSTUFF */ { char *seekadr; /* Msg start in virtual disk */ int txtlen; /* length of msg starting here */ }; @@ -130,7 +130,7 @@ int hntmax; int hints[20][5]; /* info on hints */ int hinted[20],hintlc[20]; -int place[101], prop[101],link[201]; +int place[101], prop[101],links[201]; int abb[LOCSIZ]; int maxtrs,tally,tally2; /* treasure values */ @@ -158,9 +158,4 @@ int turns,lmwarn,iwest,knfloc,detail, /* various flags & counters */ int demo,newloc,limit; -char *malloc(); -char *decr(); -unsigned long crc(); - -/* We need to get a little tricky to avoid strings */ -#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+'%') diff --git a/adventure/init.c b/adventure/init.c index 6f176132..11c3b0e7 100644 --- a/adventure/init.c +++ b/adventure/init.c @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.4 1996/05/21 21:53:05 mrg Exp $ */ +/* $NetBSD: init.c,v 1.5 1997/08/11 14:06:14 christos Exp $ */ /*- * Copyright (c) 1993 @@ -38,11 +38,12 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 6/2/93"; #else -static char rcsid[] = "$NetBSD: init.c,v 1.4 1996/05/21 21:53:05 mrg Exp $"; +__RCSID("$NetBSD: init.c,v 1.5 1997/08/11 14:06:14 christos Exp $"); #endif #endif /* not lint */ @@ -51,7 +52,10 @@ static char rcsid[] = "$NetBSD: init.c,v 1.4 1996/05/21 21:53:05 mrg Exp $"; #include <sys/types.h> #include <signal.h> #include <stdio.h> +#include <stdlib.h> +#include <unistd.h> #include "hdr.h" +#include "extern.h" int blklin = TRUE; @@ -59,6 +63,7 @@ int setbit[16] = {1,2,4,010,020,040,0100,0200,0400,01000,02000,04000, 010000,020000,040000,0100000}; +void init(command) /* everything for 1st time run */ char *command; /* command we were called with */ { @@ -81,6 +86,7 @@ char a,b,c,d,e; return buf; } +void linkdata() /* secondary data manipulation */ { register int i,j; @@ -108,67 +114,67 @@ linkdata() /* secondary data manipulation */ } /* define mnemonics */ - keys = vocab(DECR(k,e,y,s,\0), 1); - lamp = vocab(DECR(l,a,m,p,\0), 1); - grate = vocab(DECR(g,r,a,t,e), 1); - cage = vocab(DECR(c,a,g,e,\0),1); - rod = vocab(DECR(r,o,d,\0,\0),1); + keys = vocab(DECR('k','e','y','s','\0'), 1, 0); + lamp = vocab(DECR('l','a','m','p','\0'), 1, 0); + grate = vocab(DECR('g','r','a','t','e'), 1, 0); + cage = vocab(DECR('c','a','g','e','\0'),1, 0); + rod = vocab(DECR('r','o','d','\0','\0'),1, 0); rod2=rod+1; - steps=vocab(DECR(s,t,e,p,s),1); - bird = vocab(DECR(b,i,r,d,\0),1); - door = vocab(DECR(d,o,o,r,\0),1); - pillow= vocab(DECR(p,i,l,l,o), 1); - snake = vocab(DECR(s,n,a,k,e), 1); - fissur= vocab(DECR(f,i,s,s,u), 1); - tablet= vocab(DECR(t,a,b,l,e), 1); - clam = vocab(DECR(c,l,a,m,\0),1); - oyster= vocab(DECR(o,y,s,t,e), 1); - magzin= vocab(DECR(m,a,g,a,z), 1); - dwarf = vocab(DECR(d,w,a,r,f), 1); - knife = vocab(DECR(k,n,i,f,e), 1); - food = vocab(DECR(f,o,o,d,\0),1); - bottle= vocab(DECR(b,o,t,t,l), 1); - water = vocab(DECR(w,a,t,e,r), 1); - oil = vocab(DECR(o,i,l,\0,\0),1); - plant = vocab(DECR(p,l,a,n,t), 1); + steps=vocab(DECR('s','t','e','p','s'),1, 0); + bird = vocab(DECR('b','i','r','d','\0'),1, 0); + door = vocab(DECR('d','o','o','r','\0'),1, 0); + pillow= vocab(DECR('p','i','l','l','o'), 1, 0); + snake = vocab(DECR('s','n','a','k','e'), 1, 0); + fissur= vocab(DECR('f','i','s','s','u'), 1, 0); + tablet= vocab(DECR('t','a','b','l','e'), 1, 0); + clam = vocab(DECR('c','l','a','m','\0'),1, 0); + oyster= vocab(DECR('o','y','s','t','e'), 1, 0); + magzin= vocab(DECR('m','a','g','a','z'), 1, 0); + dwarf = vocab(DECR('d','w','a','r','f'), 1, 0); + knife = vocab(DECR('k','n','i','f','e'), 1, 0); + food = vocab(DECR('f','o','o','d','\0'),1, 0); + bottle= vocab(DECR('b','o','t','t','l'), 1, 0); + water = vocab(DECR('w','a','t','e','r'), 1, 0); + oil = vocab(DECR('o','i','l','\0','\0'),1, 0); + plant = vocab(DECR('p','l','a','n','t'), 1, 0); plant2=plant+1; - axe = vocab(DECR(a,x,e,\0,\0),1); - mirror= vocab(DECR(m,i,r,r,o), 1); - dragon= vocab(DECR(d,r,a,g,o), 1); - chasm = vocab(DECR(c,h,a,s,m), 1); - troll = vocab(DECR(t,r,o,l,l), 1); + axe = vocab(DECR('a','x','e','\0','\0'),1, 0); + mirror= vocab(DECR('m','i','r','r','o'), 1, 0); + dragon= vocab(DECR('d','r','a','g','o'), 1, 0); + chasm = vocab(DECR('c','h','a','s','m'), 1, 0); + troll = vocab(DECR('t','r','o','l','l'), 1, 0); troll2=troll+1; - bear = vocab(DECR(b,e,a,r,\0),1); - messag= vocab(DECR(m,e,s,s,a), 1); - vend = vocab(DECR(v,e,n,d,i), 1); - batter= vocab(DECR(b,a,t,t,e), 1); - - nugget= vocab(DECR(g,o,l,d,\0),1); - coins = vocab(DECR(c,o,i,n,s), 1); - chest = vocab(DECR(c,h,e,s,t), 1); - eggs = vocab(DECR(e,g,g,s,\0),1); - tridnt= vocab(DECR(t,r,i,d,e), 1); - vase = vocab(DECR(v,a,s,e,\0),1); - emrald= vocab(DECR(e,m,e,r,a), 1); - pyram = vocab(DECR(p,y,r,a,m), 1); - pearl = vocab(DECR(p,e,a,r,l), 1); - rug = vocab(DECR(r,u,g,\0,\0),1); - chain = vocab(DECR(c,h,a,i,n), 1); - - back = vocab(DECR(b,a,c,k,\0),0); - look = vocab(DECR(l,o,o,k,\0),0); - cave = vocab(DECR(c,a,v,e,\0),0); - null = vocab(DECR(n,u,l,l,\0),0); - entrnc= vocab(DECR(e,n,t,r,a), 0); - dprssn= vocab(DECR(d,e,p,r,e), 0); - enter = vocab(DECR(e,n,t,e,r), 0); - - pour = vocab(DECR(p,o,u,r,\0), 2); - say = vocab(DECR(s,a,y,\0,\0),2); - lock = vocab(DECR(l,o,c,k,\0),2); - throw = vocab(DECR(t,h,r,o,w), 2); - find = vocab(DECR(f,i,n,d,\0),2); - invent= vocab(DECR(i,n,v,e,n), 2); + bear = vocab(DECR('b','e','a','r','\0'),1, 0); + messag= vocab(DECR('m','e','s','s','a'), 1, 0); + vend = vocab(DECR('v','e','n','d','i'), 1, 0); + batter= vocab(DECR('b','a','t','t','e'), 1, 0); + + nugget= vocab(DECR('g','o','l','d','\0'),1, 0); + coins = vocab(DECR('c','o','i','n','s'), 1, 0); + chest = vocab(DECR('c','h','e','s','t'), 1, 0); + eggs = vocab(DECR('e','g','g','s','\0'),1, 0); + tridnt= vocab(DECR('t','r','i','d','e'), 1, 0); + vase = vocab(DECR('v','a','s','e','\0'),1, 0); + emrald= vocab(DECR('e','m','e','r','a'), 1, 0); + pyram = vocab(DECR('p','y','r','a','m'), 1, 0); + pearl = vocab(DECR('p','e','a','r','l'), 1, 0); + rug = vocab(DECR('r','u','g','\0','\0'),1, 0); + chain = vocab(DECR('c','h','a','i','n'), 1, 0); + + back = vocab(DECR('b','a','c','k','\0'),0, 0); + look = vocab(DECR('l','o','o','k','\0'),0, 0); + cave = vocab(DECR('c','a','v','e','\0'),0, 0); + null = vocab(DECR('n','u','l','l','\0'),0, 0); + entrnc= vocab(DECR('e','n','t','r','a'), 0, 0); + dprssn= vocab(DECR('d','e','p','r','e'), 0, 0); + enter = vocab(DECR('e','n','t','e','r'), 0, 0); + + pour = vocab(DECR('p','o','u','r','\0'), 2, 0); + say = vocab(DECR('s','a','y','\0','\0'),2, 0); + lock = vocab(DECR('l','o','c','k','\0'),2, 0); + throw = vocab(DECR('t','h','r','o','w'), 2, 0); + find = vocab(DECR('f','i','n','d','\0'),2, 0); + invent= vocab(DECR('i','n','v','e','n'), 2, 0); /* initialize dwarves */ chloc=114; @@ -202,19 +208,22 @@ linkdata() /* secondary data manipulation */ -trapdel() /* come here if he hits a del */ +void +trapdel(n) /* come here if he hits a del */ + int n; { delhit++; /* main checks, treats as QUIT */ signal(SIGINT,trapdel); /* catch subsequent DELs */ } +void startup() { - time_t time(); - demo=Start(0); srand((int)(time((time_t *)NULL))); /* random seed */ - /* srand(371); /* non-random seed */ +#if 0 + srand(371); /* non-random seed */ +#endif hinted[3]=yes(65,1,0); newloc=1; delhit = 0; diff --git a/adventure/io.c b/adventure/io.c index 86f0c850..01d725c9 100644 --- a/adventure/io.c +++ b/adventure/io.c @@ -1,4 +1,4 @@ -/* $NetBSD: io.c,v 1.3 1995/04/24 12:21:37 cgd Exp $ */ +/* $NetBSD: io.c,v 1.4 1997/08/11 14:06:15 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -38,21 +38,25 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: io.c,v 1.3 1995/04/24 12:21:37 cgd Exp $"; +__RCSID("$NetBSD: io.c,v 1.4 1997/08/11 14:06:15 christos Exp $"); #endif #endif /* not lint */ /* Re-coding of advent in C: file i/o and user i/o */ -#include "hdr.h" #include <stdio.h> #include <string.h> +#include <stdlib.h> +#include "hdr.h" +#include "extern.h" +void getin(wrd1,wrd2) /* get command from user */ char **wrd1,**wrd2; /* no prompt, usually */ { register char *s; @@ -95,7 +99,7 @@ char **wrd1,**wrd2; /* no prompt, usually */ } } - +int confirm(mesg) /* confirm irreversible action */ char *mesg; { register int result; @@ -107,9 +111,10 @@ char *mesg; return(result); } +int yes(x,y,z) /* confirm with rspeak */ int x,y,z; -{ register int result; +{ register int result = TRUE; /* pacify gcc */ register char ch; for (;;) { rspeak(x); /* tell him what we want*/ @@ -125,9 +130,10 @@ int x,y,z; return(result); } +int yesm(x,y,z) /* confirm with mspeak */ int x,y,z; -{ register int result; +{ register int result = TRUE; /* pacify gcc */ register char ch; for (;;) { mspeak(x); /* tell him what we want*/ @@ -152,6 +158,7 @@ int outsw = 0; /* putting stuff to data file? */ char iotape[] = "Ax3F'\003tt$8h\315qer*h\017nGKrX\207:!l"; char *tape = iotape; /* pointer to encryption tape */ +int next() /* next virtual char, bump adr */ { int ch; @@ -167,6 +174,7 @@ next() /* next virtual char, bump adr */ char breakch; /* tell which char ended rnum */ +void rdata() /* "read" data from virtual file*/ { register int sect; register char ch; @@ -237,6 +245,7 @@ rdata() /* "read" data from virtual file*/ char nbf[12]; +int rnum() /* read initial location num */ { register char *s; tape = iotape; /* restart encryption tape */ @@ -251,12 +260,11 @@ rnum() /* read initial location num */ char *seekhere; +void rdesc(sect) /* read description-format msgs */ int sect; -{ register char *s,*t; - register int locc; - char *seekstart, *maystart, *adrstart; - char *entry; +{ register int locc; + char *seekstart, *maystart; seekhere = inptr; /* Where are we in virtual file?*/ outsw=1; /* these msgs go into tmp file */ @@ -318,13 +326,14 @@ int sect; } } - +void rtrav() /* read travel table */ { register int locc; - register struct travlist *t; + register struct travlist *t = NULL; register char *s; char buf[12]; - int len,m,n,entries; + int len,m,n,entries = 0; + for (oldloc= -1;;) /* get another line */ { if ((locc=rnum())!=oldloc && oldloc>=0) /* end of entry */ { @@ -339,7 +348,7 @@ rtrav() /* read travel table */ entries=0; oldloc=locc; } - for (s=buf;; *s++) /* get the newloc number /ASCII */ + for (s=buf;; s++) /* get the newloc number /ASCII */ if ((*s=next())==TAB || *s==LF) break; *s=0; len=length(buf)-1; /* quad long number handling */ @@ -365,6 +374,7 @@ rtrav() /* read travel table */ #ifdef DEBUG +void twrite(loq) /* travel options from this loc */ int loq; { register struct travlist *t; @@ -383,8 +393,9 @@ int loq; } } -#endif DEBUG +#endif /* DEBUG */ +void rvoc() { register char *s; /* read the vocabulary */ register int index; @@ -405,6 +416,7 @@ rvoc() } +void rlocs() /* initial object locations */ { for (;;) { if ((obj=rnum())<0) break; @@ -415,6 +427,7 @@ rlocs() /* initial object locations */ } } +void rdflt() /* default verb messages */ { for (;;) { if ((verb=rnum())<0) break; @@ -422,6 +435,7 @@ rdflt() /* default verb messages */ } } +void rliq() /* liquid assets &c: cond bits */ { register int bitnum; for (;;) /* read new bit list */ @@ -433,6 +447,7 @@ rliq() /* liquid assets &c: cond bits */ } } +void rhints() { register int hintnum,i; hntmax=0; @@ -445,18 +460,21 @@ rhints() } +void rspeak(msg) int msg; { if (msg!=0) speak(&rtext[msg]); } +void mspeak(msg) int msg; { if (msg!=0) speak(&mtext[msg]); } +void speak(msg) /* read, decrypt, and print a message (not ptext) */ struct text *msg;/* msg is a pointer to seek address and length of mess */ { @@ -481,6 +499,7 @@ struct text *msg;/* msg is a pointer to seek address and length of mess */ } +void pspeak(m,skip) /* read, decrypt an print a ptext message */ int m; /* msg is the number of all the p msgs for this place */ int skip; /* assumes object 1 doesn't have prop 1, obj 2 no prop 2 &c*/ diff --git a/adventure/main.c b/adventure/main.c index 17b008b0..e5d12126 100644 --- a/adventure/main.c +++ b/adventure/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.5 1996/05/21 21:53:09 mrg Exp $ */ +/* $NetBSD: main.c,v 1.6 1997/08/11 14:06:16 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -38,17 +38,17 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; +__COPYRIGHT("@(#) Copyright (c) 1991, 1993\n\ + The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/2/93"; #else -static char rcsid[] = "$NetBSD: main.c,v 1.5 1996/05/21 21:53:09 mrg Exp $"; +__RCSID("$NetBSD: main.c,v 1.6 1997/08/11 14:06:16 christos Exp $"); #endif #endif /* not lint */ @@ -57,8 +57,11 @@ static char rcsid[] = "$NetBSD: main.c,v 1.5 1996/05/21 21:53:09 mrg Exp $"; #include <sys/file.h> #include <signal.h> #include <stdio.h> +#include <unistd.h> #include "hdr.h" +#include "extern.h" +int main(argc,argv) int argc; char **argv; @@ -66,13 +69,12 @@ char **argv; register int i; int rval,ll; struct text *kk; - extern trapdel(); /* adventure doesn't need setuid-ness, so, just get rid of it */ if (setuid(getuid()) < 0) perror("setuid"); - init(); /* Initialize everything */ + init(NULL); /* Initialize everything */ signal(SIGINT,trapdel); if (argc > 1) /* Restore file specified */ @@ -117,7 +119,10 @@ char **argv; } kk = &rtext[16]; } - l2001: if (toting(bear)) rspeak(141); /* 2001 */ +#if 0 + l2001: +#endif + if (toting(bear)) rspeak(141); /* 2001 */ speak(kk); k=1; if (forced(loc)) @@ -125,7 +130,7 @@ char **argv; if (loc==33 && pct(25)&&!closng) rspeak(8); if (!dark(0)) { abb[loc]++; - for (i=atloc[loc]; i!=0; i=link[i]) /*2004 */ + for (i=atloc[loc]; i!=0; i=links[i]) /*2004 */ { obj=i; if (obj>100) obj -= 100; if (obj==steps && toting(nugget)) continue; @@ -222,11 +227,11 @@ char **argv; if ((!weq(wd1,"water")&&!weq(wd1,"oil")) || (!weq(wd2,"plant")&&!weq(wd2,"door"))) goto l2610; - if (at(vocab(wd2,1))) copystr("pour",wd2); + if (at(vocab(wd2,1,0))) copystr("pour",wd2); l2610: if (weq(wd1,"west")) if (++iwest==10) rspeak(17); - l2630: i=vocab(wd1,-1); + l2630: i=vocab(wd1,-1,0); if (i== -1) { spk=60; /* 3000 */ if (pct(20)) spk=61; @@ -266,10 +271,12 @@ char **argv; if (*wd2!=0 && verb!=say) goto l2800; if (verb==say) obj= *wd2; if (obj!=0) goto l4090; +#if 0 l4080: +#endif switch(verb) { case 1: /* take = 8010 */ - if (atloc[loc]==0||link[atloc[loc]]!=0) goto l8000; + if (atloc[loc]==0||links[atloc[loc]]!=0) goto l8000; for (i=1; i<=5; i++) if (dloc[i]==loc&&dflag>=2) goto l8000; obj=atloc[loc]; @@ -332,7 +339,7 @@ char **argv; if (gaveup) done(2); goto l2012; case 25: /* foo: 8250 */ - k=vocab(wd1,3); + k=vocab(wd1,3,0); spk=42; if (foobar==1-k) goto l8252; if (foobar!=0) spk=151; @@ -397,7 +404,10 @@ char **argv; case 2012: goto l2012; default: bug(105); } - l9030: case 3: +#if 0 + l9030: +#endif + case 3: switch(trsay()) { case 2012: goto l2012; case 2630: goto l2630; @@ -536,7 +546,10 @@ char **argv; ||!closed) goto l2011; hinted[2]=yes(192,193,54); goto l2012; - l9280: case 28: /* break */ +#if 0 + l9280: +#endif + case 28: /* break */ if (obj==mirror) spk=148; if (obj==vase&&prop[vase]==0) { spk=198; @@ -548,8 +561,10 @@ char **argv; if (obj!=mirror||!closed) goto l2011; rspeak(197); done(3); - - l9290: case 29: /* wake */ +#if 0 + l9290: +#endif + case 29: /* wake */ if (obj!=dwarf||!closed) goto l2011; rspeak(199); done(3); diff --git a/adventure/save.c b/adventure/save.c index e748ad2e..75b45184 100644 --- a/adventure/save.c +++ b/adventure/save.c @@ -1,4 +1,4 @@ -/* $NetBSD: save.c,v 1.2 1995/03/21 12:05:08 cgd Exp $ */ +/* $NetBSD: save.c,v 1.3 1997/08/11 14:06:17 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -38,16 +38,19 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: save.c,v 1.2 1995/03/21 12:05:08 cgd Exp $"; +__RCSID("$NetBSD: save.c,v 1.3 1997/08/11 14:06:17 christos Exp $"); #endif #endif /* not lint */ #include <stdio.h> +#include <stdlib.h> #include "hdr.h" +#include "extern.h" struct savestruct { @@ -57,70 +60,71 @@ struct savestruct struct savestruct save_array[] = { - &abbnum, sizeof(abbnum), - &attack, sizeof(attack), - &blklin, sizeof(blklin), - &bonus, sizeof(bonus), - &chloc, sizeof(chloc), - &chloc2, sizeof(chloc2), - &clock1, sizeof(clock1), - &clock2, sizeof(clock2), - &closed, sizeof(closed), - &closng, sizeof(closng), - &daltlc, sizeof(daltlc), - &demo, sizeof(demo), - &detail, sizeof(detail), - &dflag, sizeof(dflag), - &dkill, sizeof(dkill), - &dtotal, sizeof(dtotal), - &foobar, sizeof(foobar), - &gaveup, sizeof(gaveup), - &holdng, sizeof(holdng), - &iwest, sizeof(iwest), - &k, sizeof(k), - &k2, sizeof(k2), - &knfloc, sizeof(knfloc), - &kq, sizeof(kq), - &latncy, sizeof(latncy), - &limit, sizeof(limit), - &lmwarn, sizeof(lmwarn), - &loc, sizeof(loc), - &maxdie, sizeof(maxdie), - &mxscor, sizeof(mxscor), - &newloc, sizeof(newloc), - &numdie, sizeof(numdie), - &obj, sizeof(obj), - &oldlc2, sizeof(oldlc2), - &oldloc, sizeof(oldloc), - &panic, sizeof(panic), - &saved, sizeof(saved), - &savet, sizeof(savet), - &scorng, sizeof(scorng), - &spk, sizeof(spk), - &stick, sizeof(stick), - &tally, sizeof(tally), - &tally2, sizeof(tally2), - &tkk, sizeof(tkk), - &turns, sizeof(turns), - &verb, sizeof(verb), - &wd1, sizeof(wd1), - &wd2, sizeof(wd2), - &wzdark, sizeof(wzdark), - &yea, sizeof(yea), - atloc, sizeof(atloc), - dloc, sizeof(dloc), - dseen, sizeof(dseen), - fixed, sizeof(fixed), - hinted, sizeof(hinted), - link, sizeof(link), - odloc, sizeof(odloc), - place, sizeof(place), - prop, sizeof(prop), - tk, sizeof(tk), + { &abbnum, sizeof(abbnum) }, + { &attack, sizeof(attack) }, + { &blklin, sizeof(blklin) }, + { &bonus, sizeof(bonus) }, + { &chloc, sizeof(chloc) }, + { &chloc2, sizeof(chloc2) }, + { &clock1, sizeof(clock1) }, + { &clock2, sizeof(clock2) }, + { &closed, sizeof(closed) }, + { &closng, sizeof(closng) }, + { &daltlc, sizeof(daltlc) }, + { &demo, sizeof(demo) }, + { &detail, sizeof(detail) }, + { &dflag, sizeof(dflag) }, + { &dkill, sizeof(dkill) }, + { &dtotal, sizeof(dtotal) }, + { &foobar, sizeof(foobar) }, + { &gaveup, sizeof(gaveup) }, + { &holdng, sizeof(holdng) }, + { &iwest, sizeof(iwest) }, + { &k, sizeof(k) }, + { &k2, sizeof(k2) }, + { &knfloc, sizeof(knfloc) }, + { &kq, sizeof(kq) }, + { &latncy, sizeof(latncy) }, + { &limit, sizeof(limit) }, + { &lmwarn, sizeof(lmwarn) }, + { &loc, sizeof(loc) }, + { &maxdie, sizeof(maxdie) }, + { &mxscor, sizeof(mxscor) }, + { &newloc, sizeof(newloc) }, + { &numdie, sizeof(numdie) }, + { &obj, sizeof(obj) }, + { &oldlc2, sizeof(oldlc2) }, + { &oldloc, sizeof(oldloc) }, + { &panic, sizeof(panic) }, + { &saved, sizeof(saved) }, + { &savet, sizeof(savet) }, + { &scorng, sizeof(scorng) }, + { &spk, sizeof(spk) }, + { &stick, sizeof(stick) }, + { &tally, sizeof(tally) }, + { &tally2, sizeof(tally2) }, + { &tkk, sizeof(tkk) }, + { &turns, sizeof(turns) }, + { &verb, sizeof(verb) }, + { &wd1, sizeof(wd1) }, + { &wd2, sizeof(wd2) }, + { &wzdark, sizeof(wzdark) }, + { &yea, sizeof(yea) }, + { atloc, sizeof(atloc) }, + { dloc, sizeof(dloc) }, + { dseen, sizeof(dseen) }, + { fixed, sizeof(fixed) }, + { hinted, sizeof(hinted) }, + { links, sizeof(links) }, + { odloc, sizeof(odloc) }, + { place, sizeof(place) }, + { prop, sizeof(prop) }, + { tk, sizeof(tk) }, - NULL, 0 + { NULL, 0 } }; +int save(outfile) /* Two passes on data: first to get checksum, second */ char *outfile; /* to output the data using checksum to start random #s */ { @@ -153,13 +157,14 @@ char *outfile; /* to output the data using checksum to start random #s */ return 0; } +int restore(infile) char *infile; { FILE *in; struct savestruct *p; char *s; - long sum, cksum; + long sum, cksum = 0; int i; if ((in = fopen(infile, "rb")) == NULL) diff --git a/adventure/subr.c b/adventure/subr.c index 9ee6d6f7..758527a8 100644 --- a/adventure/subr.c +++ b/adventure/subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: subr.c,v 1.2 1995/03/21 12:05:11 cgd Exp $ */ +/* $NetBSD: subr.c,v 1.3 1997/08/11 14:06:17 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -38,42 +38,50 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)subr.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: subr.c,v 1.2 1995/03/21 12:05:11 cgd Exp $"; +__RCSID("$NetBSD: subr.c,v 1.3 1997/08/11 14:06:17 christos Exp $"); #endif #endif /* not lint */ /* Re-coding of advent in C: subroutines from main */ -# include "hdr.h" +#include <stdio.h> +#include "hdr.h" +#include "extern.h" /* Statement functions */ +int toting(objj) int objj; { if (place[objj] == -1) return(TRUE); else return(FALSE); } +int here(objj) int objj; { if (place[objj]==loc || toting(objj)) return(TRUE); else return(FALSE); } +int at(objj) int objj; { if (place[objj]==loc || fixed[objj]==loc) return(TRUE); else return (FALSE); } +int liq2(pbotl) int pbotl; { return((1-pbotl)*water+(pbotl/2)*(water+oil)); } +int liq(foo) { register int i; i=prop[bottle]; @@ -81,6 +89,7 @@ liq(foo) else return(liq2(-1-i)); } +int liqloc(locc) /* may want to clean this one up a bit */ int locc; { register int i,j,l; @@ -91,24 +100,28 @@ int locc; return(liq2(j*l+1)); } +int bitset(l,n) int l,n; { if (cond[l] & setbit[n]) return(TRUE); return(FALSE); } +int forced(locc) int locc; { if (cond[locc]==2) return(TRUE); return(FALSE); } +int dark(foo) { if ((cond[loc]%2)==0 && (prop[lamp]==0 || !here(lamp))) return(TRUE); return(FALSE); } +int pct(n) int n; { if (ran(100)<n) return(TRUE); @@ -116,6 +129,7 @@ int n; } +int fdwarf() /* 71 */ { register int i,j; register struct travlist *kk; @@ -234,6 +248,7 @@ fdwarf() /* 71 */ } +int march() /* label 8 */ { register int ll1,ll2; @@ -299,6 +314,7 @@ l12: /* alternative to probability move */ +int mback() /* 20 */ { register struct travlist *tk2,*j; register int ll; @@ -333,6 +349,7 @@ mback() /* 20 */ } +int specials() /* 30000 */ { switch(newloc -= 300) { case 1: /* 30100 */ @@ -351,6 +368,7 @@ specials() /* 30000 */ } +int trbridge() /* 30300 */ { if (prop[troll]==1) { pspeak(troll,1); @@ -378,6 +396,7 @@ trbridge() /* 30300 */ } +int badmove() /* 20 */ { spk=12; if (k>=43 && k<=50) spk=9; @@ -391,6 +410,7 @@ badmove() /* 20 */ return(2); } +int bug(n) int n; { printf("Please tell jim@rand.org that fatal bug %d happened.\n",n); @@ -398,6 +418,7 @@ int n; } +int checkhints() /* 2600 &c */ { register int hint; for (hint=4; hint<=hntmax; hint++) @@ -433,13 +454,15 @@ checkhints() /* 2600 &c */ hinted[hint]=yes(175,hints[hint][4],54); l40020: hintlc[hint]=0; } + return 0; } +int trsay() /* 9030 */ { register int i; if (*wd2!=0) copystr(wd2,wd1); - i=vocab(wd1,-1); + i=vocab(wd1,-1,0); if (i==62||i==65||i==71||i==2025) { *wd2=0; obj=0; @@ -450,9 +473,9 @@ trsay() /* 9030 */ } +int trtake() /* 9010 */ -{ register int i; - if (toting(obj)) return(2011); /* 9010 */ +{ if (toting(obj)) return(2011); /* 9010 */ spk=25; if (obj==plant&&prop[plant]<=0) spk=115; if (obj==bear&&prop[bear]==1) spk=169; @@ -495,6 +518,7 @@ l9014: if ((obj==bird||obj==cage)&&prop[bird]!=0) } +int dropper() /* 9021 */ { k=liq(0); if (k==obj) obj=bottle; @@ -505,6 +529,7 @@ dropper() /* 9021 */ return(2012); } +int trdrop() /* 9020 */ { if (toting(rod2)&&obj==rod&&!toting(rod)) obj=rod2; @@ -551,6 +576,7 @@ trdrop() /* 9020 */ } +int tropen() /* 9040 */ { if (obj==clam||obj==oyster) { k=0; /* 9046 */ @@ -606,6 +632,7 @@ tropen() /* 9040 */ } +int trkill() /* 9120 */ { register int i; for (i=1; i<=5; i++) @@ -663,6 +690,7 @@ trkill() /* 9120 */ } +int trtoss() /* 9170: throw */ { register int i; if (toting(rod2)&&obj==rod&&!toting(rod)) obj=rod2; @@ -717,6 +745,7 @@ trtoss() /* 9170: throw */ } +int trfeed() /* 9210 */ { if (obj==bird) { spk=100; @@ -755,6 +784,7 @@ trfeed() /* 9210 */ } +int trfill() /* 9220 */ { if (obj==vase) { spk=29; @@ -779,6 +809,7 @@ trfill() /* 9220 */ } +int closing() /* 10000 */ { register int i; @@ -804,6 +835,7 @@ closing() /* 10000 */ } +int caveclose() /* 11000 */ { register int i; prop[bottle]=put(bottle,115,1); diff --git a/adventure/vocab.c b/adventure/vocab.c index f6ae1656..864a6f22 100644 --- a/adventure/vocab.c +++ b/adventure/vocab.c @@ -1,4 +1,4 @@ -/* $NetBSD: vocab.c,v 1.2 1995/03/21 12:05:13 cgd Exp $ */ +/* $NetBSD: vocab.c,v 1.3 1997/08/11 14:06:18 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -38,23 +38,29 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)vocab.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: vocab.c,v 1.2 1995/03/21 12:05:13 cgd Exp $"; +__RCSID("$NetBSD: vocab.c,v 1.3 1997/08/11 14:06:18 christos Exp $"); #endif #endif /* not lint */ /* Re-coding of advent in C: data structure routines */ -# include "hdr.h" +#include <stdio.h> +#include <stdlib.h> +#include "hdr.h" +#include "extern.h" +void dstroy(object) int object; { move(object,0); } +void juggle(object) int object; { register int i,j; @@ -66,6 +72,7 @@ int object; } +void move(object,where) int object,where; { register int from; @@ -78,13 +85,14 @@ int object,where; drop(object,where); } - +int put(object,where,pval) int object,where,pval; { move(object,where); return(-1-pval); } +void carry(object,where) int object,where; { register int temp; @@ -95,14 +103,15 @@ int object,where; holdng++; } if (atloc[where]==object) - { atloc[where]=link[object]; + { atloc[where]=links[object]; return; } - for (temp=atloc[where]; link[temp]!=object; temp=link[temp]); - link[temp]=link[object]; + for (temp=atloc[where]; links[temp]!=object; temp=links[temp]); + links[temp]=links[object]; } +void drop(object,where) int object,where; { if (object>100) fixed[object-100]=where; @@ -111,11 +120,11 @@ int object,where; place[object]=where; } if (where<=0) return; - link[object]=atloc[where]; + links[object]=atloc[where]; atloc[where]=object; } - +int vocab(word,type,value) /* look up or store a word */ char *word; int type; /* -2 for store, -1 for user word, >=0 for canned lookup*/ @@ -174,7 +183,7 @@ int value; /* used for storing only */ } } - +void copystr(w1,w2) /* copy one string to another */ char *w1,*w2; { register char *s,*t; @@ -183,6 +192,7 @@ char *w1,*w2; *t=0; } +int weq(w1,w2) /* compare words */ char *w1,*w2; /* w1 is user, w2 is system */ { register char *s,*t; @@ -197,7 +207,7 @@ char *w1,*w2; /* w1 is user, w2 is system */ return(TRUE); } - +int length(str) /* includes 0 at end */ char *str; { register char *s; @@ -206,6 +216,7 @@ char *str; return(n+1); } +void prht() /* print hash table */ { register int i,j,l; char *c; diff --git a/adventure/wizard.c b/adventure/wizard.c index aee942e2..59460f3b 100644 --- a/adventure/wizard.c +++ b/adventure/wizard.c @@ -1,4 +1,4 @@ -/* $NetBSD: wizard.c,v 1.3 1995/04/24 12:21:41 cgd Exp $ */ +/* $NetBSD: wizard.c,v 1.4 1997/08/11 14:06:19 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -38,41 +38,51 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)wizard.c 8.1 (Berkeley) 6/2/93"; #else -static char rcsid[] = "$NetBSD: wizard.c,v 1.3 1995/04/24 12:21:41 cgd Exp $"; +__RCSID("$NetBSD: wizard.c,v 1.4 1997/08/11 14:06:19 christos Exp $"); #endif #endif /* not lint */ /* Re-coding of advent in C: privileged operations */ -# include "hdr.h" +#include <stdio.h> #include <string.h> +#include <stdlib.h> +#include <time.h> +#include "hdr.h" +#include "extern.h" +void datime(d,t) int *d,*t; -{ int tvec[2],*tptr; - int *localtime(); +{ time_t tvec; + struct tm *tptr; - time(tvec); - tptr=localtime(tvec); - *d=tptr[7]+365*(tptr[5]-77); /* day since 1977 (mod leap) */ + time(&tvec); + tptr=localtime(&tvec); + /* day since 1977 (mod leap) */ + *d=tptr->tm_yday +365*(tptr->tm_year-77); /* bug: this will overflow in the year 2066 AD */ /* it will be attributed to Wm the C's millenial celebration */ - *t=tptr[2]*60+tptr[1]; /* and minutes since midnite */ + /* and minutes since midnite */ + *t=tptr->tm_hour*60+tptr->tm_min; } /* pretty painless */ char magic[6]; +void poof() { - strcpy(magic, DECR(d,w,a,r,f)); + strcpy(magic, DECR('d','w','a','r','f')); latncy = 45; } +int Start(n) { int d,t,delay; @@ -98,9 +108,9 @@ Start(n) return(FALSE); } +int wizard() /* not as complex as advent/10 (for now) */ -{ register int wiz; - char *word,*x; +{ char *word,*x; if (!yesm(16,0,7)) return(FALSE); mspeak(17); getin(&word,&x); @@ -112,12 +122,11 @@ wizard() /* not as complex as advent/10 (for now) */ return(TRUE); } +void ciao(cmdfile) char *cmdfile; { register char *c; - register int outfd, size; - char fname[80], buf[512]; - extern unsigned filesize; + char fname[80]; printf("What would you like to call the saved version?\n"); for (c=fname;; c++) @@ -130,10 +139,11 @@ char *cmdfile; } +int ran(range) int range; { - long rand(), i; + long i; i = rand() % range; return(i); |