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