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