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