extern.h revision 1.27 1 /* $NetBSD: extern.h,v 1.27 2000/09/25 14:44:59 jsm Exp $ */
2
3 /*
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)externs.h 8.1 (Berkeley) 5/31/93
36 */
37
38 #include <ctype.h>
39 #include <err.h>
40 #include <pwd.h>
41 #include <signal.h>
42 #include <stdio.h>
43 #include <stdlib.h>
44 #include <string.h>
45 #include <time.h>
46 #include <unistd.h>
47
48 #define BITS (8 * sizeof (int))
49
50 #define OUTSIDE (position > 68 && position < 246 && position != 218)
51 #define rnd(x) (rand() % (x))
52 #define max(a,b) ((a) < (b) ? (b) : (a))
53 #define testbit(array, index) (array[index/BITS] & (1 << (index % BITS)))
54 #define setbit(array, index) (array[index/BITS] |= (1 << (index % BITS)))
55 #define clearbit(array, index) (array[index/BITS] &= ~(1 << (index % BITS)))
56
57 /* well known rooms */
58 #define FINAL 275
59 #define GARDEN 197
60 #define POOLS 126
61 #define DOCK 93
62
63 /* word types */
64 #define VERB 0
65 #define OBJECT 1
66 #define NOUNS 2
67 #define PREPS 3
68 #define ADJS 4
69 #define CONJ 5
70
71 /* words numbers */
72 #define KNIFE 0
73 #define SWORD 1
74 #define LAND 2
75 #define WOODSMAN 3
76 #define TWO_HANDED 4
77 #define CLEAVER 5
78 #define BROAD 6
79 #define MAIL 7
80 #define HELM 8
81 #define SHIELD 9
82 #define MAID 10
83 #define BODY 10
84 #define VIPER 11
85 #define LAMPON 12
86 #define SHOES 13
87 #define CYLON 14
88 #define PAJAMAS 15
89 #define ROBE 16
90 #define AMULET 17
91 #define MEDALION 18
92 #define TALISMAN 19
93 #define DEADWOOD 20
94 #define MALLET 21
95 #define LASER 22
96 #define BATHGOD 23
97 #define NORMGOD 24
98 #define GRENADE 25
99 #define CHAIN 26
100 #define ROPE 27
101 #define LEVIS 28
102 #define MACE 29
103 #define SHOVEL 30
104 #define HALBERD 31
105 #define COMPASS 32
106 #define CRASH 33
107 #define ELF 34
108 #define FOOT 35
109 #define COINS 36
110 #define MATCHES 37
111 #define MAN 38
112 #define PAPAYAS 39
113 #define PINEAPPLE 40
114 #define KIWI 41
115 #define COCONUTS 42
116 #define MANGO 43
117 #define RING 44
118 #define POTION 45
119 #define BRACELET 46
120 #define GIRL 47
121 #define GIRLTALK 48
122 #define DARK 49
123 #define TIMER 50
124 #define CHAR 53
125 #define BOMB 54
126 #define DEADGOD 55
127 #define DEADTIME 56
128 #define DEADNATIVE 57
129 #define NATIVE 58
130 #define HORSE 59
131 #define CAR 60
132 #define POT 61
133 #define BAR 62
134 #define BLOCK 63
135 #define NUMOFOBJECTS 64
136 /* non-objects below */
137 #define UP 1000
138 #define DOWN 1001
139 #define AHEAD 1002
140 #define BACK 1003
141 #define RIGHT 1004
142 #define LEFT 1005
143 #define TAKE 1006
144 #define USE 1007
145 #define LOOK 1008
146 #define QUIT 1009
147 #define NORTH 1010
148 #define SOUTH 1011
149 #define EAST 1012
150 #define WEST 1013
151 #define SU 1014
152 #define DROP 1015
153 #define TAKEOFF 1016
154 #define DRAW 1017
155 #define PUTON 1018
156 #define WEARIT 1019
157 #define PUT 1020
158 #define INVEN 1021
159 #define EVERYTHING 1022
160 #define AND 1023
161 #define KILL 1024
162 #define RAVAGE 1025
163 #define UNDRESS 1026
164 #define THROW 1027
165 #define LAUNCH 1028
166 #define LANDIT 1029
167 #define LIGHT 1030
168 #define FOLLOW 1031
169 #define KISS 1032
170 #define LOVE 1033
171 #define GIVE 1034
172 #define SMITE 1035
173 #define SHOOT 1036
174 #define ON 1037
175 #define OFF 1038
176 #define TIME 1039
177 #define SLEEP 1040
178 #define DIG 1041
179 #define EAT 1042
180 #define SWIM 1043
181 #define DRINK 1044
182 #define DOOR 1045
183 #define SAVE 1046
184 #define RIDE 1047
185 #define DRIVE 1048
186 #define SCORE 1049
187 #define BURY 1050
188 #define JUMP 1051
189 #define KICK 1052
190 #define OPEN 1053
191 #define VERBOSE 1054
192 #define BRIEF 1055
193
194 /* injuries */
195 #define ARM 6 /* broken arm */
196 #define RIBS 7 /* broken ribs */
197 #define SPINE 9 /* broken back */
198 #define SKULL 11 /* fractured skull */
199 #define INCISE 10 /* deep incisions */
200 #define NECK 12 /* broken NECK */
201 #define NUMOFINJURIES 13
202
203 /* notes */
204 #define CANTLAUNCH 0
205 #define LAUNCHED 1
206 #define CANTSEE 2
207 #define CANTMOVE 3
208 #define JINXED 4
209 #define DUG 5
210 #define NUMOFNOTES 6
211
212 /* Number of times room description shown. */
213 #define ROOMDESC 3
214
215 /* fundamental constants */
216 #define NUMOFROOMS 275
217 #define NUMOFWORDS ((NUMOFOBJECTS + BITS - 1) / BITS)
218 #define LINELENGTH 81
219
220 #define TODAY 0
221 #define TONIGHT 1
222 #define CYCLE 100
223
224 /* initial variable values */
225 #define TANKFULL 250
226 #define TORPEDOES 10
227 #define MAXWEIGHT 60
228 #define MAXCUMBER 10
229
230 /*
231 * These are flags for objects in the objflags array. OBJ_PLURAL means
232 * that the object short name is plural; OBJ_AN that it begins with a
233 * vowel sound so should be preceded by "an" instead of "a"; OBJ_PERSON
234 * that it is a living person; OBJ_NONOBJ that it is not an object (to
235 * which any game action can be applied) at all (e.g. footsteps, asteroids).
236 * Any individual object has at most one of OBJ_PERSON and OBJ_NONOBJ.
237 */
238 #define OBJ_PLURAL 1
239 #define OBJ_AN 2
240 #define OBJ_PERSON 4
241 #define OBJ_NONOBJ 8
242
243 struct room {
244 const char *name;
245 int link[8];
246 #define north link[0]
247 #define south link[1]
248 #define east link[2]
249 #define west link[3]
250 #define up link[4]
251 #define access link[5]
252 #define down link[6]
253 #define flyhere link[7]
254 const char *desc;
255 unsigned int objects[NUMOFWORDS];
256 };
257 extern struct room dayfile[];
258 extern struct room nightfile[];
259 extern struct room *location;
260
261 /* object characteristics */
262 extern const char *const objdes[NUMOFOBJECTS];
263 extern const char *const objsht[NUMOFOBJECTS];
264 extern const char *const ouch[NUMOFINJURIES];
265 extern const int objwt[NUMOFOBJECTS];
266 extern const int objcumber[NUMOFOBJECTS];
267 extern const int objflags[NUMOFOBJECTS];
268 #define is_plural_object(n) (objflags[(n)] & OBJ_PLURAL)
269 /*
270 * These macros yield words to use with objects (followed but not preceded
271 * by spaces, or with no spaces if the expansion is the empty string).
272 */
273 #define A_OR_AN(n) (objflags[(n)] & OBJ_AN ? "an " : "a ")
274 #define A_OR_AN_OR_THE(n) (is_plural_object((n)) ? "the " : A_OR_AN((n)))
275 #define A_OR_AN_OR_BLANK(n) (is_plural_object((n)) ? "" : A_OR_AN((n)))
276 #define IS_OR_ARE(n) (is_plural_object((n)) ? "are " : "is ")
277
278 /* current input line */
279 #define WORDLEN 15
280 #define NWORD 20 /* words per line */
281 extern char words[NWORD][WORDLEN];
282 extern int wordvalue[NWORD];
283 extern int wordtype[NWORD];
284 extern int wordcount, wordnumber;
285
286 /* state of the game */
287 extern int ourtime;
288 extern int position;
289 extern int direction;
290 extern int left, right, ahead, back;
291 extern int ourclock, fuel, torps;
292 extern int carrying, encumber;
293 extern int rythmn;
294 extern int followfight;
295 extern int ate;
296 extern int snooze;
297 extern int meetgirl;
298 extern int followgod;
299 extern int godready;
300 extern int win;
301 extern int wintime;
302 extern int wiz;
303 extern int tempwiz;
304 extern int matchlight, matchcount;
305 extern int loved;
306 extern int pleasure, power, ego;
307 extern int WEIGHT;
308 extern int CUMBER;
309 extern int notes[NUMOFNOTES];
310 extern unsigned int inven[NUMOFWORDS];
311 extern unsigned int wear[NUMOFWORDS];
312 extern char beenthere[NUMOFROOMS + 1];
313 extern char injuries[NUMOFINJURIES];
314 extern int verbose;
315
316 extern const char *username;
317
318 struct wlist {
319 const char *string;
320 int value, article;
321 struct wlist *next;
322 };
323 extern struct wlist wlist[];
324
325 struct objs {
326 short room;
327 short obj;
328 };
329 extern const struct objs dayobjs[];
330 extern const struct objs nightobjs[];
331
332 #define DEFAULT_SAVE_FILE ".Bstar"
333
334 void bury __P((void));
335 int card __P((const char *, int));
336 void chime __P((void));
337 void convert __P((int));
338 void crash __P((void));
339 int cypher __P((void));
340 void die __P((void)) __attribute__((__noreturn__));
341 void diesig __P((int)) __attribute__((__noreturn__));
342 void dig __P((void));
343 void dooropen __P((void));
344 int draw __P((void));
345 void drink __P((void));
346 int drive __P((void));
347 int drop __P((const char *));
348 int eat __P((void));
349 int fight __P((int, int));
350 int follow __P((void));
351 char *getcom __P((char *, int, const char *, const char *));
352 char *getword __P((char *, char *, int));
353 int give __P((void));
354 void initialize __P((const char *));
355 int jump __P((void));
356 void kiss __P((void));
357 int land __P((void));
358 int launch __P((void));
359 void light __P((void));
360 void live __P((void)) __attribute__((__noreturn__));
361 void love __P((void));
362 int moveplayer __P((int, int));
363 void murder __P((void));
364 void news __P((void));
365 void newway __P((int));
366 void open_score_file __P((void));
367 void parse __P((void));
368 void post __P((char));
369 void printobjs __P((void));
370 int put __P((void));
371 int puton __P((void));
372 const char *rate __P((void));
373 void ravage __P((void));
374 void restore __P((const char *));
375 int ride __P((void));
376 void save __P((const char *));
377 char *save_file_name __P((const char *, size_t));
378 int shoot __P((void));
379 int take __P((unsigned int[]));
380 int takeoff __P((void));
381 int throw __P((const char *));
382 const char *truedirec __P((int, char));
383 int ucard __P((const unsigned int *));
384 int use __P((void));
385 int visual __P((void));
386 int wearit __P((void));
387 void whichway __P((struct room));
388 void wordinit __P((void));
389 void writedes __P((void));
390 int zzz __P((void));
391