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
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.
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
29 * @(#)externs.h 8.1 (Berkeley) 5/31/93
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 $
36 #include <sys/param.h>
37 #include <sys/signal.h>
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)))
50 #define setbit(array, index) (array[index/BITS] |= (1 << (index % BITS)))
52 #define clearbit(array, index) (array[index/BITS] &= ~(1 << (index % BITS)))
54 /* well known rooms */
125 #define DEADNATIVE 57
132 #define NUMOFOBJECTS 64
133 /* non-objects below */
156 #define EVERYTHING 1022
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
206 /* fundamental constants */
207 #define NUMOFROOMS 275
208 #define NUMOFWORDS ((NUMOFOBJECTS + BITS - 1) / BITS)
209 #define LINELENGTH 81
215 /* initial variable values */
224 #define north link[0]
225 #define south link[1]
229 #define access link[5]
231 #define flyhere link[7]
233 unsigned int objects[NUMOFWORDS];
235 extern struct room dayfile[];
236 extern struct room nightfile[];
237 struct room *location;
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];
246 /* current input line */
247 #define NWORD 20 /* words per line */
248 char words[NWORD][15];
249 int wordvalue[NWORD];
251 int wordcount, wordnumber;
253 /* state of the game */
258 int left, right, ahead, back;
260 int carrying, encumber;
262 extern int followfight;
266 extern int followgod;
273 extern int matchcount;
275 int pleasure, power, ego;
278 int notes[NUMOFNOTES];
279 unsigned int inven[NUMOFWORDS];
280 u_int wear[NUMOFWORDS];
281 char beenthere[NUMOFROOMS+1];
282 char injuries[NUMOFINJURIES];
284 char uname[MAXLOGNAME];
293 #define HASHMASK (HASHSIZE - 1)
294 struct wlist *hashtab[HASHSIZE];
295 extern struct wlist wlist[];
301 extern const struct objs dayobjs[];
302 extern const struct objs nightobjs[];
307 int battlestar_move(int, int);
309 int card(const char *, int);
318 int drop(const char *);
322 char *getcom(char *, int, const char *, const char *);
323 char *getword(char *, char *, int);
325 void initialize(int);
336 void open_score_file(void);
338 void printobjs(void);
341 const char *rate(void);
347 int take(unsigned int[]);
349 int throw(const char *);
350 const char *truedirec(int, unsigned int);
351 int ucard(const unsigned int *);
355 void whichway(struct room);