]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/extern.h
1 /* $NetBSD: extern.h,v 1.36 2014/03/22 23:33:33 dholland Exp $ */
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
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
31 * @(#)externs.h 8.1 (Berkeley) 5/31/93
45 #define BITS (CHAR_BIT * sizeof (unsigned int))
47 #define OUTSIDE (position > 68 && position < 246 && position != 218)
48 #define rnd(x) (random() % (x))
49 #define max(a,b) ((a) < (b) ? (b) : (a))
50 #define testbit(array, index) (array[index/BITS] & (1U << (index % BITS)))
51 #define setbit(array, index) (array[index/BITS] |= (1U << (index % BITS)))
52 #define clearbit(array, index) (array[index/BITS] &= ~(1U << (index % BITS)))
54 /* well known rooms */
125 #define DEADNATIVE 57
132 #define NUMOFOBJECTS 64
133 /* non-objects below */
156 #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 /* Number of times room description shown. */
213 /* fundamental constants */
214 #define NUMOFROOMS 275
215 #define NUMOFWORDS ((NUMOFOBJECTS + BITS - 1) / BITS)
216 #define LINELENGTH 81
222 /* initial variable values */
229 * These are flags for objects in the objflags array. OBJ_PLURAL means
230 * that the object short name is plural; OBJ_AN that it begins with a
231 * vowel sound so should be preceded by "an" instead of "a"; OBJ_PERSON
232 * that it is a living person; OBJ_NONOBJ that it is not an object (to
233 * which any game action can be applied) at all (e.g. footsteps, asteroids).
234 * Any individual object has at most one of OBJ_PERSON and OBJ_NONOBJ.
244 #define north link[0]
245 #define south link[1]
249 #define access link[5]
251 #define flyhere link[7]
253 unsigned int objects
[NUMOFWORDS
];
255 extern struct room dayfile
[];
256 extern struct room nightfile
[];
257 extern struct room
*location
;
259 /* object characteristics */
260 extern const char *const objdes
[NUMOFOBJECTS
];
261 extern const char *const objsht
[NUMOFOBJECTS
];
262 extern const char *const ouch
[NUMOFINJURIES
];
263 extern const int objwt
[NUMOFOBJECTS
];
264 extern const int objcumber
[NUMOFOBJECTS
];
265 extern const int objflags
[NUMOFOBJECTS
];
266 #define is_plural_object(n) (objflags[(n)] & OBJ_PLURAL)
268 * These macros yield words to use with objects (followed but not preceded
269 * by spaces, or with no spaces if the expansion is the empty string).
271 #define A_OR_AN(n) (objflags[(n)] & OBJ_AN ? "an " : "a ")
272 #define A_OR_AN_OR_THE(n) (is_plural_object((n)) ? "the " : A_OR_AN((n)))
273 #define A_OR_AN_OR_BLANK(n) (is_plural_object((n)) ? "" : A_OR_AN((n)))
274 #define IS_OR_ARE(n) (is_plural_object((n)) ? "are " : "is ")
276 /* current input line */
278 #define NWORD 20 /* words per line */
279 extern char words
[NWORD
][WORDLEN
];
280 extern int wordvalue
[NWORD
];
281 extern int wordtype
[NWORD
];
282 extern int wordcount
, wordnumber
;
284 /* state of the game */
287 extern int direction
;
288 extern int left
, right
, ahead
, back
;
289 extern int ourclock
, fuel
, torps
;
290 extern int carrying
, encumber
;
292 extern int followfight
;
296 extern int followgod
;
302 extern int matchlight
, matchcount
;
304 extern int pleasure
, power
, ego
;
307 extern int notes
[NUMOFNOTES
];
308 extern unsigned int inven
[NUMOFWORDS
];
309 extern unsigned int wear
[NUMOFWORDS
];
310 extern char beenthere
[NUMOFROOMS
+ 1];
311 extern char injuries
[NUMOFINJURIES
];
314 extern const char *username
;
321 extern struct wlist wlist
[];
327 extern const struct objs dayobjs
[];
328 extern const struct objs nightobjs
[];
330 #define DEFAULT_SAVE_FILE ".Bstar"
333 int card(const char *, int);
337 void die(void) __dead
;
338 void diesig(int) __dead
;
344 int drop(const char *);
348 char *getcom(char *, int, const char *, const char *);
349 char *getword(char *, char *, int);
351 void initialize(const char *);
357 void live(void) __dead
;
359 int moveplayer(int, int);
363 void open_score_file(void);
365 void printobjs(void);
368 const char *rate(void);
370 void restore(const char *);
372 void save(const char *);
373 char *save_file_name(const char *, size_t);
375 int take(unsigned int[]);
377 int throw(const char *);
378 const char *truedirec(int, int);
379 int ucard(const unsigned int *);
383 void whichway(struct room
);