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