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