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. 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.
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
33 * @(#)externs.h 8.1 (Berkeley) 5/31/93
35 * $FreeBSD: src/games/battlestar/externs.h,v 1.9.2.1 2001/03/05 11:45:36 kris Exp $
36 * $DragonFly: src/games/battlestar/externs.h,v 1.4 2006/08/08 16:47:20 pavalos Exp $
40 #include <sys/param.h>
41 #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)))
54 #define setbit(array, index) (array[index/BITS] |= (1 << (index % BITS)))
56 #define clearbit(array, index) (array[index/BITS] &= ~(1 << (index % BITS)))
58 /* well known rooms */
129 #define DEADNATIVE 57
136 #define NUMOFOBJECTS 64
137 /* non-objects below */
160 #define EVERYTHING 1022
193 #define ARM 6 /* broken arm */
194 #define RIBS 7 /* broken ribs */
195 #define SPINE 9 /* broken back */
196 #define SKULL 11 /* fractured skull */
197 #define INCISE 10 /* deep incisions */
198 #define NECK 12 /* broken NECK */
199 #define NUMOFINJURIES 13
210 /* fundamental constants */
211 #define NUMOFROOMS 275
212 #define NUMOFWORDS ((NUMOFOBJECTS + BITS - 1) / BITS)
213 #define LINELENGTH 81
219 /* initial variable values */
228 #define north link[0]
229 #define south link[1]
233 #define access link[5]
235 #define flyhere link[7]
237 unsigned int objects
[NUMOFWORDS
];
239 extern struct room dayfile
[];
240 extern struct room nightfile
[];
241 struct room
*location
;
243 /* object characteristics */
244 extern const char *const objdes
[NUMOFOBJECTS
];
245 extern const char *const objsht
[NUMOFOBJECTS
];
246 extern const char *const ouch
[NUMOFINJURIES
];
247 extern const int objwt
[NUMOFOBJECTS
];
248 extern const int objcumber
[NUMOFOBJECTS
];
250 /* current input line */
251 #define NWORD 20 /* words per line */
252 char words
[NWORD
][15];
253 int wordvalue
[NWORD
];
255 int wordcount
, wordnumber
;
258 int battlestar_move (int, int);
260 int card (const char *, int);
269 int drop (const char *name
);
271 int fight (int, int);
273 char *getcom (char *, int, const char *, const char *);
274 char *getword (char *, char *, int);
276 void initialize (int);
287 void open_score_file (void);
289 void printobjs (void);
293 const char *rate (void);
298 int take (unsigned int from
[]);
300 int throw (const char *name
);
301 const char *truedirec (int, unsigned int);
302 int ucard (const unsigned int *);
306 void whichway (struct room
);
307 void wordinit (void);
308 void writedes (void);
311 /* state of the game */
316 int left
, right
, ahead
, back
;
318 int carrying
, encumber
;
320 extern int followfight
;
324 extern int followgod
;
331 extern int matchcount
;
333 int pleasure
, power
, ego
;
336 int notes
[NUMOFNOTES
];
337 unsigned int inven
[NUMOFWORDS
];
338 u_int wear
[NUMOFWORDS
];
339 char beenthere
[NUMOFROOMS
+1];
340 char injuries
[NUMOFINJURIES
];
342 char uname
[MAXLOGNAME
];
351 #define HASHMASK (HASHSIZE - 1)
352 struct wlist
*hashtab
[HASHSIZE
];
353 extern struct wlist wlist
[];
359 extern const struct objs dayobjs
[];
360 extern const struct objs nightobjs
[];