xref: /openbsd/games/adventure/hdr.h (revision d0bb6702)
1 /*	$OpenBSD: hdr.h,v 1.18 2021/01/27 01:59:39 deraadt Exp $	*/
2 /*	$NetBSD: hdr.h,v 1.2 1995/03/21 12:05:02 cgd Exp $	*/
3 
4 /*-
5  * Copyright (c) 1991, 1993
6  *	The Regents of the University of California.  All rights reserved.
7  *
8  * The game adventure was originally written in Fortran by Will Crowther
9  * and Don Woods.  It was later translated to C and enhanced by Jim
10  * Gillogly.  This code is derived from software contributed to Berkeley
11  * by Jim Gillogly at The Rand Corporation.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  *    notice, this list of conditions and the following disclaimer in the
20  *    documentation and/or other materials provided with the distribution.
21  * 3. Neither the name of the University nor the names of its contributors
22  *    may be used to endorse or promote products derived from this software
23  *    without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  *
37  *	@(#)hdr.h	8.1 (Berkeley) 5/31/93
38  */
39 
40 /*   ADVENTURE -- Jim Gillogly, Jul 1977
41  * This program is a re-write of ADVENT, written in FORTRAN mostly by
42  * Don Woods of SAIL.  In most places it is as nearly identical to the
43  * original as possible given the language and word-size differences.
44  * A few places, such as the message arrays and travel arrays were changed
45  * to reflect the smaller core size and word size.  The labels of the
46  * original are reflected in this version, so that the comments of the
47  * fortran are still applicable here.
48  *
49  * The data file distributed with the fortran source is assumed to be called
50  * "glorkz" in the directory where the program is first run.
51  */
52 
53 /* hdr.h: included by c advent files */
54 
55 #include <sys/types.h>
56 
57 #include <signal.h>
58 
59 extern int     datfd;			/* message file descriptor	*/
60 extern volatile sig_atomic_t delhit;
61 extern int     yea;
62 extern char data_file[];	/* Virtual data file		*/
63 
64 #define TAB     011
65 #define LF      012
66 #define FLUSHLINE do { int c; while ((c = getchar()) != EOF && c != '\n'); } while (0)
67 #define FLUSHLF   while (next()!=LF)
68 
69 extern int     loc, newloc, oldloc, oldlc2, wzdark, gaveup, kq, k, k2;
70 extern int     verb, obj, spk;
71 extern int blklin;
72 extern time_t  savet;
73 extern int     mxscor, latncy;
74 
75 #define SHORT 50		/* How short is a demo game?	*/
76 
77 #define MAXSTR  20		/* max length of user's words	*/
78 extern char	wd1[MAXSTR];		/* the complete words		*/
79 extern char	wd2[MAXSTR];
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 };
86 extern struct hashtab voc[HTSIZE];
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 extern struct text rtext[RTXSIZ];	/* random text messages		*/
95 
96 #define MAGSIZ  35
97 extern struct text mtext[MAGSIZ];	/* magic messages		*/
98 
99 extern int clsses;
100 #define CLSMAX  12
101 extern struct text ctext[CLSMAX];	/* classes of adventurer	*/
102 extern int cval[CLSMAX];
103 
104 extern struct text ptext[101];		/* object descriptions		*/
105 
106 #define LOCSIZ	141		/* number of locations		*/
107 extern struct text ltext[LOCSIZ];	/* long loc description		*/
108 extern 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 };
116 extern struct travlist *travel[LOCSIZ],*tkk;	/* travel is closer to keys(...)*/
117 
118 extern int atloc[LOCSIZ];
119 
120 extern int	plac[101];		/* initial object placement	*/
121 extern int	fixd[101], fixed[101];	/* location fixed?		*/
122 
123 extern int	actspk[35];		/* rtext msg for verb <n>	*/
124 
125 extern int	cond[LOCSIZ];		/* various condition bits	*/
126 
127 extern int setbit[16];		/* bit defn masks 1,2,4,...	*/
128 
129 extern int	hntmax;
130 extern int	hints[20][5];		/* info on hints		*/
131 extern int	hinted[20], hintlc[20];
132 
133 extern int	place[101], prop[101], linkx[201];
134 extern int	abb[LOCSIZ];
135 
136 extern int	maxtrs, tally, tally2;	/* treasure values		*/
137 
138 #define FALSE   0
139 #define TRUE    1
140 
141 extern int
142 	keys, lamp, grate, cage, rod, rod2, steps,	/* mnemonics */
143 	bird, door, pillow, snake, fissur, tablet, clam, oyster,
144 	magzin, dwarf, knife, food, bottle, water, oil, plant, plant2,
145 	axe, mirror, dragon, chasm, troll, troll2, bear, messag,
146 	vend, batter, nugget, coins, chest, eggs, tridnt, vase,
147 	emrald, pyram, pearl, rug, chain, spices, back, look, cave,
148 	null, entrnc, dprssn, enter, stream, pour, say, lock, throw,
149 	find, invent;
150 
151 extern int
152 	chloc, chloc2, dseen[7], dloc[7],	/* dwarf stuff	*/
153 	odloc[7], dflag, daltlc;
154 
155 extern int
156 	tk[21], stick, dtotal, attack;
157 extern int
158 	turns, lmwarn, iwest, knfloc, detail,   /* various flags & counters */
159 	abbnum, maxdie, numdie, holdng, dkill, foobar, bonus, clock1,
160 	clock2, saved, closng, panic, closed, scorng;
161 
162 extern int
163 	demo, limit;
164 
165 /* We need to get a little tricky to avoid strings */
166 #define DECR(a,b,c,d,e) decr(*#a-'+',*#b-'-',*#c-'#',*#d-'&',*#e-'%')
167