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