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