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