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