main.c revision 1.18 1 1.18 jsm /* $NetBSD: main.c,v 1.18 2004/01/27 20:30:28 jsm Exp $ */
2 1.2 cgd
3 1.1 jtc /*-
4 1.1 jtc * Copyright (c) 1991, 1993
5 1.1 jtc * The Regents of the University of California. All rights reserved.
6 1.1 jtc *
7 1.1 jtc * The game adventure was originally written in Fortran by Will Crowther
8 1.1 jtc * and Don Woods. It was later translated to C and enhanced by Jim
9 1.1 jtc * Gillogly. This code is derived from software contributed to Berkeley
10 1.1 jtc * by Jim Gillogly at The Rand Corporation.
11 1.1 jtc *
12 1.1 jtc * Redistribution and use in source and binary forms, with or without
13 1.1 jtc * modification, are permitted provided that the following conditions
14 1.1 jtc * are met:
15 1.1 jtc * 1. Redistributions of source code must retain the above copyright
16 1.1 jtc * notice, this list of conditions and the following disclaimer.
17 1.1 jtc * 2. Redistributions in binary form must reproduce the above copyright
18 1.1 jtc * notice, this list of conditions and the following disclaimer in the
19 1.1 jtc * documentation and/or other materials provided with the distribution.
20 1.17 agc * 3. Neither the name of the University nor the names of its contributors
21 1.1 jtc * may be used to endorse or promote products derived from this software
22 1.1 jtc * without specific prior written permission.
23 1.1 jtc *
24 1.1 jtc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 1.1 jtc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 1.1 jtc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 1.1 jtc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 1.1 jtc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 1.1 jtc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 1.1 jtc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 1.1 jtc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 1.1 jtc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 1.1 jtc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 1.1 jtc * SUCH DAMAGE.
35 1.1 jtc */
36 1.1 jtc
37 1.6 christos #include <sys/cdefs.h>
38 1.1 jtc #ifndef lint
39 1.6 christos __COPYRIGHT("@(#) Copyright (c) 1991, 1993\n\
40 1.6 christos The Regents of the University of California. All rights reserved.\n");
41 1.1 jtc #endif /* not lint */
42 1.1 jtc
43 1.1 jtc #ifndef lint
44 1.2 cgd #if 0
45 1.1 jtc static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/2/93";
46 1.2 cgd #else
47 1.18 jsm __RCSID("$NetBSD: main.c,v 1.18 2004/01/27 20:30:28 jsm Exp $");
48 1.2 cgd #endif
49 1.1 jtc #endif /* not lint */
50 1.1 jtc
51 1.8 lukem /* Re-coding of advent in C: main program */
52 1.1 jtc
53 1.1 jtc #include <sys/file.h>
54 1.8 lukem #include <err.h>
55 1.5 mrg #include <signal.h>
56 1.1 jtc #include <stdio.h>
57 1.16 matt #include <stdlib.h>
58 1.6 christos #include <unistd.h>
59 1.1 jtc #include "hdr.h"
60 1.6 christos #include "extern.h"
61 1.10 hubertf
62 1.18 jsm int main(int, char **);
63 1.1 jtc
64 1.6 christos int
65 1.8 lukem main(argc, argv)
66 1.8 lukem int argc;
67 1.8 lukem char **argv;
68 1.1 jtc {
69 1.8 lukem int i;
70 1.8 lukem int rval, ll;
71 1.1 jtc struct text *kk;
72 1.1 jtc
73 1.13 hubertf /* revoke setgid privileges from dm */
74 1.15 mycroft setgid(getgid());
75 1.4 mrg
76 1.9 hubertf init(); /* Initialize everything */
77 1.8 lukem signal(SIGINT, trapdel);
78 1.1 jtc
79 1.8 lukem if (argc > 1) { /* Restore file specified */
80 1.8 lukem /* Restart is label 8305 (Fortran) */
81 1.8 lukem i = restore(argv[1]); /* See what we've got */
82 1.8 lukem switch (i) {
83 1.8 lukem case 0: /* The restore worked fine */
84 1.9 hubertf yea = Start();
85 1.8 lukem k = null;
86 1.8 lukem unlink(argv[1]); /* Don't re-use the save */
87 1.8 lukem goto l8; /* Get where we're going */
88 1.8 lukem case 1: /* Couldn't open it */
89 1.12 hubertf errx(1,"can't open file"); /* So give up */
90 1.8 lukem case 2: /* Oops -- file was altered */
91 1.8 lukem rspeak(202); /* You dissolve */
92 1.12 hubertf exit(1); /* File could be non-adventure */
93 1.8 lukem } /* So don't unlink it. */
94 1.1 jtc }
95 1.8 lukem startup(); /* prepare for a user */
96 1.1 jtc
97 1.8 lukem for (;;) { /* main command loop (label 2) */
98 1.8 lukem if (newloc < 9 && newloc != 0 && closng) {
99 1.8 lukem rspeak(130); /* if closing leave only by */
100 1.8 lukem newloc = loc; /* main office */
101 1.8 lukem if (!panic)
102 1.8 lukem clock2 = 15;
103 1.8 lukem panic = TRUE;
104 1.8 lukem }
105 1.8 lukem rval = fdwarf(); /* dwarf stuff */
106 1.8 lukem if (rval == 99)
107 1.8 lukem die(99);
108 1.1 jtc
109 1.8 lukem l2000: if (loc == 0)
110 1.8 lukem die(99); /* label 2000 */
111 1.1 jtc kk = &stext[loc];
112 1.8 lukem if ((abb[loc] % abbnum) == 0 || kk->seekadr == 0)
113 1.1 jtc kk = <ext[loc];
114 1.9 hubertf if (!forced(loc) && dark()) {
115 1.8 lukem if (wzdark && pct(35)) {
116 1.8 lukem die(90);
117 1.1 jtc goto l2000;
118 1.1 jtc }
119 1.1 jtc kk = &rtext[16];
120 1.1 jtc }
121 1.6 christos #if 0
122 1.8 lukem l2001:
123 1.6 christos #endif
124 1.8 lukem if (toting(bear))
125 1.8 lukem rspeak(141); /* 2001 */
126 1.1 jtc speak(kk);
127 1.8 lukem k = 1;
128 1.1 jtc if (forced(loc))
129 1.1 jtc goto l8;
130 1.8 lukem if (loc == 33 && pct(25) && !closng)
131 1.8 lukem rspeak(8);
132 1.9 hubertf if (!dark()) {
133 1.8 lukem abb[loc]++;
134 1.8 lukem for (i = atloc[loc]; i != 0; i = links[i]) { /* 2004 */
135 1.8 lukem obj = i;
136 1.8 lukem if (obj > 100)
137 1.8 lukem obj -= 100;
138 1.8 lukem if (obj == steps && toting(nugget))
139 1.8 lukem continue;
140 1.8 lukem if (prop[obj] < 0) {
141 1.8 lukem if (closed)
142 1.8 lukem continue;
143 1.8 lukem prop[obj] = 0;
144 1.8 lukem if (obj == rug || obj == chain)
145 1.8 lukem prop[obj] = 1;
146 1.1 jtc tally--;
147 1.8 lukem if (tally == tally2 && tally != 0)
148 1.8 lukem if (limit > 35)
149 1.8 lukem limit = 35;
150 1.1 jtc }
151 1.8 lukem ll = prop[obj]; /* 2006 */
152 1.8 lukem if (obj == steps && loc == fixed[steps])
153 1.1 jtc ll = 1;
154 1.1 jtc pspeak(obj, ll);
155 1.8 lukem } /* 2008 */
156 1.1 jtc goto l2012;
157 1.8 lukem l2009: k = 54; /* 2009 */
158 1.8 lukem l2010: spk = k;
159 1.8 lukem l2011: rspeak(spk);
160 1.8 lukem }
161 1.8 lukem l2012: verb = 0; /* 2012 */
162 1.8 lukem obj = 0;
163 1.8 lukem l2600: checkhints(); /* to 2600-2602 */
164 1.8 lukem if (closed) {
165 1.8 lukem if (prop[oyster] < 0 && toting(oyster))
166 1.8 lukem pspeak(oyster, 1);
167 1.8 lukem for (i = 1; i < 100; i++)
168 1.8 lukem if (toting(i) && prop[i] < 0) /* 2604 */
169 1.8 lukem prop[i] = -1 - prop[i];
170 1.8 lukem }
171 1.9 hubertf wzdark = dark(); /* 2605 */
172 1.8 lukem if (knfloc > 0 && knfloc != loc)
173 1.8 lukem knfloc = 1;
174 1.8 lukem getin(&wd1, &wd2);
175 1.8 lukem if (delhit) { /* user typed a DEL */
176 1.8 lukem delhit = 0; /* reset counter */
177 1.8 lukem copystr("quit", wd1); /* pretend he's quitting */
178 1.8 lukem *wd2 = 0;
179 1.8 lukem }
180 1.8 lukem l2608: if ((foobar = -foobar) > 0)
181 1.8 lukem foobar = 0; /* 2608 */
182 1.8 lukem /* should check here for "magic mode" */
183 1.1 jtc turns++;
184 1.8 lukem if (demo && turns >= SHORT)
185 1.8 lukem done(1); /* to 13000 */
186 1.1 jtc
187 1.8 lukem if (verb == say && *wd2 != 0)
188 1.8 lukem verb = 0;
189 1.8 lukem if (verb == say)
190 1.1 jtc goto l4090;
191 1.8 lukem if (tally == 0 && loc >= 15 && loc != 33)
192 1.8 lukem clock1--;
193 1.8 lukem if (clock1 == 0) {
194 1.8 lukem closing(); /* to 10000 */
195 1.1 jtc goto l19999;
196 1.1 jtc }
197 1.8 lukem if (clock1 < 0)
198 1.8 lukem clock2--;
199 1.8 lukem if (clock2 == 0) {
200 1.8 lukem caveclose(); /* to 11000 */
201 1.8 lukem continue; /* back to 2 */
202 1.8 lukem }
203 1.8 lukem if (prop[lamp] == 1)
204 1.8 lukem limit--;
205 1.8 lukem if (limit <= 30 && here(batter) && prop[batter] == 0
206 1.8 lukem && here(lamp)) {
207 1.8 lukem rspeak(188); /* 12000 */
208 1.8 lukem prop[batter] = 1;
209 1.8 lukem if (toting(batter))
210 1.8 lukem drop(batter, loc);
211 1.8 lukem limit = limit + 2500;
212 1.8 lukem lmwarn = FALSE;
213 1.1 jtc goto l19999;
214 1.1 jtc }
215 1.8 lukem if (limit == 0) {
216 1.8 lukem limit = -1; /* 12400 */
217 1.8 lukem prop[lamp] = 0;
218 1.1 jtc rspeak(184);
219 1.1 jtc goto l19999;
220 1.1 jtc }
221 1.8 lukem if (limit < 0 && loc <= 8) {
222 1.8 lukem rspeak(185); /* 12600 */
223 1.8 lukem gaveup = TRUE;
224 1.8 lukem done(2); /* to 20000 */
225 1.8 lukem }
226 1.8 lukem if (limit <= 30) {
227 1.8 lukem if (lmwarn || !here(lamp))
228 1.8 lukem goto l19999; /* 12200 */
229 1.8 lukem lmwarn = TRUE;
230 1.8 lukem spk = 187;
231 1.8 lukem if (place[batter] == 0)
232 1.8 lukem spk = 183;
233 1.8 lukem if (prop[batter] == 1)
234 1.8 lukem spk = 189;
235 1.1 jtc rspeak(spk);
236 1.1 jtc }
237 1.8 lukem l19999: k = 43;
238 1.8 lukem if (liqloc(loc) == water)
239 1.8 lukem k = 70;
240 1.8 lukem if (weq(wd1, "enter") &&
241 1.8 lukem (weq(wd2, "strea") || weq(wd2, "water")))
242 1.1 jtc goto l2010;
243 1.8 lukem if (weq(wd1, "enter") && *wd2 != 0)
244 1.8 lukem goto l2800;
245 1.8 lukem if ((!weq(wd1, "water") && !weq(wd1, "oil"))
246 1.8 lukem || (!weq(wd2, "plant") && !weq(wd2, "door")))
247 1.1 jtc goto l2610;
248 1.8 lukem if (at(vocab(wd2, 1, 0)))
249 1.8 lukem copystr("pour", wd2);
250 1.1 jtc
251 1.8 lukem l2610: if (weq(wd1, "west"))
252 1.8 lukem if (++iwest == 10)
253 1.8 lukem rspeak(17);
254 1.8 lukem l2630: i = vocab(wd1, -1, 0);
255 1.8 lukem if (i == -1) {
256 1.8 lukem spk = 60; /* 3000 */
257 1.8 lukem if (pct(20))
258 1.8 lukem spk = 61;
259 1.8 lukem if (pct(20))
260 1.8 lukem spk = 13;
261 1.1 jtc rspeak(spk);
262 1.1 jtc goto l2600;
263 1.1 jtc }
264 1.8 lukem k = i % 1000;
265 1.8 lukem kq = i / 1000 + 1;
266 1.8 lukem switch (kq) {
267 1.8 lukem case 1:
268 1.8 lukem goto l8;
269 1.8 lukem case 2:
270 1.8 lukem goto l5000;
271 1.8 lukem case 3:
272 1.8 lukem goto l4000;
273 1.8 lukem case 4:
274 1.8 lukem goto l2010;
275 1.8 lukem default:
276 1.12 hubertf bug(22);
277 1.1 jtc }
278 1.1 jtc
279 1.8 lukem l8:
280 1.8 lukem switch (march()) {
281 1.8 lukem case 2:
282 1.8 lukem continue; /* i.e. goto l2 */
283 1.8 lukem case 99:
284 1.11 hubertf die(99);
285 1.11 hubertf goto l2000;
286 1.8 lukem default:
287 1.8 lukem bug(110);
288 1.1 jtc }
289 1.1 jtc
290 1.8 lukem l2800: copystr(wd2, wd1);
291 1.8 lukem *wd2 = 0;
292 1.1 jtc goto l2610;
293 1.1 jtc
294 1.8 lukem l4000: verb = k;
295 1.8 lukem spk = actspk[verb];
296 1.8 lukem if (*wd2 != 0 && verb != say)
297 1.8 lukem goto l2800;
298 1.8 lukem if (verb == say)
299 1.8 lukem obj = *wd2;
300 1.8 lukem if (obj != 0)
301 1.8 lukem goto l4090;
302 1.6 christos #if 0
303 1.8 lukem l4080:
304 1.6 christos #endif
305 1.8 lukem switch (verb) {
306 1.8 lukem case 1: /* take = 8010 */
307 1.8 lukem if (atloc[loc] == 0 || links[atloc[loc]] != 0)
308 1.8 lukem goto l8000;
309 1.8 lukem for (i = 1; i <= 5; i++)
310 1.8 lukem if (dloc[i] == loc && dflag >= 2)
311 1.8 lukem goto l8000;
312 1.8 lukem obj = atloc[loc];
313 1.1 jtc goto l9010;
314 1.8 lukem case 2:
315 1.8 lukem case 3:
316 1.8 lukem case 9: /* 8000 : drop,say,wave */
317 1.8 lukem case 10:
318 1.8 lukem case 16:
319 1.8 lukem case 17: /* calm,rub,toss */
320 1.8 lukem case 19:
321 1.8 lukem case 21:
322 1.8 lukem case 28: /* find,feed,break */
323 1.8 lukem case 29: /* wake */
324 1.8 lukem l8000: printf("%s what?\n", wd1);
325 1.8 lukem obj = 0;
326 1.1 jtc goto l2600;
327 1.8 lukem case 4:
328 1.8 lukem case 6: /* 8040 open,lock */
329 1.8 lukem spk = 28;
330 1.8 lukem if (here(clam))
331 1.8 lukem obj = clam;
332 1.8 lukem if (here(oyster))
333 1.8 lukem obj = oyster;
334 1.8 lukem if (at(door))
335 1.8 lukem obj = door;
336 1.8 lukem if (at(grate))
337 1.8 lukem obj = grate;
338 1.8 lukem if (obj != 0 && here(chain))
339 1.8 lukem goto l8000;
340 1.8 lukem if (here(chain))
341 1.8 lukem obj = chain;
342 1.8 lukem if (obj == 0)
343 1.8 lukem goto l2011;
344 1.1 jtc goto l9040;
345 1.8 lukem case 5:
346 1.8 lukem goto l2009; /* nothing */
347 1.8 lukem case 7:
348 1.8 lukem goto l9070; /* on */
349 1.8 lukem case 8:
350 1.8 lukem goto l9080; /* off */
351 1.8 lukem case 11:
352 1.8 lukem goto l8000; /* walk */
353 1.8 lukem case 12:
354 1.8 lukem goto l9120; /* kill */
355 1.8 lukem case 13:
356 1.8 lukem goto l9130; /* pour */
357 1.8 lukem case 14: /* eat: 8140 */
358 1.8 lukem if (!here(food))
359 1.8 lukem goto l8000;
360 1.8 lukem l8142: dstroy(food);
361 1.8 lukem spk = 72;
362 1.1 jtc goto l2011;
363 1.8 lukem case 15:
364 1.8 lukem goto l9150; /* drink */
365 1.8 lukem case 18: /* quit: 8180 */
366 1.8 lukem gaveup = yes(22, 54, 54);
367 1.8 lukem if (gaveup)
368 1.8 lukem done(2); /* 8185 */
369 1.1 jtc goto l2012;
370 1.8 lukem case 20: /* invent=8200 */
371 1.8 lukem spk = 98;
372 1.8 lukem for (i = 1; i <= 100; i++) {
373 1.8 lukem if (i != bear && toting(i)) {
374 1.8 lukem if (spk == 98)
375 1.8 lukem rspeak(99);
376 1.8 lukem blklin = FALSE;
377 1.8 lukem pspeak(i, -1);
378 1.8 lukem blklin = TRUE;
379 1.8 lukem spk = 0;
380 1.1 jtc }
381 1.1 jtc }
382 1.8 lukem if (toting(bear))
383 1.8 lukem spk = 141;
384 1.1 jtc goto l2011;
385 1.8 lukem case 22:
386 1.8 lukem goto l9220; /* fill */
387 1.8 lukem case 23:
388 1.8 lukem goto l9230; /* blast */
389 1.8 lukem case 24: /* score: 8240 */
390 1.8 lukem scorng = TRUE;
391 1.1 jtc printf("If you were to quit now, you would score");
392 1.8 lukem printf(" %d out of a possible ", score());
393 1.8 lukem printf("%d.", mxscor);
394 1.8 lukem scorng = FALSE;
395 1.8 lukem gaveup = yes(143, 54, 54);
396 1.8 lukem if (gaveup)
397 1.8 lukem done(2);
398 1.1 jtc goto l2012;
399 1.8 lukem case 25: /* foo: 8250 */
400 1.8 lukem k = vocab(wd1, 3, 0);
401 1.8 lukem spk = 42;
402 1.8 lukem if (foobar == 1 - k)
403 1.8 lukem goto l8252;
404 1.8 lukem if (foobar != 0)
405 1.8 lukem spk = 151;
406 1.1 jtc goto l2011;
407 1.8 lukem l8252: foobar = k;
408 1.8 lukem if (k != 4)
409 1.8 lukem goto l2009;
410 1.8 lukem foobar = 0;
411 1.8 lukem if (place[eggs] == plac[eggs]
412 1.8 lukem || (toting(eggs) && loc == plac[eggs]))
413 1.8 lukem goto l2011;
414 1.8 lukem if (place[eggs] == 0 && place[troll] == 0 && prop[troll] == 0)
415 1.8 lukem prop[troll] = 1;
416 1.8 lukem k = 2;
417 1.8 lukem if (here(eggs))
418 1.8 lukem k = 1;
419 1.8 lukem if (loc == plac[eggs])
420 1.8 lukem k = 0;
421 1.8 lukem move(eggs, plac[eggs]);
422 1.8 lukem pspeak(eggs, k);
423 1.1 jtc goto l2012;
424 1.8 lukem case 26: /* brief=8260 */
425 1.8 lukem spk = 156;
426 1.8 lukem abbnum = 10000;
427 1.8 lukem detail = 3;
428 1.1 jtc goto l2011;
429 1.8 lukem case 27: /* read=8270 */
430 1.8 lukem if (here(magzin))
431 1.8 lukem obj = magzin;
432 1.8 lukem if (here(tablet))
433 1.8 lukem obj = obj * 100 + tablet;
434 1.8 lukem if (here(messag))
435 1.8 lukem obj = obj * 100 + messag;
436 1.8 lukem if (closed && toting(oyster))
437 1.8 lukem obj = oyster;
438 1.9 hubertf if (obj > 100 || obj == 0 || dark())
439 1.8 lukem goto l8000;
440 1.1 jtc goto l9270;
441 1.8 lukem case 30: /* suspend=8300 */
442 1.8 lukem spk = 201;
443 1.8 lukem if (demo)
444 1.8 lukem goto l2011;
445 1.1 jtc printf("I can suspend your adventure for you so");
446 1.1 jtc printf(" you can resume later, but\n");
447 1.1 jtc printf("you will have to wait at least");
448 1.8 lukem printf(" %d minutes before continuing.", latncy);
449 1.8 lukem if (!yes(200, 54, 54))
450 1.8 lukem goto l2012;
451 1.14 hubertf datime(&saveday, &savet);
452 1.9 hubertf ciao(); /* Do we quit? */
453 1.8 lukem continue; /* Maybe not */
454 1.8 lukem case 31: /* hours=8310 */
455 1.1 jtc printf("Colossal cave is closed 9am-5pm Mon ");
456 1.1 jtc printf("through Fri except holidays.\n");
457 1.1 jtc goto l2012;
458 1.8 lukem default:
459 1.8 lukem bug(23);
460 1.1 jtc }
461 1.1 jtc
462 1.8 lukem l4090:
463 1.8 lukem switch (verb) {
464 1.8 lukem case 1: /* take = 9010 */
465 1.8 lukem l9010: switch (trtake()) {
466 1.8 lukem case 2011:
467 1.8 lukem goto l2011;
468 1.8 lukem case 9220:
469 1.8 lukem goto l9220;
470 1.8 lukem case 2009:
471 1.8 lukem goto l2009;
472 1.8 lukem case 2012:
473 1.8 lukem goto l2012;
474 1.8 lukem default:
475 1.8 lukem bug(102);
476 1.8 lukem }
477 1.8 lukem l9020: case 2: /* drop = 9020 */
478 1.8 lukem switch (trdrop()) {
479 1.8 lukem case 2011:
480 1.8 lukem goto l2011;
481 1.8 lukem case 19000:
482 1.8 lukem done(3);
483 1.8 lukem case 2012:
484 1.8 lukem goto l2012;
485 1.8 lukem default:
486 1.8 lukem bug(105);
487 1.1 jtc }
488 1.6 christos #if 0
489 1.6 christos l9030:
490 1.6 christos #endif
491 1.8 lukem case 3:
492 1.8 lukem switch (trsay()) {
493 1.8 lukem case 2012:
494 1.8 lukem goto l2012;
495 1.8 lukem case 2630:
496 1.8 lukem goto l2630;
497 1.8 lukem default:
498 1.8 lukem bug(107);
499 1.8 lukem }
500 1.8 lukem l9040: case 4:
501 1.8 lukem case 6: /* open, close */
502 1.8 lukem switch (tropen()) {
503 1.8 lukem case 2011:
504 1.8 lukem goto l2011;
505 1.8 lukem case 2010:
506 1.8 lukem goto l2010;
507 1.8 lukem default:
508 1.8 lukem bug(106);
509 1.8 lukem }
510 1.8 lukem case 5:
511 1.8 lukem goto l2009; /* nothing */
512 1.8 lukem case 7: /* on 9070 */
513 1.8 lukem l9070: if (!here(lamp))
514 1.8 lukem goto l2011;
515 1.8 lukem spk = 184;
516 1.8 lukem if (limit < 0)
517 1.8 lukem goto l2011;
518 1.8 lukem prop[lamp] = 1;
519 1.1 jtc rspeak(39);
520 1.8 lukem if (wzdark)
521 1.8 lukem goto l2000;
522 1.1 jtc goto l2012;
523 1.1 jtc
524 1.8 lukem case 8: /* off */
525 1.8 lukem l9080: if (!here(lamp))
526 1.8 lukem goto l2011;
527 1.8 lukem prop[lamp] = 0;
528 1.1 jtc rspeak(40);
529 1.9 hubertf if (dark())
530 1.8 lukem rspeak(16);
531 1.1 jtc goto l2012;
532 1.1 jtc
533 1.8 lukem case 9: /* wave */
534 1.8 lukem if ((!toting(obj)) && (obj != rod || !toting(rod2)))
535 1.8 lukem spk = 29;
536 1.8 lukem if (obj != rod || !at(fissur) || !toting(obj) || closng)
537 1.1 jtc goto l2011;
538 1.8 lukem prop[fissur] = 1 - prop[fissur];
539 1.8 lukem pspeak(fissur, 2 - prop[fissur]);
540 1.1 jtc goto l2012;
541 1.8 lukem case 10:
542 1.8 lukem case 11:
543 1.8 lukem case 18: /* calm, walk, quit */
544 1.8 lukem case 24:
545 1.8 lukem case 25:
546 1.8 lukem case 26: /* score, foo, brief */
547 1.8 lukem case 30:
548 1.8 lukem case 31: /* suspend, hours */
549 1.8 lukem goto l2011;
550 1.8 lukem l9120: case 12:/* kill */
551 1.8 lukem switch (trkill()) {
552 1.8 lukem case 8000:
553 1.8 lukem goto l8000;
554 1.8 lukem case 8:
555 1.8 lukem goto l8;
556 1.8 lukem case 2011:
557 1.8 lukem goto l2011;
558 1.8 lukem case 2608:
559 1.8 lukem goto l2608;
560 1.8 lukem case 19000:
561 1.8 lukem done(3);
562 1.8 lukem default:
563 1.8 lukem bug(112);
564 1.8 lukem }
565 1.8 lukem l9130: case 13:/* pour */
566 1.8 lukem if (obj == bottle || obj == 0)
567 1.9 hubertf obj = liq();
568 1.8 lukem if (obj == 0)
569 1.8 lukem goto l8000;
570 1.8 lukem if (!toting(obj))
571 1.8 lukem goto l2011;
572 1.8 lukem spk = 78;
573 1.8 lukem if (obj != oil && obj != water)
574 1.8 lukem goto l2011;
575 1.8 lukem prop[bottle] = 1;
576 1.8 lukem place[obj] = 0;
577 1.8 lukem spk = 77;
578 1.8 lukem if (!(at(plant) || at(door)))
579 1.8 lukem goto l2011;
580 1.8 lukem if (at(door)) {
581 1.8 lukem prop[door] = 0; /* 9132 */
582 1.8 lukem if (obj == oil)
583 1.8 lukem prop[door] = 1;
584 1.8 lukem spk = 113 + prop[door];
585 1.1 jtc goto l2011;
586 1.1 jtc }
587 1.8 lukem spk = 112;
588 1.8 lukem if (obj != water)
589 1.8 lukem goto l2011;
590 1.8 lukem pspeak(plant, prop[plant] + 1);
591 1.8 lukem prop[plant] = (prop[plant] + 2) % 6;
592 1.8 lukem prop[plant2] = prop[plant] / 2;
593 1.8 lukem k = null;
594 1.1 jtc goto l8;
595 1.8 lukem case 14: /* 9140 - eat */
596 1.8 lukem if (obj == food)
597 1.8 lukem goto l8142;
598 1.8 lukem if (obj == bird || obj == snake || obj == clam || obj == oyster
599 1.8 lukem || obj == dwarf || obj == dragon || obj == troll
600 1.8 lukem || obj == bear)
601 1.8 lukem spk = 71;
602 1.1 jtc goto l2011;
603 1.8 lukem l9150: case 15:/* 9150 - drink */
604 1.9 hubertf if (obj == 0 && liqloc(loc) != water && (liq() != water
605 1.8 lukem || !here(bottle)))
606 1.8 lukem goto l8000;
607 1.8 lukem if (obj != 0 && obj != water)
608 1.8 lukem spk = 110;
609 1.9 hubertf if (spk == 110 || liq() != water || !here(bottle))
610 1.8 lukem goto l2011;
611 1.8 lukem prop[bottle] = 1;
612 1.8 lukem place[water] = 0;
613 1.8 lukem spk = 74;
614 1.1 jtc goto l2011;
615 1.8 lukem case 16: /* 9160: rub */
616 1.8 lukem if (obj != lamp)
617 1.8 lukem spk = 76;
618 1.1 jtc goto l2011;
619 1.8 lukem case 17: /* 9170: throw */
620 1.8 lukem switch (trtoss()) {
621 1.8 lukem case 2011:
622 1.8 lukem goto l2011;
623 1.8 lukem case 9020:
624 1.8 lukem goto l9020;
625 1.8 lukem case 9120:
626 1.8 lukem goto l9120;
627 1.8 lukem case 8:
628 1.8 lukem goto l8;
629 1.8 lukem case 9210:
630 1.8 lukem goto l9210;
631 1.8 lukem default:
632 1.8 lukem bug(113);
633 1.8 lukem }
634 1.8 lukem case 19:
635 1.8 lukem case 20: /* 9190: find, invent */
636 1.9 hubertf if (at(obj) || (liq() == obj && at(bottle))
637 1.8 lukem || k == liqloc(loc))
638 1.8 lukem spk = 94;
639 1.8 lukem for (i = 1; i <= 5; i++)
640 1.8 lukem if (dloc[i] == loc && dflag >= 2 && obj == dwarf)
641 1.8 lukem spk = 94;
642 1.8 lukem if (closed)
643 1.8 lukem spk = 138;
644 1.8 lukem if (toting(obj))
645 1.8 lukem spk = 24;
646 1.1 jtc goto l2011;
647 1.8 lukem l9210: case 21:/* feed */
648 1.8 lukem switch (trfeed()) {
649 1.8 lukem case 2011:
650 1.8 lukem goto l2011;
651 1.8 lukem default:
652 1.8 lukem bug(114);
653 1.8 lukem }
654 1.8 lukem l9220: case 22:/* fill */
655 1.8 lukem switch (trfill()) {
656 1.8 lukem case 2011:
657 1.8 lukem goto l2011;
658 1.8 lukem case 8000:
659 1.8 lukem goto l8000;
660 1.8 lukem case 9020:
661 1.8 lukem goto l9020;
662 1.8 lukem default:
663 1.8 lukem bug(115);
664 1.8 lukem }
665 1.8 lukem l9230: case 23:/* blast */
666 1.8 lukem if (prop[rod2] < 0 || !closed)
667 1.8 lukem goto l2011;
668 1.8 lukem bonus = 133;
669 1.8 lukem if (loc == 115)
670 1.8 lukem bonus = 134;
671 1.8 lukem if (here(rod2))
672 1.8 lukem bonus = 135;
673 1.1 jtc rspeak(bonus);
674 1.1 jtc done(2);
675 1.8 lukem l9270: case 27:/* read */
676 1.9 hubertf if (dark())
677 1.8 lukem goto l5190;
678 1.8 lukem if (obj == magzin)
679 1.8 lukem spk = 190;
680 1.8 lukem if (obj == tablet)
681 1.8 lukem spk = 196;
682 1.8 lukem if (obj == messag)
683 1.8 lukem spk = 191;
684 1.8 lukem if (obj == oyster && hinted[2] && toting(oyster))
685 1.8 lukem spk = 194;
686 1.8 lukem if (obj != oyster || hinted[2] || !toting(oyster)
687 1.8 lukem || !closed)
688 1.8 lukem goto l2011;
689 1.8 lukem hinted[2] = yes(192, 193, 54);
690 1.1 jtc goto l2012;
691 1.6 christos #if 0
692 1.6 christos l9280:
693 1.6 christos #endif
694 1.8 lukem case 28: /* break */
695 1.8 lukem if (obj == mirror)
696 1.8 lukem spk = 148;
697 1.8 lukem if (obj == vase && prop[vase] == 0) {
698 1.8 lukem spk = 198;
699 1.8 lukem if (toting(vase))
700 1.8 lukem drop(vase, loc);
701 1.8 lukem prop[vase] = 2;
702 1.8 lukem fixed[vase] = -1;
703 1.1 jtc goto l2011;
704 1.1 jtc }
705 1.8 lukem if (obj != mirror || !closed)
706 1.8 lukem goto l2011;
707 1.1 jtc rspeak(197);
708 1.1 jtc done(3);
709 1.6 christos #if 0
710 1.6 christos l9290:
711 1.6 christos #endif
712 1.8 lukem case 29: /* wake */
713 1.8 lukem if (obj != dwarf || !closed)
714 1.8 lukem goto l2011;
715 1.1 jtc rspeak(199);
716 1.1 jtc done(3);
717 1.1 jtc
718 1.8 lukem default:
719 1.8 lukem bug(24);
720 1.1 jtc }
721 1.1 jtc
722 1.8 lukem l5000:
723 1.8 lukem obj = k;
724 1.8 lukem if (fixed[k] != loc && !here(k))
725 1.8 lukem goto l5100;
726 1.8 lukem l5010: if (*wd2 != 0)
727 1.8 lukem goto l2800;
728 1.8 lukem if (verb != 0)
729 1.8 lukem goto l4090;
730 1.8 lukem printf("What do you want to do with the %s?\n", wd1);
731 1.1 jtc goto l2600;
732 1.8 lukem l5100: if (k != grate)
733 1.8 lukem goto l5110;
734 1.8 lukem if (loc == 1 || loc == 4 || loc == 7)
735 1.8 lukem k = dprssn;
736 1.8 lukem if (loc > 9 && loc < 15)
737 1.8 lukem k = entrnc;
738 1.8 lukem if (k != grate)
739 1.8 lukem goto l8;
740 1.8 lukem l5110: if (k != dwarf)
741 1.8 lukem goto l5120;
742 1.8 lukem for (i = 1; i <= 5; i++)
743 1.8 lukem if (dloc[i] == loc && dflag >= 2)
744 1.8 lukem goto l5010;
745 1.9 hubertf l5120: if ((liq() == k && here(bottle)) || k == liqloc(loc))
746 1.8 lukem goto l5010;
747 1.8 lukem if (obj != plant || !at(plant2) || prop[plant2] == 0)
748 1.8 lukem goto l5130;
749 1.8 lukem obj = plant2;
750 1.1 jtc goto l5010;
751 1.8 lukem l5130: if (obj != knife || knfloc != loc)
752 1.8 lukem goto l5140;
753 1.1 jtc knfloc = -1;
754 1.8 lukem spk = 116;
755 1.1 jtc goto l2011;
756 1.8 lukem l5140: if (obj != rod || !here(rod2))
757 1.8 lukem goto l5190;
758 1.8 lukem obj = rod2;
759 1.1 jtc goto l5010;
760 1.8 lukem l5190: if ((verb == find || verb == invent) && *wd2 == 0)
761 1.8 lukem goto l5010;
762 1.8 lukem printf("I see no %s here\n", wd1);
763 1.1 jtc goto l2012;
764 1.1 jtc }
765 1.1 jtc }
766