Commit | Line | Data |
---|---|---|
2a1cfdf5 WJ |
1 | /* |
2 | * Copyright (c) 1983 Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: | |
8 | * 1. Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * 2. Redistributions in binary form must reproduce the above copyright | |
11 | * notice, this list of conditions and the following disclaimer in the | |
12 | * documentation and/or other materials provided with the distribution. | |
13 | * 3. All advertising materials mentioning features or use of this software | |
14 | * must display the following acknowledgement: | |
15 | * This product includes software developed by the University of | |
16 | * California, Berkeley and its contributors. | |
17 | * 4. Neither the name of the University nor the names of its contributors | |
18 | * may be used to endorse or promote products derived from this software | |
19 | * without specific prior written permission. | |
20 | * | |
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
31 | * SUCH DAMAGE. | |
32 | * | |
33 | * @(#)externs.h 5.4 (Berkeley) 6/1/90 | |
34 | */ | |
35 | ||
36 | #include <sys/signal.h> | |
37 | #include <stdio.h> | |
38 | ||
39 | #define BITS (8 * sizeof (int)) | |
40 | ||
41 | #define OUTSIDE (position > 68 && position < 246 && position != 218) | |
42 | #define rnd(x) (rand() % (x)) | |
43 | #define max(a,b) ((a) < (b) ? (b) : (a)) | |
44 | #define testbit(array, index) (array[index/BITS] & (1 << (index % BITS))) | |
45 | #define setbit(array, index) (array[index/BITS] |= (1 << (index % BITS))) | |
46 | #define clearbit(array, index) (array[index/BITS] &= ~(1 << (index % BITS))) | |
47 | ||
48 | /* well known rooms */ | |
49 | #define FINAL 275 | |
50 | #define GARDEN 197 | |
51 | #define POOLS 126 | |
52 | #define DOCK 93 | |
53 | ||
54 | /* word types */ | |
55 | #define VERB 0 | |
56 | #define OBJECT 1 | |
57 | #define NOUNS 2 | |
58 | #define PREPS 3 | |
59 | #define ADJS 4 | |
60 | #define CONJ 5 | |
61 | ||
62 | /* words numbers */ | |
63 | #define KNIFE 0 | |
64 | #define SWORD 1 | |
65 | #define LAND 2 | |
66 | #define WOODSMAN 3 | |
67 | #define TWO_HANDED 4 | |
68 | #define CLEAVER 5 | |
69 | #define BROAD 6 | |
70 | #define MAIL 7 | |
71 | #define HELM 8 | |
72 | #define SHIELD 9 | |
73 | #define MAID 10 | |
74 | #define BODY 10 | |
75 | #define VIPER 11 | |
76 | #define LAMPON 12 | |
77 | #define SHOES 13 | |
78 | #define CYLON 14 | |
79 | #define PAJAMAS 15 | |
80 | #define ROBE 16 | |
81 | #define AMULET 17 | |
82 | #define MEDALION 18 | |
83 | #define TALISMAN 19 | |
84 | #define DEADWOOD 20 | |
85 | #define MALLET 21 | |
86 | #define LASER 22 | |
87 | #define BATHGOD 23 | |
88 | #define NORMGOD 24 | |
89 | #define GRENADE 25 | |
90 | #define CHAIN 26 | |
91 | #define ROPE 27 | |
92 | #define LEVIS 28 | |
93 | #define MACE 29 | |
94 | #define SHOVEL 30 | |
95 | #define HALBERD 31 | |
96 | #define COMPASS 32 | |
97 | #define CRASH 33 | |
98 | #define ELF 34 | |
99 | #define FOOT 35 | |
100 | #define COINS 36 | |
101 | #define MATCHES 37 | |
102 | #define MAN 38 | |
103 | #define PAPAYAS 39 | |
104 | #define PINEAPPLE 40 | |
105 | #define KIWI 41 | |
106 | #define COCONUTS 42 | |
107 | #define MANGO 43 | |
108 | #define RING 44 | |
109 | #define POTION 45 | |
110 | #define BRACELET 46 | |
111 | #define GIRL 47 | |
112 | #define GIRLTALK 48 | |
113 | #define DARK 49 | |
114 | #define TIMER 50 | |
115 | #define CHAR 53 | |
116 | #define BOMB 54 | |
117 | #define DEADGOD 55 | |
118 | #define DEADTIME 56 | |
119 | #define DEADNATIVE 57 | |
120 | #define NATIVE 58 | |
121 | #define HORSE 59 | |
122 | #define CAR 60 | |
123 | #define POT 61 | |
124 | #define BAR 62 | |
125 | #define BLOCK 63 | |
126 | #define NUMOFOBJECTS 64 | |
127 | /* non-objects below */ | |
128 | #define UP 1000 | |
129 | #define DOWN 1001 | |
130 | #define AHEAD 1002 | |
131 | #define BACK 1003 | |
132 | #define RIGHT 1004 | |
133 | #define LEFT 1005 | |
134 | #define TAKE 1006 | |
135 | #define USE 1007 | |
136 | #define LOOK 1008 | |
137 | #define QUIT 1009 | |
138 | #define NORTH 1010 | |
139 | #define SOUTH 1011 | |
140 | #define EAST 1012 | |
141 | #define WEST 1013 | |
142 | #define SU 1014 | |
143 | #define DROP 1015 | |
144 | #define TAKEOFF 1016 | |
145 | #define DRAW 1017 | |
146 | #define PUTON 1018 | |
147 | #define WEARIT 1019 | |
148 | #define PUT 1020 | |
149 | #define INVEN 1021 | |
150 | #define EVERYTHING 1022 | |
151 | #define AND 1023 | |
152 | #define KILL 1024 | |
153 | #define RAVAGE 1025 | |
154 | #define UNDRESS 1026 | |
155 | #define THROW 1027 | |
156 | #define LAUNCH 1028 | |
157 | #define LANDIT 1029 | |
158 | #define LIGHT 1030 | |
159 | #define FOLLOW 1031 | |
160 | #define KISS 1032 | |
161 | #define LOVE 1033 | |
162 | #define GIVE 1034 | |
163 | #define SMITE 1035 | |
164 | #define SHOOT 1036 | |
165 | #define ON 1037 | |
166 | #define OFF 1038 | |
167 | #define TIME 1039 | |
168 | #define SLEEP 1040 | |
169 | #define DIG 1041 | |
170 | #define EAT 1042 | |
171 | #define SWIM 1043 | |
172 | #define DRINK 1044 | |
173 | #define DOOR 1045 | |
174 | #define SAVE 1046 | |
175 | #define RIDE 1047 | |
176 | #define DRIVE 1048 | |
177 | #define SCORE 1049 | |
178 | #define BURY 1050 | |
179 | #define JUMP 1051 | |
180 | #define KICK 1052 | |
181 | ||
182 | /* injuries */ | |
183 | #define ARM 6 /* broken arm */ | |
184 | #define RIBS 7 /* broken ribs */ | |
185 | #define SPINE 9 /* broken back */ | |
186 | #define SKULL 11 /* fractured skull */ | |
187 | #define INCISE 10 /* deep incisions */ | |
188 | #define NECK 12 /* broken NECK */ | |
189 | #define NUMOFINJURIES 13 | |
190 | ||
191 | /* notes */ | |
192 | #define CANTLAUNCH 0 | |
193 | #define LAUNCHED 1 | |
194 | #define CANTSEE 2 | |
195 | #define CANTMOVE 3 | |
196 | #define JINXED 4 | |
197 | #define DUG 5 | |
198 | #define NUMOFNOTES 6 | |
199 | ||
200 | /* fundamental constants */ | |
201 | #define NUMOFROOMS 275 | |
202 | #define NUMOFWORDS ((NUMOFOBJECTS + BITS - 1) / BITS) | |
203 | #define LINELENGTH 81 | |
204 | ||
205 | #define TODAY 0 | |
206 | #define TONIGHT 1 | |
207 | #define CYCLE 100 | |
208 | ||
209 | /* initial variable values */ | |
210 | #define TANKFULL 250 | |
211 | #define TORPEDOES 10 | |
212 | #define MAXWEIGHT 60 | |
213 | #define MAXCUMBER 10 | |
214 | ||
215 | struct room { | |
216 | char *name; | |
217 | int link[8]; | |
218 | #define north link[0] | |
219 | #define south link[1] | |
220 | #define east link[2] | |
221 | #define west link[3] | |
222 | #define up link[4] | |
223 | #define access link[5] | |
224 | #define down link[6] | |
225 | #define flyhere link[7] | |
226 | char *desc; | |
227 | unsigned int objects[NUMOFWORDS]; | |
228 | }; | |
229 | struct room dayfile[]; | |
230 | struct room nightfile[]; | |
231 | struct room *location; | |
232 | ||
233 | /* object characteristics */ | |
234 | char *objdes[NUMOFOBJECTS]; | |
235 | char *objsht[NUMOFOBJECTS]; | |
236 | char *ouch[NUMOFINJURIES]; | |
237 | int objwt[NUMOFOBJECTS]; | |
238 | int objcumber[NUMOFOBJECTS]; | |
239 | ||
240 | /* current input line */ | |
241 | #define NWORD 20 /* words per line */ | |
242 | char words[NWORD][15]; | |
243 | int wordvalue[NWORD]; | |
244 | int wordtype[NWORD]; | |
245 | int wordcount, wordnumber; | |
246 | ||
247 | char *truedirec(), *rate(); | |
248 | char *getcom(), *getword(); | |
249 | ||
250 | /* state of the game */ | |
251 | int time; | |
252 | int position; | |
253 | int direction; | |
254 | int left, right, ahead, back; | |
255 | int clock, fuel, torps; | |
256 | int carrying, encumber; | |
257 | int rythmn; | |
258 | int followfight; | |
259 | int ate; | |
260 | int snooze; | |
261 | int meetgirl; | |
262 | int followgod; | |
263 | int godready; | |
264 | int win; | |
265 | int wintime; | |
266 | int wiz; | |
267 | int tempwiz; | |
268 | int matchlight, matchcount; | |
269 | int loved; | |
270 | int pleasure, power, ego; | |
271 | int WEIGHT; | |
272 | int CUMBER; | |
273 | int notes[NUMOFNOTES]; | |
274 | unsigned int inven[NUMOFWORDS]; | |
275 | unsigned int wear[NUMOFWORDS]; | |
276 | char beenthere[NUMOFROOMS+1]; | |
277 | char injuries[NUMOFINJURIES]; | |
278 | ||
279 | char uname[9]; | |
280 | ||
281 | struct wlist { | |
282 | char *string; | |
283 | int value, article; | |
284 | struct wlist *next; | |
285 | }; | |
286 | #define HASHSIZE 256 | |
287 | #define HASHMUL 81 | |
288 | #define HASHMASK (HASHSIZE - 1) | |
289 | struct wlist *hashtab[HASHSIZE]; | |
290 | struct wlist wlist[]; | |
291 | ||
292 | struct objs { | |
293 | short room; | |
294 | short obj; | |
295 | }; | |
296 | struct objs dayobjs[]; | |
297 | struct objs nightobjs[]; |