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 $
35 #include <sys/param.h>
36 #include <sys/signal.h>
49 #define OUTSIDE (position > 68 && position < 246 && position != 218)
50 #define rnd(x) (random() % (x))
51 #define max(a,b) ((a) < (b) ? (b) : (a))
52 #define testbit(array, index) (array[index/BITS] & (1 << (index % BITS)))
53 #define setbit(array, index) (array[index/BITS] |= (1 << (index % BITS)))
54 #define clearbit(array, index) (array[index/BITS] &= ~(1 << (index % BITS)))
56 /* well known rooms */
127 #define DEADNATIVE 57
134 #define NUMOFOBJECTS 64
135 /* non-objects below */
158 #define EVERYTHING 1022
191 #define ARM 6 /* broken arm */
192 #define RIBS 7 /* broken ribs */
193 #define SPINE 9 /* broken back */
194 #define SKULL 11 /* fractured skull */
195 #define INCISE 10 /* deep incisions */
196 #define NECK 12 /* broken NECK */
197 #define NUMOFINJURIES 13
208 /* fundamental constants */
209 #define NUMOFROOMS 275
210 #define NUMOFWORDS ((NUMOFOBJECTS + BITS - 1) / BITS)
211 #define LINELENGTH 81
217 /* initial variable values */
226 #define north link[0]
227 #define south link[1]
231 #define access link[5]
233 #define flyhere link[7]
235 unsigned int objects
[NUMOFWORDS
];
237 extern struct room dayfile
[];
238 extern struct room nightfile
[];
239 struct room
*location
;
241 /* object characteristics */
242 extern const char *const objdes
[NUMOFOBJECTS
];
243 extern const char *const objsht
[NUMOFOBJECTS
];
244 extern const char *const ouch
[NUMOFINJURIES
];
245 extern const int objwt
[NUMOFOBJECTS
];
246 extern const int objcumber
[NUMOFOBJECTS
];
248 /* current input line */
249 #define NWORD 20 /* words per line */
250 char words
[NWORD
][15];
251 int wordvalue
[NWORD
];
253 int wordcount
, wordnumber
;
255 /* state of the game */
260 int left
, right
, ahead
, back
;
262 int carrying
, encumber
;
264 extern int followfight
;
268 extern int followgod
;
275 extern int matchcount
;
277 int pleasure
, power
, ego
;
280 int notes
[NUMOFNOTES
];
281 unsigned int inven
[NUMOFWORDS
];
282 u_int wear
[NUMOFWORDS
];
283 char beenthere
[NUMOFROOMS
+1];
284 char injuries
[NUMOFINJURIES
];
286 char uname
[MAXLOGNAME
];
295 #define HASHMASK (HASHSIZE - 1)
296 struct wlist
*hashtab
[HASHSIZE
];
297 extern struct wlist wlist
[];
303 extern const struct objs dayobjs
[];
304 extern const struct objs nightobjs
[];
309 int battlestar_move(int, int);
311 int card(const char *, int);
315 void die(int) __dead2
;
320 int drop(const char *);
324 char *getcom(char *, int, const char *, const char *);
325 char *getword(char *, char *, int);
327 void initialize(int);
333 void live(void) __dead2
;
338 void open_score_file(void);
340 void printobjs(void);
343 const char *rate(void);
349 int take(unsigned int[]);
351 int throw(const char *);
352 const char *truedirec(int, unsigned int);
353 int ucard(const unsigned int *);
357 void whichway(struct room
);