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