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