]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - games/battlestar/externs.h
This commit was generated by cvs2svn to compensate for changes in r37446,
[FreeBSD/FreeBSD.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
36 #include <errno.h>
37 #include <sys/param.h>
38 #include <sys/signal.h>
39 #include <stdio.h>
40 #include <stdlib.h>
41
42 #define BITS (8)
43
44 #define OUTSIDE         (position > 68 && position < 246 && position != 218)
45 #define rnd(x)          (random() % (x))
46 #define max(a,b)        ((a) < (b) ? (b) : (a))
47 #define testbit(array, index)   (array[index/BITS] & (1 << (index % BITS)))
48 #ifndef setbit
49 #define setbit(array, index)    (array[index/BITS] |= (1 << (index % BITS)))
50 #endif
51 #define clearbit(array, index)  (array[index/BITS] &= ~(1 << (index % BITS)))
52
53         /* well known rooms */
54 #define FINAL   275
55 #define GARDEN  197
56 #define POOLS   126
57 #define DOCK    93
58
59         /* word types */
60 #define VERB    0
61 #define OBJECT  1
62 #define NOUNS   2
63 #define PREPS   3
64 #define ADJS    4
65 #define CONJ    5
66
67         /* words numbers */
68 #define KNIFE           0
69 #define SWORD           1
70 #define LAND            2
71 #define WOODSMAN        3
72 #define TWO_HANDED      4
73 #define CLEAVER         5
74 #define BROAD           6
75 #define MAIL            7
76 #define HELM            8
77 #define SHIELD          9
78 #define MAID            10
79 #define BODY            10
80 #define VIPER           11
81 #define LAMPON          12
82 #define SHOES           13
83 #define CYLON           14
84 #define PAJAMAS         15
85 #define ROBE            16
86 #define AMULET          17
87 #define MEDALION        18
88 #define TALISMAN        19
89 #define DEADWOOD        20
90 #define MALLET          21
91 #define LASER           22
92 #define BATHGOD         23
93 #define NORMGOD         24
94 #define GRENADE         25
95 #define CHAIN           26
96 #define ROPE            27
97 #define LEVIS           28
98 #define MACE            29
99 #define SHOVEL          30
100 #define HALBERD         31
101 #define COMPASS         32
102 #define CRASH           33
103 #define ELF             34
104 #define FOOT            35
105 #define COINS           36
106 #define MATCHES         37
107 #define MAN             38
108 #define PAPAYAS         39
109 #define PINEAPPLE       40
110 #define KIWI            41
111 #define COCONUTS        42
112 #define MANGO           43
113 #define RING            44
114 #define POTION          45
115 #define BRACELET        46
116 #define GIRL            47
117 #define GIRLTALK        48
118 #define DARK            49
119 #define TIMER           50
120 #define CHAR            53
121 #define BOMB            54
122 #define DEADGOD         55
123 #define DEADTIME        56
124 #define DEADNATIVE      57
125 #define NATIVE          58
126 #define HORSE           59
127 #define CAR             60
128 #define POT             61
129 #define BAR             62
130 #define BLOCK           63
131 #define NUMOFOBJECTS    64
132         /* non-objects below */
133 #define UP      1000
134 #define DOWN    1001
135 #define AHEAD   1002
136 #define BACK    1003
137 #define RIGHT   1004
138 #define LEFT    1005
139 #define TAKE    1006
140 #define USE     1007
141 #define LOOK    1008
142 #define QUIT    1009
143 #define NORTH   1010
144 #define SOUTH   1011
145 #define EAST    1012
146 #define WEST    1013
147 #define SU      1014
148 #define DROP    1015
149 #define TAKEOFF 1016
150 #define DRAW    1017
151 #define PUTON   1018
152 #define WEARIT  1019
153 #define PUT     1020
154 #define INVEN   1021
155 #define EVERYTHING 1022
156 #define AND     1023
157 #define KILL    1024
158 #define RAVAGE  1025
159 #define UNDRESS 1026
160 #define THROW   1027
161 #define LAUNCH  1028
162 #define LANDIT  1029
163 #define LIGHT   1030
164 #define FOLLOW  1031
165 #define KISS    1032
166 #define LOVE    1033
167 #define GIVE    1034
168 #define SMITE   1035
169 #define SHOOT   1036
170 #define ON      1037
171 #define OFF     1038
172 #define TIME    1039
173 #define SLEEP   1040
174 #define DIG     1041
175 #define EAT     1042
176 #define SWIM    1043
177 #define DRINK   1044
178 #define DOOR    1045
179 #define SAVE    1046
180 #define RIDE    1047
181 #define DRIVE   1048
182 #define SCORE   1049
183 #define BURY    1050
184 #define JUMP    1051
185 #define KICK    1052
186
187         /* injuries */
188 #define ARM     6               /* broken arm */
189 #define RIBS    7               /* broken ribs */
190 #define SPINE   9               /* broken back */
191 #define SKULL   11              /* fractured skull */
192 #define INCISE  10              /* deep incisions */
193 #define NECK    12              /* broken NECK */
194 #define NUMOFINJURIES 13
195
196         /* notes */
197 #define CANTLAUNCH      0
198 #define LAUNCHED        1
199 #define CANTSEE         2
200 #define CANTMOVE        3
201 #define JINXED          4
202 #define DUG             5
203 #define NUMOFNOTES      6
204
205         /* fundamental constants */
206 #define NUMOFROOMS      275
207 #define NUMOFWORDS      ((NUMOFOBJECTS + BITS - 1) / BITS)
208 #define LINELENGTH      81
209
210 #define TODAY           0
211 #define TONIGHT         1
212 #define CYCLE           100
213
214         /* initial variable values */
215 #define TANKFULL        250
216 #define TORPEDOES       10
217 #define MAXWEIGHT       60
218 #define MAXCUMBER       10
219
220 struct room {
221         char *name;
222         int link[8];
223 #define north   link[0]
224 #define south   link[1]
225 #define east    link[2]
226 #define west    link[3]
227 #define up      link[4]
228 #define access  link[5]
229 #define down    link[6]
230 #define flyhere link[7]
231         char *desc;
232         int objects[NUMOFWORDS];
233 };
234 extern struct room dayfile[];
235 extern struct room nightfile[];
236 struct room *location;
237
238         /* object characteristics */
239 char *objdes[NUMOFOBJECTS];
240 char *objsht[NUMOFOBJECTS];
241 char *ouch[NUMOFINJURIES];
242 int objwt[NUMOFOBJECTS];
243 int objcumber[NUMOFOBJECTS];
244
245         /* current input line */
246 #define NWORD   20                      /* words per line */
247 char words[NWORD][15];
248 int wordvalue[NWORD];
249 int wordtype[NWORD];
250 int wordcount, wordnumber;
251
252 char *truedirec(), *rate();
253 char *getcom(), *getword();
254
255         /* state of the game */
256 int gtime;
257 int position;
258 int direction;
259 int left, right, ahead, back;
260 int gclock, 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 int inven[NUMOFWORDS];
280 int wear[NUMOFWORDS];
281 char beenthere[NUMOFROOMS+1];
282 char injuries[NUMOFINJURIES];
283
284 char uname[MAXLOGNAME];
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 extern struct wlist wlist[];
296
297 struct objs {
298         short room;
299         short obj;
300 };
301 extern struct objs dayobjs[];
302 extern struct objs nightobjs[];
303
304 gid_t   egid;