Sync usage with man page.
[netbsd-mini2440.git] / games / battlestar / extern.h
blob620ed8d0612116a0db7fc4d148149bf60a9a891c
1 /* $NetBSD: extern.h,v 1.31 2005/07/01 06:04:54 jmc Exp $ */
3 /*
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
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. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
31 * @(#)externs.h 8.1 (Berkeley) 5/31/93
34 #include <ctype.h>
35 #include <err.h>
36 #include <pwd.h>
37 #include <signal.h>
38 #include <stdio.h>
39 #include <stdlib.h>
40 #include <string.h>
41 #include <time.h>
42 #include <unistd.h>
44 #define BITS (8 * sizeof (int))
46 #define OUTSIDE (position > 68 && position < 246 && position != 218)
47 #define rnd(x) (rand() % (x))
48 #define max(a,b) ((a) < (b) ? (b) : (a))
49 #define testbit(array, index) (array[index/BITS] & (1 << (index % BITS)))
50 #define setbit(array, index) (array[index/BITS] |= (1 << (index % BITS)))
51 #define clearbit(array, index) (array[index/BITS] &= ~(1 << (index % BITS)))
53 /* well known rooms */
54 #define FINAL 275
55 #define GARDEN 197
56 #define POOLS 126
57 #define DOCK 93
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
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 #define OPEN 1053
187 #define VERBOSE 1054
188 #define BRIEF 1055
189 #define AUXVERB 1056
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
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
209 /* Number of times room description shown. */
210 #define ROOMDESC 3
212 /* fundamental constants */
213 #define NUMOFROOMS 275
214 #define NUMOFWORDS ((NUMOFOBJECTS + BITS - 1) / BITS)
215 #define LINELENGTH 81
217 #define TODAY 0
218 #define TONIGHT 1
219 #define CYCLE 100
221 /* initial variable values */
222 #define TANKFULL 250
223 #define TORPEDOES 10
224 #define MAXWEIGHT 60
225 #define MAXCUMBER 10
228 * These are flags for objects in the objflags array. OBJ_PLURAL means
229 * that the object short name is plural; OBJ_AN that it begins with a
230 * vowel sound so should be preceded by "an" instead of "a"; OBJ_PERSON
231 * that it is a living person; OBJ_NONOBJ that it is not an object (to
232 * which any game action can be applied) at all (e.g. footsteps, asteroids).
233 * Any individual object has at most one of OBJ_PERSON and OBJ_NONOBJ.
235 #define OBJ_PLURAL 1
236 #define OBJ_AN 2
237 #define OBJ_PERSON 4
238 #define OBJ_NONOBJ 8
240 struct room {
241 const char *name;
242 int link[8];
243 #define north link[0]
244 #define south link[1]
245 #define east link[2]
246 #define west link[3]
247 #define up link[4]
248 #define access link[5]
249 #define down link[6]
250 #define flyhere link[7]
251 const char *desc;
252 unsigned int objects[NUMOFWORDS];
254 extern struct room dayfile[];
255 extern struct room nightfile[];
256 extern struct room *location;
258 /* object characteristics */
259 extern const char *const objdes[NUMOFOBJECTS];
260 extern const char *const objsht[NUMOFOBJECTS];
261 extern const char *const ouch[NUMOFINJURIES];
262 extern const int objwt[NUMOFOBJECTS];
263 extern const int objcumber[NUMOFOBJECTS];
264 extern const int objflags[NUMOFOBJECTS];
265 #define is_plural_object(n) (objflags[(n)] & OBJ_PLURAL)
267 * These macros yield words to use with objects (followed but not preceded
268 * by spaces, or with no spaces if the expansion is the empty string).
270 #define A_OR_AN(n) (objflags[(n)] & OBJ_AN ? "an " : "a ")
271 #define A_OR_AN_OR_THE(n) (is_plural_object((n)) ? "the " : A_OR_AN((n)))
272 #define A_OR_AN_OR_BLANK(n) (is_plural_object((n)) ? "" : A_OR_AN((n)))
273 #define IS_OR_ARE(n) (is_plural_object((n)) ? "are " : "is ")
275 /* current input line */
276 #define WORDLEN 15
277 #define NWORD 20 /* words per line */
278 extern char words[NWORD][WORDLEN];
279 extern int wordvalue[NWORD];
280 extern int wordtype[NWORD];
281 extern int wordcount, wordnumber;
283 /* state of the game */
284 extern int ourtime;
285 extern int position;
286 extern int direction;
287 extern int left, right, ahead, back;
288 extern int ourclock, fuel, torps;
289 extern int carrying, encumber;
290 extern int rythmn;
291 extern int followfight;
292 extern int ate;
293 extern int snooze;
294 extern int meetgirl;
295 extern int followgod;
296 extern int godready;
297 extern int win;
298 extern int wintime;
299 extern int wiz;
300 extern int tempwiz;
301 extern int matchlight, matchcount;
302 extern int loved;
303 extern int pleasure, power, ego;
304 extern int WEIGHT;
305 extern int CUMBER;
306 extern int notes[NUMOFNOTES];
307 extern unsigned int inven[NUMOFWORDS];
308 extern unsigned int wear[NUMOFWORDS];
309 extern char beenthere[NUMOFROOMS + 1];
310 extern char injuries[NUMOFINJURIES];
311 extern int verbose;
313 extern const char *username;
315 struct wlist {
316 const char *string;
317 int value, article;
318 struct wlist *next;
320 extern struct wlist wlist[];
322 struct objs {
323 short room;
324 short obj;
326 extern const struct objs dayobjs[];
327 extern const struct objs nightobjs[];
329 #define DEFAULT_SAVE_FILE ".Bstar"
331 void bury(void);
332 int card(const char *, int);
333 void chime(void);
334 void crash(void);
335 int cypher(void);
336 void die(void) __attribute__((__noreturn__));
337 void diesig(int) __attribute__((__noreturn__));
338 void dig(void);
339 void dooropen(void);
340 int draw(void);
341 void drink(void);
342 int drive(void);
343 int drop(const char *);
344 int eat(void);
345 int fight(int, int);
346 int follow(void);
347 char *getcom(char *, int, const char *, const char *);
348 char *getword(char *, char *, int);
349 int give(void);
350 void initialize(const char *);
351 int jump(void);
352 void kiss(void);
353 int land(void);
354 int launch(void);
355 void light(void);
356 void live(void) __attribute__((__noreturn__));
357 void love(void);
358 int moveplayer(int, int);
359 void murder(void);
360 void news(void);
361 void newway(int);
362 void open_score_file(void);
363 void parse(void);
364 void printobjs(void);
365 int put(void);
366 int puton(void);
367 const char *rate(void);
368 void ravage(void);
369 void restore(const char *);
370 int ride(void);
371 void save(const char *);
372 char *save_file_name(const char *, size_t);
373 int shoot(void);
374 int take(unsigned int[]);
375 int takeoff(void);
376 int throw(const char *);
377 const char *truedirec(int, int);
378 int ucard(const unsigned int *);
379 int use(void);
380 int visual(void);
381 int wearit(void);
382 void whichway(struct room);
383 void wordinit(void);
384 void writedes(void);
385 int zzz(void);