Home | History | Annotate | Line # | Download | only in battlestar
extern.h revision 1.3
      1 /* $NetBSD: extern.h,v 1.3 1997/01/07 12:35:42 tls 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. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *	This product includes software developed by the University of
     18  *	California, Berkeley and its contributors.
     19  * 4. Neither the name of the University nor the names of its contributors
     20  *    may be used to endorse or promote products derived from this software
     21  *    without specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  * SUCH DAMAGE.
     34  *
     35  *	@(#)externs.h	8.1 (Berkeley) 5/31/93
     36  */
     37 
     38 #include <signal.h>
     39 #include <stdio.h>
     40 #include <string.h>
     41 
     42 #define BITS (8 * sizeof (int))
     43 
     44 #define OUTSIDE		(position > 68 && position < 246 && position != 218)
     45 #define rnd(x)		(rand() % (x))
     46 #define max(a,b)	((a) < (b) ? (b) : (a))
     47 #define testbit(array, index)	(array[index/BITS] & (1 << (index % BITS)))
     48 #define setbit(array, index)	(array[index/BITS] |= (1 << (index % BITS)))
     49 #define clearbit(array, index)	(array[index/BITS] &= ~(1 << (index % BITS)))
     50 
     51 	/* well known rooms */
     52 #define FINAL	275
     53 #define GARDEN	197
     54 #define POOLS	126
     55 #define DOCK	93
     56 
     57 	/* word types */
     58 #define VERB	0
     59 #define OBJECT  1
     60 #define NOUNS	2
     61 #define PREPS	3
     62 #define ADJS	4
     63 #define CONJ	5
     64 
     65 	/* words numbers */
     66 #define KNIFE		0
     67 #define SWORD		1
     68 #define LAND		2
     69 #define WOODSMAN 	3
     70 #define TWO_HANDED	4
     71 #define CLEAVER		5
     72 #define BROAD		6
     73 #define MAIL		7
     74 #define HELM		8
     75 #define SHIELD		9
     76 #define MAID		10
     77 #define BODY		10
     78 #define VIPER		11
     79 #define LAMPON		12
     80 #define SHOES		13
     81 #define CYLON		14
     82 #define PAJAMAS		15
     83 #define ROBE		16
     84 #define AMULET		17
     85 #define MEDALION	18
     86 #define TALISMAN	19
     87 #define DEADWOOD	20
     88 #define MALLET		21
     89 #define LASER		22
     90 #define BATHGOD		23
     91 #define NORMGOD		24
     92 #define GRENADE		25
     93 #define CHAIN		26
     94 #define ROPE		27
     95 #define LEVIS		28
     96 #define MACE		29
     97 #define SHOVEL		30
     98 #define HALBERD		31
     99 #define	COMPASS		32
    100 #define	CRASH		33
    101 #define ELF		34
    102 #define FOOT		35
    103 #define COINS		36
    104 #define MATCHES		37
    105 #define MAN		38
    106 #define PAPAYAS		39
    107 #define PINEAPPLE	40
    108 #define KIWI		41
    109 #define COCONUTS	42
    110 #define MANGO		43
    111 #define RING		44
    112 #define POTION		45
    113 #define BRACELET	46
    114 #define GIRL		47
    115 #define GIRLTALK	48
    116 #define DARK		49
    117 #define TIMER		50
    118 #define CHAR		53
    119 #define BOMB		54
    120 #define DEADGOD		55
    121 #define DEADTIME	56
    122 #define DEADNATIVE	57
    123 #define NATIVE		58
    124 #define HORSE		59
    125 #define CAR		60
    126 #define POT		61
    127 #define BAR		62
    128 #define	BLOCK		63
    129 #define NUMOFOBJECTS	64
    130 	/* non-objects below */
    131 #define UP	1000
    132 #define DOWN	1001
    133 #define AHEAD	1002
    134 #define BACK	1003
    135 #define RIGHT	1004
    136 #define LEFT	1005
    137 #define TAKE	1006
    138 #define USE	1007
    139 #define LOOK	1008
    140 #define QUIT	1009
    141 #define NORTH	1010
    142 #define SOUTH	1011
    143 #define EAST	1012
    144 #define WEST	1013
    145 #define SU      1014
    146 #define DROP	1015
    147 #define TAKEOFF	1016
    148 #define DRAW	1017
    149 #define PUTON	1018
    150 #define WEARIT	1019
    151 #define PUT	1020
    152 #define INVEN	1021
    153 #define EVERYTHING 1022
    154 #define AND	1023
    155 #define KILL	1024
    156 #define RAVAGE	1025
    157 #define UNDRESS	1026
    158 #define THROW	1027
    159 #define LAUNCH	1028
    160 #define LANDIT	1029
    161 #define LIGHT	1030
    162 #define FOLLOW	1031
    163 #define KISS	1032
    164 #define LOVE	1033
    165 #define GIVE	1034
    166 #define SMITE	1035
    167 #define SHOOT	1036
    168 #define ON	1037
    169 #define	OFF	1038
    170 #define TIME	1039
    171 #define SLEEP	1040
    172 #define DIG	1041
    173 #define EAT	1042
    174 #define SWIM	1043
    175 #define DRINK	1044
    176 #define DOOR	1045
    177 #define SAVE	1046
    178 #define RIDE	1047
    179 #define DRIVE	1048
    180 #define SCORE	1049
    181 #define BURY	1050
    182 #define JUMP	1051
    183 #define KICK	1052
    184 
    185 	/* injuries */
    186 #define ARM	6		/* broken arm */
    187 #define RIBS	7		/* broken ribs */
    188 #define SPINE	9		/* broken back */
    189 #define SKULL	11		/* fractured skull */
    190 #define INCISE	10		/* deep incisions */
    191 #define NECK	12		/* broken NECK */
    192 #define NUMOFINJURIES 13
    193 
    194 	/* notes */
    195 #define	CANTLAUNCH	0
    196 #define LAUNCHED	1
    197 #define CANTSEE		2
    198 #define CANTMOVE	3
    199 #define JINXED		4
    200 #define DUG		5
    201 #define NUMOFNOTES	6
    202 
    203 	/* fundamental constants */
    204 #define NUMOFROOMS	275
    205 #define NUMOFWORDS	((NUMOFOBJECTS + BITS - 1) / BITS)
    206 #define LINELENGTH	81
    207 
    208 #define TODAY		0
    209 #define TONIGHT		1
    210 #define CYCLE		100
    211 
    212 	/* initial variable values */
    213 #define TANKFULL	250
    214 #define TORPEDOES	10
    215 #define MAXWEIGHT	60
    216 #define MAXCUMBER	10
    217 
    218 struct room {
    219 	char *name;
    220 	int link[8];
    221 #define north	link[0]
    222 #define south	link[1]
    223 #define east	link[2]
    224 #define west	link[3]
    225 #define up	link[4]
    226 #define access	link[5]
    227 #define down	link[6]
    228 #define flyhere	link[7]
    229 	char *desc;
    230 	unsigned int objects[NUMOFWORDS];
    231 };
    232 struct room dayfile[];
    233 struct room nightfile[];
    234 struct room *location;
    235 
    236 	/* object characteristics */
    237 char *objdes[NUMOFOBJECTS];
    238 char *objsht[NUMOFOBJECTS];
    239 char *ouch[NUMOFINJURIES];
    240 int objwt[NUMOFOBJECTS];
    241 int objcumber[NUMOFOBJECTS];
    242 
    243 	/* current input line */
    244 #define NWORD	20			/* words per line */
    245 char words[NWORD][15];
    246 int wordvalue[NWORD];
    247 int wordtype[NWORD];
    248 int wordcount, wordnumber;
    249 
    250 char *truedirec(), *rate();
    251 char *getcom(), *getword();
    252 
    253 	/* state of the game */
    254 int time;
    255 int position;
    256 int direction;
    257 int left, right, ahead, back;
    258 int clock, fuel, torps;
    259 int carrying, encumber;
    260 int rythmn;
    261 int followfight;
    262 int ate;
    263 int snooze;
    264 int meetgirl;
    265 int followgod;
    266 int godready;
    267 int win;
    268 int wintime;
    269 int wiz;
    270 int tempwiz;
    271 int matchlight, matchcount;
    272 int loved;
    273 int pleasure, power, ego;
    274 int WEIGHT;
    275 int CUMBER;
    276 int notes[NUMOFNOTES];
    277 unsigned int inven[NUMOFWORDS];
    278 unsigned int wear[NUMOFWORDS];
    279 char beenthere[NUMOFROOMS+1];
    280 char injuries[NUMOFINJURIES];
    281 
    282 char uname[9];
    283 
    284 struct wlist {
    285 	char *string;
    286 	int value, article;
    287 	struct wlist *next;
    288 };
    289 #define HASHSIZE	256
    290 #define HASHMUL		81
    291 #define HASHMASK	(HASHSIZE - 1)
    292 struct wlist *hashtab[HASHSIZE];
    293 struct wlist wlist[];
    294 
    295 struct objs {
    296 	short room;
    297 	short obj;
    298 };
    299 struct objs dayobjs[];
    300 struct objs nightobjs[];
    301