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