Home | History | Annotate | Line # | Download | only in battlestar
extern.h revision 1.29
      1 /*	$NetBSD: extern.h,v 1.29 2003/08/07 09:37:02 agc Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1983, 1993
      5  *	The Regents of the University of California.  All rights reserved.
      6  *
      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.
     18  *
     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.
     30  *
     31  *	@(#)externs.h	8.1 (Berkeley) 5/31/93
     32  */
     33 
     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>
     43 
     44 #define BITS (8 * sizeof (int))
     45 
     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)))
     52 
     53  /* well known rooms */
     54 #define FINAL	275
     55 #define GARDEN	197
     56 #define POOLS	126
     57 #define DOCK	93
     58 
     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
     66 
     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
    190 
    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
    199 
    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
    208 
    209 /* Number of times room description shown. */
    210 #define ROOMDESC	3
    211 
    212  /* fundamental constants */
    213 #define NUMOFROOMS	275
    214 #define NUMOFWORDS	((NUMOFOBJECTS + BITS - 1) / BITS)
    215 #define LINELENGTH	81
    216 
    217 #define TODAY		0
    218 #define TONIGHT		1
    219 #define CYCLE		100
    220 
    221  /* initial variable values */
    222 #define TANKFULL	250
    223 #define TORPEDOES	10
    224 #define MAXWEIGHT	60
    225 #define MAXCUMBER	10
    226 
    227 /*
    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.
    234  */
    235 #define OBJ_PLURAL	1
    236 #define OBJ_AN		2
    237 #define OBJ_PERSON	4
    238 #define OBJ_NONOBJ	8
    239 
    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];
    253 };
    254 extern struct room dayfile[];
    255 extern struct room nightfile[];
    256 extern struct room *location;
    257 
    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)
    266 /*
    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).
    269  */
    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 ")
    274 
    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;
    282 
    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;
    312 
    313 extern const char *username;
    314 
    315 struct wlist {
    316 	const char   *string;
    317 	int     value, article;
    318 	struct wlist *next;
    319 };
    320 extern struct wlist wlist[];
    321 
    322 struct objs {
    323 	short   room;
    324 	short   obj;
    325 };
    326 extern const struct objs dayobjs[];
    327 extern const struct objs nightobjs[];
    328 
    329 #define DEFAULT_SAVE_FILE	".Bstar"
    330 
    331 void bury __P((void));
    332 int card __P((const char *, int));
    333 void chime __P((void));
    334 void convert __P((int));
    335 void crash __P((void));
    336 int cypher __P((void));
    337 void die __P((void)) __attribute__((__noreturn__));
    338 void diesig __P((int)) __attribute__((__noreturn__));
    339 void dig __P((void));
    340 void dooropen __P((void));
    341 int draw __P((void));
    342 void drink __P((void));
    343 int drive __P((void));
    344 int drop __P((const char *));
    345 int eat __P((void));
    346 int fight __P((int, int));
    347 int follow __P((void));
    348 char *getcom __P((char *, int, const char *, const char *));
    349 char *getword __P((char *, char *, int));
    350 int give __P((void));
    351 void initialize __P((const char *));
    352 int jump __P((void));
    353 void kiss __P((void));
    354 int land __P((void));
    355 int launch __P((void));
    356 void light __P((void));
    357 void live __P((void)) __attribute__((__noreturn__));
    358 void love __P((void));
    359 int moveplayer __P((int, int));
    360 void murder __P((void));
    361 void news __P((void));
    362 void newway __P((int));
    363 void open_score_file __P((void));
    364 void parse __P((void));
    365 void post __P((char));
    366 void printobjs __P((void));
    367 int put __P((void));
    368 int puton __P((void));
    369 const char *rate __P((void));
    370 void ravage __P((void));
    371 void restore __P((const char *));
    372 int ride __P((void));
    373 void save __P((const char *));
    374 char *save_file_name __P((const char *, size_t));
    375 int shoot __P((void));
    376 int take __P((unsigned int[]));
    377 int takeoff __P((void));
    378 int throw __P((const char *));
    379 const char *truedirec __P((int, char));
    380 int ucard __P((const unsigned int *));
    381 int use __P((void));
    382 int visual __P((void));
    383 int wearit __P((void));
    384 void whichway __P((struct room));
    385 void wordinit __P((void));
    386 void writedes __P((void));
    387 int zzz __P((void));
    388