1 /*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * The game adventure was originally written in Fortran by Will Crowther 6 * and Don Woods. It was later translated to C and enhanced by Jim 7 * Gillogly. This code is derived from software contributed to Berkeley 8 * by Jim Gillogly at The Rand Corporation. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. Neither the name of the University nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * @(#)hdr.h 8.1 (Berkeley) 5/31/93 35 */ 36 37 /* ADVENTURE -- Jim Gillogly, Jul 1977 38 * This program is a re-write of ADVENT, written in FORTRAN mostly by 39 * Don Woods of SAIL. In most places it is as nearly identical to the 40 * original as possible given the language and word-size differences. 41 * A few places, such as the message arrays and travel arrays were changed 42 * to reflect the smaller core size and word size. The labels of the 43 * original are reflected in this version, so that the comments of the 44 * fortran are still applicable here. 45 * 46 * The data file distributed with the fortran source is assumed to be called 47 * "glorkz" in the directory where the program is first run. 48 * 49 * The original FORTRAN version can be found at 50 * <URL:ftp://ftp.gmd.de/if-archive/games/source/advent-original.tar.gz>. 51 * 52 * $FreeBSD: src/games/adventure/hdr.h,v 1.5.2.1 2001/03/05 11:43:11 kris Exp $ 53 * $DragonFly: src/games/adventure/hdr.h,v 1.3 2004/09/12 17:19:58 dillon Exp $ 54 */ 55 56 /* hdr.h: included by c advent files */ 57 #include <sys/types.h> 58 #include <signal.h> 59 60 int datfd; /* message file descriptor */ 61 volatile sig_atomic_t delhit; 62 int yea; 63 extern char data_file[]; /* Virtual data file */ 64 65 #define TAB 011 66 #define LF 012 67 #define FLUSHLINE do { int flushline_ch; while ((flushline_ch = getchar()) != EOF && flushline_ch != '\n'); } while (0) 68 #define FLUSHLF while (next()!=LF) 69 70 int loc, newloc, oldloc, oldlc2, wzdark, gaveup, kq, k, k2; 71 char *wd1, *wd2; /* the complete words */ 72 int verb, obj, spk; 73 extern int blklin; 74 int saved, savet, mxscor, latncy; 75 76 #define SHORT 50 /* How short is a demo game? */ 77 78 #define MAXSTR 20 /* max length of user's words */ 79 80 #define HTSIZE 512 /* max number of vocab words */ 81 struct hashtab { /* hash table for vocabulary */ 82 int val; /* word type &index (ktab) */ 83 char *atab; /* pointer to actual string */ 84 } voc[HTSIZE]; 85 86 #define SEED 1815622 /* "Encryption" seed */ 87 88 struct text { 89 char *seekadr; /* Msg start in virtual disk */ 90 int txtlen; /* length of msg starting here */ 91 }; 92 93 #define RTXSIZ 205 94 struct text rtext[RTXSIZ]; /* random text messages */ 95 96 #define MAGSIZ 35 97 struct text mtext[MAGSIZ]; /* magic messages */ 98 99 int clsses; 100 #define CLSMAX 12 101 struct text ctext[CLSMAX]; /* classes of adventurer */ 102 int cval[CLSMAX]; 103 104 struct text ptext[101]; /* object descriptions */ 105 106 #define LOCSIZ 141 /* number of locations */ 107 struct text ltext[LOCSIZ]; /* long loc description */ 108 struct text stext[LOCSIZ]; /* short loc descriptions */ 109 110 struct travlist { /* direcs & conditions of travel */ 111 struct travlist *next; /* ptr to next list entry */ 112 int conditions; /* m in writeup (newloc / 1000) */ 113 int tloc; /* n in writeup (newloc % 1000) */ 114 int tverb; /* the verb that takes you there */ 115 } *travel[LOCSIZ], *tkk; /* travel is closer to keys(...) */ 116 117 int atloc[LOCSIZ]; 118 119 int plac[101]; /* initial object placement */ 120 int fixd[101], fixed[101]; /* location fixed? */ 121 122 int actspk[35]; /* rtext msg for verb <n> */ 123 124 int cond[LOCSIZ]; /* various condition bits */ 125 126 extern int setbit[16]; /* bit defn masks 1,2,4,... */ 127 128 int hntmax; 129 int hints[20][5]; /* info on hints */ 130 int hinted[20], hintlc[20]; 131 132 int place[101], prop[101], linkx[201]; 133 int abb[LOCSIZ]; 134 135 int maxtrs, tally, tally2; /* treasure values */ 136 137 #define FALSE 0 138 #define TRUE 1 139 140 int axe, back, batter, bear, bird, bottle, /* mnemonics */ 141 cage, cave, chain, chasm, chest, clam, coins, door, dprssn, dragon, 142 dwarf, eggs, emrald, enter, entrnc, find, fissur, food, grate, invent, 143 keys, knife, lamp, lock, look, magzin, messag, mirror, nugget, null, 144 oil, oyster, pearl, pillow, plant, plant2, pour, pyram, rod, rod2, 145 rug, say, snake, spices, steps, stream, tablet, throw, tridnt, troll, 146 troll2, vase, vend, water; 147 148 int chloc, chloc2, daltlc, dflag, dloc[7], /* dwarf stuff */ 149 dseen[7], odloc[7]; 150 151 int attack, dtotal, stick, tk[21]; 152 153 int abbnum, bonus, clock1, clock2, closed, /* various flags and counters */ 154 closng, detail, dkill, foobar, holdng, iwest, knfloc, 155 lmwarn, maxdie, numdie, panic, scorng, turns; 156 157 int demo, limit; 158 159 int at(int objj); 160 int bug(int n); 161 void carry(int, int); 162 void caveclose(void); 163 void checkhints(void); 164 void ciao(void); 165 void closing(void); 166 unsigned long crc(const char *ptr, int nr); 167 void crc_start(void); 168 int dark(void); 169 void datime(int *d, int *t); 170 char *decr(const char *, const char *, const char *, const char *, const char *); 171 void die(int entry); 172 void done(int entry); 173 void drop(int object, int where); 174 void dstroy(int); 175 int fdwarf(void); 176 int forced(int locc); 177 void getin(char **wrd1, char **wrd2); 178 int here(int objj); 179 void init(void); 180 void juggle(int); 181 int liq(void); 182 int liqloc(int locc); 183 int march(void); 184 void move(int, int); 185 void mspeak(int); 186 int pct(int n); 187 void poof(void); 188 void pspeak(int m, int skip); 189 int put(int, int, int); 190 int ran(int range); 191 void rdata(void); 192 int restore(const char *infile); 193 void rspeak(int); 194 int save(const char *); 195 int score(void); 196 void speak(const struct text *); 197 int Start(void); 198 void startup(void); 199 int toting(int objj); 200 void trapdel(int sig); 201 int trdrop(void); 202 int trfeed(void); 203 int trfill(void); 204 int trkill(void); 205 int tropen(void); 206 int trsay(void); 207 int trtake(void); 208 int trtoss(void); 209 int vocab(const char *, int, int); 210 int yes(int x, int y, int z); 211 int yesm(int x, int y, int z); 212 213 /* We need to get a little tricky to avoid strings */ 214 #define DECR(a,b,c,d,e) decr(#a,#b,#c,#d,#e) 215 216 gid_t egid; 217