]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/extern.h
WARNSify
[bsdgames-darwin.git] / battlestar / extern.h
1 /* $NetBSD: extern.h,v 1.5 1997/10/10 11:39:47 lukem 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 <pwd.h>
40 #include <signal.h>
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <string.h>
44 #include <unistd.h>
45
46 #define BITS (8 * sizeof (int))
47
48 #define OUTSIDE (position > 68 && position < 246 && position != 218)
49 #define rnd(x) (rand() % (x))
50 #define max(a,b) ((a) < (b) ? (b) : (a))
51 #define testbit(array, index) (array[index/BITS] & (1 << (index % BITS)))
52 #define setbit(array, index) (array[index/BITS] |= (1 << (index % BITS)))
53 #define clearbit(array, index) (array[index/BITS] &= ~(1 << (index % BITS)))
54
55 /* well known rooms */
56 #define FINAL 275
57 #define GARDEN 197
58 #define POOLS 126
59 #define DOCK 93
60
61 /* word types */
62 #define VERB 0
63 #define OBJECT 1
64 #define NOUNS 2
65 #define PREPS 3
66 #define ADJS 4
67 #define CONJ 5
68
69 /* words numbers */
70 #define KNIFE 0
71 #define SWORD 1
72 #define LAND 2
73 #define WOODSMAN 3
74 #define TWO_HANDED 4
75 #define CLEAVER 5
76 #define BROAD 6
77 #define MAIL 7
78 #define HELM 8
79 #define SHIELD 9
80 #define MAID 10
81 #define BODY 10
82 #define VIPER 11
83 #define LAMPON 12
84 #define SHOES 13
85 #define CYLON 14
86 #define PAJAMAS 15
87 #define ROBE 16
88 #define AMULET 17
89 #define MEDALION 18
90 #define TALISMAN 19
91 #define DEADWOOD 20
92 #define MALLET 21
93 #define LASER 22
94 #define BATHGOD 23
95 #define NORMGOD 24
96 #define GRENADE 25
97 #define CHAIN 26
98 #define ROPE 27
99 #define LEVIS 28
100 #define MACE 29
101 #define SHOVEL 30
102 #define HALBERD 31
103 #define COMPASS 32
104 #define CRASH 33
105 #define ELF 34
106 #define FOOT 35
107 #define COINS 36
108 #define MATCHES 37
109 #define MAN 38
110 #define PAPAYAS 39
111 #define PINEAPPLE 40
112 #define KIWI 41
113 #define COCONUTS 42
114 #define MANGO 43
115 #define RING 44
116 #define POTION 45
117 #define BRACELET 46
118 #define GIRL 47
119 #define GIRLTALK 48
120 #define DARK 49
121 #define TIMER 50
122 #define CHAR 53
123 #define BOMB 54
124 #define DEADGOD 55
125 #define DEADTIME 56
126 #define DEADNATIVE 57
127 #define NATIVE 58
128 #define HORSE 59
129 #define CAR 60
130 #define POT 61
131 #define BAR 62
132 #define BLOCK 63
133 #define NUMOFOBJECTS 64
134 /* non-objects below */
135 #define UP 1000
136 #define DOWN 1001
137 #define AHEAD 1002
138 #define BACK 1003
139 #define RIGHT 1004
140 #define LEFT 1005
141 #define TAKE 1006
142 #define USE 1007
143 #define LOOK 1008
144 #define QUIT 1009
145 #define NORTH 1010
146 #define SOUTH 1011
147 #define EAST 1012
148 #define WEST 1013
149 #define SU 1014
150 #define DROP 1015
151 #define TAKEOFF 1016
152 #define DRAW 1017
153 #define PUTON 1018
154 #define WEARIT 1019
155 #define PUT 1020
156 #define INVEN 1021
157 #define EVERYTHING 1022
158 #define AND 1023
159 #define KILL 1024
160 #define RAVAGE 1025
161 #define UNDRESS 1026
162 #define THROW 1027
163 #define LAUNCH 1028
164 #define LANDIT 1029
165 #define LIGHT 1030
166 #define FOLLOW 1031
167 #define KISS 1032
168 #define LOVE 1033
169 #define GIVE 1034
170 #define SMITE 1035
171 #define SHOOT 1036
172 #define ON 1037
173 #define OFF 1038
174 #define TIME 1039
175 #define SLEEP 1040
176 #define DIG 1041
177 #define EAT 1042
178 #define SWIM 1043
179 #define DRINK 1044
180 #define DOOR 1045
181 #define SAVE 1046
182 #define RIDE 1047
183 #define DRIVE 1048
184 #define SCORE 1049
185 #define BURY 1050
186 #define JUMP 1051
187 #define KICK 1052
188
189 /* injuries */
190 #define ARM 6 /* broken arm */
191 #define RIBS 7 /* broken ribs */
192 #define SPINE 9 /* broken back */
193 #define SKULL 11 /* fractured skull */
194 #define INCISE 10 /* deep incisions */
195 #define NECK 12 /* broken NECK */
196 #define NUMOFINJURIES 13
197
198 /* notes */
199 #define CANTLAUNCH 0
200 #define LAUNCHED 1
201 #define CANTSEE 2
202 #define CANTMOVE 3
203 #define JINXED 4
204 #define DUG 5
205 #define NUMOFNOTES 6
206
207 /* fundamental constants */
208 #define NUMOFROOMS 275
209 #define NUMOFWORDS ((NUMOFOBJECTS + BITS - 1) / BITS)
210 #define LINELENGTH 81
211
212 #define TODAY 0
213 #define TONIGHT 1
214 #define CYCLE 100
215
216 /* initial variable values */
217 #define TANKFULL 250
218 #define TORPEDOES 10
219 #define MAXWEIGHT 60
220 #define MAXCUMBER 10
221
222 struct room {
223 char *name;
224 int link[8];
225 #define north link[0]
226 #define south link[1]
227 #define east link[2]
228 #define west link[3]
229 #define up link[4]
230 #define access link[5]
231 #define down link[6]
232 #define flyhere link[7]
233 char *desc;
234 unsigned int objects[NUMOFWORDS];
235 };
236 struct room dayfile[];
237 struct room nightfile[];
238 struct room *location;
239
240 /* object characteristics */
241 char *objdes[NUMOFOBJECTS];
242 char *objsht[NUMOFOBJECTS];
243 char *ouch[NUMOFINJURIES];
244 int objwt[NUMOFOBJECTS];
245 int objcumber[NUMOFOBJECTS];
246
247 /* current input line */
248 #define NWORD 20 /* words per line */
249 char words[NWORD][15];
250 int wordvalue[NWORD];
251 int wordtype[NWORD];
252 int wordcount, wordnumber;
253
254 /* state of the game */
255 int ourtime;
256 int position;
257 int direction;
258 int left, right, ahead, back;
259 int ourclock, fuel, torps;
260 int carrying, encumber;
261 int rythmn;
262 int followfight;
263 int ate;
264 int snooze;
265 int meetgirl;
266 int followgod;
267 int godready;
268 int win;
269 int wintime;
270 int wiz;
271 int tempwiz;
272 int matchlight, matchcount;
273 int loved;
274 int pleasure, power, ego;
275 int WEIGHT;
276 int CUMBER;
277 int notes[NUMOFNOTES];
278 unsigned int inven[NUMOFWORDS];
279 unsigned int wear[NUMOFWORDS];
280 char beenthere[NUMOFROOMS+1];
281 char injuries[NUMOFINJURIES];
282
283 char uname[9];
284
285 struct wlist {
286 char *string;
287 int value, article;
288 struct wlist *next;
289 };
290 #define HASHSIZE 256
291 #define HASHMUL 81
292 #define HASHMASK (HASHSIZE - 1)
293 struct wlist *hashtab[HASHSIZE];
294 struct wlist wlist[];
295
296 struct objs {
297 short room;
298 short obj;
299 };
300 struct objs dayobjs[];
301 struct objs nightobjs[];
302
303 void blast __P((void));
304 void bury __P((void));
305 int card __P((char *, int));
306 int checkout __P((char *));
307 void chime __P((void));
308 void convert __P((int));
309 void crash __P((void));
310 int cypher __P((void));
311 void die __P((void));
312 void diesig __P((int));
313 void dig __P((void));
314 int draw __P((void));
315 void drink __P((void));
316 int drive __P((void));
317 int drop __P((char *));
318 int eat __P((void));
319 void endfly __P((void));
320 int fight __P((int, int));
321 int follow __P((void));
322 void getutmp __P((char *));
323 int give __P((void));
324 int hash __P((char *));
325 void initialize __P((char));
326 void install __P((struct wlist *));
327 int jump __P((void));
328 void kiss __P((void));
329 int land __P((void));
330 int launch __P((void));
331 void light __P((void));
332 void live __P((void));
333 void love __P((void));
334 int move __P((int, int));
335 void moveenemy __P((int));
336 void murder __P((void));
337 void news __P((void));
338 void newway __P((int));
339 void notarget __P((void));
340 void parse __P((void));
341 void post __P((char));
342 void printobjs __P((void));
343 int put __P((void));
344 int puton __P((void));
345 void ravage __P((void));
346 void restore __P((void));
347 int ride __P((void));
348 void save __P((void));
349 void screen __P((void));
350 int shoot __P((void));
351 void succumb __P((int));
352 int take __P((unsigned int []));
353 int takeoff __P((void));
354 void target __P((void));
355 int throw __P((char *));
356 int ucard __P((unsigned int *));
357 int use __P((void));
358 int visual __P((void));
359 int wearit __P((void));
360 void whichway __P((struct room));
361 int wizard __P((char *));
362 void wordinit __P((void));
363 void writedes __P((void));
364 int zzz __P((void));
365 char *getcom __P((char *, int, char *, char *));
366 char *getword __P((char *, char *, int));
367 char *rate __P((void));
368 char *truedirec __P((int, char));
369 struct wlist *lookup __P((char *));