Home | History | Annotate | Line # | Download | only in battlestar
extern.h revision 1.7
      1 /*	$NetBSD: extern.h,v 1.7 1998/02/03 05:39:25 perry 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 <sys/time.h>
     39 
     40 #include <ctype.h>
     41 #include <err.h>
     42 #include <pwd.h>
     43 #include <signal.h>
     44 #include <stdio.h>
     45 #include <stdlib.h>
     46 #include <string.h>
     47 #include <unistd.h>
     48 
     49 #define BITS (8 * sizeof (int))
     50 
     51 #define OUTSIDE		(position > 68 && position < 246 && position != 218)
     52 #define rnd(x)		(rand() % (x))
     53 #define max(a,b)	((a) < (b) ? (b) : (a))
     54 #define testbit(array, index)	(array[index/BITS] & (1 << (index % BITS)))
     55 #define setbit(array, index)	(array[index/BITS] |= (1 << (index % BITS)))
     56 #define clearbit(array, index)	(array[index/BITS] &= ~(1 << (index % BITS)))
     57 
     58  /* well known rooms */
     59 #define FINAL	275
     60 #define GARDEN	197
     61 #define POOLS	126
     62 #define DOCK	93
     63 
     64  /* word types */
     65 #define VERB	0
     66 #define OBJECT  1
     67 #define NOUNS	2
     68 #define PREPS	3
     69 #define ADJS	4
     70 #define CONJ	5
     71 
     72  /* words numbers */
     73 #define KNIFE		0
     74 #define SWORD		1
     75 #define LAND		2
     76 #define WOODSMAN 	3
     77 #define TWO_HANDED	4
     78 #define CLEAVER		5
     79 #define BROAD		6
     80 #define MAIL		7
     81 #define HELM		8
     82 #define SHIELD		9
     83 #define MAID		10
     84 #define BODY		10
     85 #define VIPER		11
     86 #define LAMPON		12
     87 #define SHOES		13
     88 #define CYLON		14
     89 #define PAJAMAS		15
     90 #define ROBE		16
     91 #define AMULET		17
     92 #define MEDALION	18
     93 #define TALISMAN	19
     94 #define DEADWOOD	20
     95 #define MALLET		21
     96 #define LASER		22
     97 #define BATHGOD		23
     98 #define NORMGOD		24
     99 #define GRENADE		25
    100 #define CHAIN		26
    101 #define ROPE		27
    102 #define LEVIS		28
    103 #define MACE		29
    104 #define SHOVEL		30
    105 #define HALBERD		31
    106 #define	COMPASS		32
    107 #define	CRASH		33
    108 #define ELF		34
    109 #define FOOT		35
    110 #define COINS		36
    111 #define MATCHES		37
    112 #define MAN		38
    113 #define PAPAYAS		39
    114 #define PINEAPPLE	40
    115 #define KIWI		41
    116 #define COCONUTS	42
    117 #define MANGO		43
    118 #define RING		44
    119 #define POTION		45
    120 #define BRACELET	46
    121 #define GIRL		47
    122 #define GIRLTALK	48
    123 #define DARK		49
    124 #define TIMER		50
    125 #define CHAR		53
    126 #define BOMB		54
    127 #define DEADGOD		55
    128 #define DEADTIME	56
    129 #define DEADNATIVE	57
    130 #define NATIVE		58
    131 #define HORSE		59
    132 #define CAR		60
    133 #define POT		61
    134 #define BAR		62
    135 #define	BLOCK		63
    136 #define NUMOFOBJECTS	64
    137  /* non-objects below */
    138 #define UP	1000
    139 #define DOWN	1001
    140 #define AHEAD	1002
    141 #define BACK	1003
    142 #define RIGHT	1004
    143 #define LEFT	1005
    144 #define TAKE	1006
    145 #define USE	1007
    146 #define LOOK	1008
    147 #define QUIT	1009
    148 #define NORTH	1010
    149 #define SOUTH	1011
    150 #define EAST	1012
    151 #define WEST	1013
    152 #define SU      1014
    153 #define DROP	1015
    154 #define TAKEOFF	1016
    155 #define DRAW	1017
    156 #define PUTON	1018
    157 #define WEARIT	1019
    158 #define PUT	1020
    159 #define INVEN	1021
    160 #define EVERYTHING 1022
    161 #define AND	1023
    162 #define KILL	1024
    163 #define RAVAGE	1025
    164 #define UNDRESS	1026
    165 #define THROW	1027
    166 #define LAUNCH	1028
    167 #define LANDIT	1029
    168 #define LIGHT	1030
    169 #define FOLLOW	1031
    170 #define KISS	1032
    171 #define LOVE	1033
    172 #define GIVE	1034
    173 #define SMITE	1035
    174 #define SHOOT	1036
    175 #define ON	1037
    176 #define	OFF	1038
    177 #define TIME	1039
    178 #define SLEEP	1040
    179 #define DIG	1041
    180 #define EAT	1042
    181 #define SWIM	1043
    182 #define DRINK	1044
    183 #define DOOR	1045
    184 #define SAVE	1046
    185 #define RIDE	1047
    186 #define DRIVE	1048
    187 #define SCORE	1049
    188 #define BURY	1050
    189 #define JUMP	1051
    190 #define KICK	1052
    191 
    192  /* injuries */
    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
    200 
    201  /* notes */
    202 #define	CANTLAUNCH	0
    203 #define LAUNCHED	1
    204 #define CANTSEE		2
    205 #define CANTMOVE	3
    206 #define JINXED		4
    207 #define DUG		5
    208 #define NUMOFNOTES	6
    209 
    210  /* fundamental constants */
    211 #define NUMOFROOMS	275
    212 #define NUMOFWORDS	((NUMOFOBJECTS + BITS - 1) / BITS)
    213 #define LINELENGTH	81
    214 
    215 #define TODAY		0
    216 #define TONIGHT		1
    217 #define CYCLE		100
    218 
    219  /* initial variable values */
    220 #define TANKFULL	250
    221 #define TORPEDOES	10
    222 #define MAXWEIGHT	60
    223 #define MAXCUMBER	10
    224 
    225 struct room {
    226 	char   *name;
    227 	int     link[8];
    228 #define north	link[0]
    229 #define south	link[1]
    230 #define east	link[2]
    231 #define west	link[3]
    232 #define up	link[4]
    233 #define access	link[5]
    234 #define down	link[6]
    235 #define flyhere	link[7]
    236 	char   *desc;
    237 	unsigned int objects[NUMOFWORDS];
    238 };
    239 struct room dayfile[];
    240 struct room nightfile[];
    241 struct room *location;
    242 
    243  /* object characteristics */
    244 char   *objdes[NUMOFOBJECTS];
    245 char   *objsht[NUMOFOBJECTS];
    246 char   *ouch[NUMOFINJURIES];
    247 int     objwt[NUMOFOBJECTS];
    248 int     objcumber[NUMOFOBJECTS];
    249 
    250  /* current input line */
    251 #define NWORD	20		/* words per line */
    252 char    words[NWORD][15];
    253 int     wordvalue[NWORD];
    254 int     wordtype[NWORD];
    255 int     wordcount, wordnumber;
    256 
    257  /* state of the game */
    258 int     ourtime;
    259 int     position;
    260 int     direction;
    261 int     left, right, ahead, back;
    262 int     ourclock, fuel, torps;
    263 int     carrying, encumber;
    264 int     rythmn;
    265 int     followfight;
    266 int     ate;
    267 int     snooze;
    268 int     meetgirl;
    269 int     followgod;
    270 int     godready;
    271 int     win;
    272 int     wintime;
    273 int     wiz;
    274 int     tempwiz;
    275 int     matchlight, matchcount;
    276 int     loved;
    277 int     pleasure, power, ego;
    278 int     WEIGHT;
    279 int     CUMBER;
    280 int     notes[NUMOFNOTES];
    281 unsigned int inven[NUMOFWORDS];
    282 unsigned int wear[NUMOFWORDS];
    283 char    beenthere[NUMOFROOMS + 1];
    284 char    injuries[NUMOFINJURIES];
    285 
    286 char    uname[9];
    287 
    288 struct wlist {
    289 	char   *string;
    290 	int     value, article;
    291 	struct wlist *next;
    292 };
    293 #define HASHSIZE	256
    294 #define HASHMUL		81
    295 #define HASHMASK	(HASHSIZE - 1)
    296 struct wlist *hashtab[HASHSIZE];
    297 struct wlist wlist[];
    298 
    299 struct objs {
    300 	short   room;
    301 	short   obj;
    302 };
    303 struct objs dayobjs[];
    304 struct objs nightobjs[];
    305 
    306 void blast __P((void));
    307 void bury __P((void));
    308 int card __P((char *, int));
    309 int checkout __P((char *));
    310 void chime __P((void));
    311 void convert __P((int));
    312 void crash __P((void));
    313 int cypher __P((void));
    314 void die __P((void));
    315 void diesig __P((int));
    316 void dig __P((void));
    317 int draw __P((void));
    318 void drink __P((void));
    319 int drive __P((void));
    320 int drop __P((char *));
    321 int eat __P((void));
    322 void endfly __P((void));
    323 int fight __P((int, int));
    324 int follow __P((void));
    325 void getutmp __P((char *));
    326 int give __P((void));
    327 int hash __P((char *));
    328 void initialize __P((char));
    329 void install __P((struct wlist *));
    330 int jump __P((void));
    331 void kiss __P((void));
    332 int land __P((void));
    333 int launch __P((void));
    334 void light __P((void));
    335 void live __P((void));
    336 void love __P((void));
    337 int move __P((int, int));
    338 void moveenemy __P((int));
    339 void murder __P((void));
    340 void news __P((void));
    341 void newway __P((int));
    342 void notarget __P((void));
    343 void parse __P((void));
    344 void post __P((char));
    345 void printobjs __P((void));
    346 int put __P((void));
    347 int puton __P((void));
    348 void ravage __P((void));
    349 void restore __P((void));
    350 int ride __P((void));
    351 void save __P((void));
    352 void screen __P((void));
    353 int shoot __P((void));
    354 void succumb __P((int));
    355 int take __P((unsigned int[]));
    356 int takeoff __P((void));
    357 void target __P((void));
    358 int throw __P((char *));
    359 int ucard __P((unsigned int *));
    360 int use __P((void));
    361 int visual __P((void));
    362 int wearit __P((void));
    363 void whichway __P((struct room));
    364 int wizard __P((char *));
    365 void wordinit __P((void));
    366 void writedes __P((void));
    367 int zzz __P((void));
    368 char   *getcom __P((char *, int, char *, char *));
    369 char   *getword __P((char *, char *, int));
    370 char   *rate __P((void));
    371 char   *truedirec __P((int, char));
    372 struct wlist *lookup __P((char *));
    373