xref: /csrg-svn/games/adventure/main.c (revision 47851)
1*47851Sbostic /*-
2*47851Sbostic  * Copyright (c) 1991 The Regents of the University of California.
3*47851Sbostic  * All rights reserved.
4*47851Sbostic  *
5*47851Sbostic  * The game adventure was original written Fortran by Will Crowther
6*47851Sbostic  * and Don Woods.  It was later translated to C and enhanced by
7*47851Sbostic  * Jim Gillogly.
8*47851Sbostic  *
9*47851Sbostic  * %sccs.include.redist.c%
10*47851Sbostic  */
11*47851Sbostic 
12*47851Sbostic #ifndef lint
13*47851Sbostic char copyright[] =
14*47851Sbostic "@(#) Copyright (c) 1991 The Regents of the University of California.\n\
15*47851Sbostic  All rights reserved.\n";
16*47851Sbostic #endif /* not lint */
17*47851Sbostic 
18*47851Sbostic #ifndef lint
19*47851Sbostic static char sccsid[] = "@(#)main.c	5.1 (Berkeley) 04/08/91";
20*47851Sbostic #endif /* not lint */
21*47851Sbostic 
226737Srrh /*      Re-coding of advent in C: main program                          */
236737Srrh 
2437005Sbostic #include <sys/file.h>
2537005Sbostic #include <stdio.h>
266737Srrh #include "hdr.h"
2737005Sbostic #include "pathnames.h"
286737Srrh 
296737Srrh int	datfd = -1;
306737Srrh main(argc,argv)
316737Srrh int argc;
326737Srrh char **argv;
3337005Sbostic {
3437005Sbostic 	extern int errno;
3537005Sbostic 	register int i;
366737Srrh 	int rval,ll;
376737Srrh 	struct text *kk;
386737Srrh 	extern trapdel();
3937005Sbostic 	char *strerror();
406737Srrh 	static reenter;
4137005Sbostic 
426737Srrh 	reenter++;
436737Srrh 	switch (setup) {
446737Srrh 	case 0:
4537005Sbostic 		if ((datfd = open(*argv, O_RDONLY, 0)) < 0) {
4637005Sbostic 			fprintf(stderr, "adventure: can't init\n");
4737005Sbostic 			exit(1);
4837005Sbostic 		}
4937005Sbostic 		init(*argv);
506737Srrh 		/* NOTREACHED */
516737Srrh 	case 1:
5237005Sbostic 		if ((datfd = open(_PATH_ADVENTURE, O_RDONLY, 0)) < 0) {
5337005Sbostic 			fprintf(stderr, "adventure: %s: %s\n", _PATH_ADVENTURE,
5437005Sbostic 			    strerror(errno));
5537005Sbostic 			exit(1);
5637005Sbostic 		}
576737Srrh 		startup();		/* prepare for a user           */
586737Srrh 		signal(2,trapdel);
596737Srrh 		break;
606737Srrh 	case -1:	                /* restarting game : 8305       */
616737Srrh 		yea=start(0);
626737Srrh 		setup=3;
636737Srrh 		k=null;
646737Srrh 		goto l8;
656737Srrh 	default:
666737Srrh 		printf("Your forged file dissappears in a puff of greasy black smoke! (poof)\n");
676737Srrh 		unlink(argv[0]);
686737Srrh 		exit(1);
696737Srrh 	}
706737Srrh 
716737Srrh 	for (;;)                        /* main command loop (label 2)  */
726737Srrh 	{       if (newloc<9 && newloc!=0 && closng)
736737Srrh 		{       rspeak(130);    /* if closing leave only by     */
746737Srrh 			newloc=loc;     /*      main office             */
756737Srrh 			if (!panic) clock2=15;
766737Srrh 			panic=TRUE;
776737Srrh 		}
786737Srrh 
796737Srrh 		rval=fdwarf();          /* dwarf stuff                  */
806737Srrh 		if (rval==99) die(99);
816737Srrh 
826737Srrh 	l2000:  if (loc==0) die(99);    /* label 2000                   */
836737Srrh 		kk = &stext[loc];
846737Srrh 		if ((abb[loc]%abbnum)==0 || kk->seekadr==0)
856737Srrh 			kk = &ltext[loc];
866737Srrh 		if (!forced(loc) && dark(0))
876737Srrh 		{       if (wzdark && pct(35))
886737Srrh 			{       die(90);
896737Srrh 				goto l2000;
906737Srrh 			}
916737Srrh 			kk = &rtext[16];
926737Srrh 		}
936737Srrh 	l2001:  if (toting(bear)) rspeak(141);  /* 2001                 */
946737Srrh 		speak(kk);
956737Srrh 		k=1;
966737Srrh 		if (forced(loc))
976737Srrh 			goto l8;
986737Srrh 		if (loc==33 && pct(25)&&!closng) rspeak(8);
996737Srrh 		if (!dark(0))
1006737Srrh 		{       abb[loc]++;
1016737Srrh 			for (i=atloc[loc]; i!=0; i=link[i])     /*2004  */
1026737Srrh 			{       obj=i;
1036737Srrh 				if (obj>100) obj -= 100;
1046737Srrh 				if (obj==steps && toting(nugget)) continue;
1056737Srrh 				if (prop[obj]<0)
1066737Srrh 				{       if (closed) continue;
1076737Srrh 					prop[obj]=0;
1086737Srrh 					if (obj==rug||obj==chain)
1096737Srrh 						prop[obj]=1;
1106737Srrh 					tally--;
1116737Srrh 					if (tally==tally2 && tally != 0)
1126737Srrh 						if (limit>35) limit=35;
1136737Srrh 				}
1146737Srrh 				kk=(struct text *) prop[obj];	/* 2006		*/
1156737Srrh 				if (obj==steps && loc==fixed[steps])kk=(struct text *)1;
1166737Srrh 				pspeak(obj,kk);
1176737Srrh 			}                                       /* 2008 */
1186737Srrh 			goto l2012;
1196737Srrh 	l2009:          k=54;                   /* 2009                 */
1206737Srrh 	l2010:          spk=k;
1216737Srrh 	l2011:          rspeak(spk);
1226737Srrh 		}
1236737Srrh 	l2012:  verb=0;                         /* 2012                 */
1246737Srrh 		obj=0;
1256737Srrh 	l2600:	checkhints();                   /* to 2600-2602         */
1266737Srrh 		if (closed)
1276737Srrh 		{       if (prop[oyster]<0 && toting(oyster))
1286737Srrh 				pspeak(oyster,1);
1296737Srrh 			for (i=1; i<100; i++)
1306737Srrh 				if (toting(i)&&prop[i]<0)       /*2604  */
1316737Srrh 					prop[i] = -1-prop[i];
1326737Srrh 		}
1336737Srrh 		wzdark=dark(0);                 /* 2605                 */
1346737Srrh 		if (knfloc>0 && knfloc!=loc) knfloc=1;
1356737Srrh 		getin(&wd1,&wd2);
1366737Srrh 		if (delhit)                     /* user typed a DEL     */
1376737Srrh 		{       delhit=0;               /* reset counter        */
1386737Srrh 			copystr("quit",wd1);    /* pretend he's quitting*/
1396737Srrh 			*wd2=0;
1406737Srrh 		}
1416737Srrh 	l2608:  if ((foobar = -foobar)>0) foobar=0;     /* 2608         */
1426737Srrh 		/* should check here for "magic mode"                   */
1436737Srrh 		turns++;
1446737Srrh 		if (demo && turns>=SHORT) done(1);      /* to 13000     */
1456737Srrh 
1466737Srrh 		if (verb==say && *wd2!=0) verb=0;
1476737Srrh 		if (verb==say)
1486737Srrh 			goto l4090;
1496737Srrh 		if (tally==0 && loc>=15 && loc!=33) clock1--;
1506737Srrh 		if (clock1==0)
1516737Srrh 		{       closing();                      /* to 10000     */
1526737Srrh 			goto l19999;
1536737Srrh 		}
1546737Srrh 		if (clock1<0) clock2--;
1556737Srrh 		if (clock2==0)
1566737Srrh 		{       caveclose();            /* to 11000             */
1576737Srrh 			continue;               /* back to 2            */
1586737Srrh 		}
1596737Srrh 		if (prop[lamp]==1) limit--;
1606737Srrh 		if (limit<=30 && here(batter) && prop[batter]==0
1616737Srrh 			&& here(lamp))
1626737Srrh 		{       rspeak(188);            /* 12000                */
1636737Srrh 			prop[batter]=1;
1646737Srrh 			if (toting(batter)) drop(batter,loc);
1656737Srrh 			limit=limit+2500;
1666737Srrh 			lmwarn=FALSE;
1676737Srrh 			goto l19999;
1686737Srrh 		}
1696737Srrh 		if (limit==0)
1706737Srrh 		{       limit = -1;             /* 12400                */
1716737Srrh 			prop[lamp]=0;
1726737Srrh 			rspeak(184);
1736737Srrh 			goto l19999;
1746737Srrh 		}
1756737Srrh 		if (limit<0&&loc<=8)
1766737Srrh 		{       rspeak(185);            /* 12600                */
1776737Srrh 			gaveup=TRUE;
1786737Srrh 			done(2);                /* to 20000             */
1796737Srrh 		}
1806737Srrh 		if (limit<=30)
1816737Srrh 		{       if (lmwarn|| !here(lamp)) goto l19999;  /*12200*/
1826737Srrh 			lmwarn=TRUE;
1836737Srrh 			spk=187;
1846737Srrh 			if (place[batter]==0) spk=183;
1856737Srrh 			if (prop[batter]==1) spk=189;
1866737Srrh 			rspeak(spk);
1876737Srrh 		}
1886737Srrh 	l19999: k=43;
1896737Srrh 		if (liqloc(loc)==water) k=70;
1906737Srrh 		if (weq(wd1,"enter") &&
1916737Srrh 		    (weq(wd2,"strea")||weq(wd2,"water")))
1926737Srrh 			goto l2010;
1936737Srrh 		if (weq(wd1,"enter") && *wd2!=0) goto l2800;
1946737Srrh 		if ((!weq(wd1,"water")&&!weq(wd1,"oil"))
1956737Srrh 		    || (!weq(wd2,"plant")&&!weq(wd2,"door")))
1966737Srrh 			goto l2610;
1976737Srrh 		if (at(vocab(wd2,1))) copystr("pour",wd2);
1986737Srrh 	l2610:  if (weq(wd1,"west"))
1996737Srrh 			if (++iwest==10) rspeak(17);
2006737Srrh 	l2630:  i=vocab(wd1,-1);
2016737Srrh 		if (i== -1)
2026737Srrh 		{       spk=60;                 /* 3000         */
2036737Srrh 			if (pct(20)) spk=61;
2046737Srrh 			if (pct(20)) spk=13;
2056737Srrh 			rspeak(spk);
2066737Srrh 			goto l2600;
2076737Srrh 		}
2086737Srrh 		k=i%1000;
2096737Srrh 		kq=i/1000+1;
2106737Srrh 		switch(kq)
2116737Srrh 		{   case 1: goto l8;
2126737Srrh 		    case 2: goto l5000;
2136737Srrh 		    case 3: goto l4000;
2146737Srrh 		    case 4: goto l2010;
2156737Srrh 		    default:
2166737Srrh 			printf("Error 22\n");
2176737Srrh 			exit(0);
2186737Srrh 		}
2196737Srrh 
2206737Srrh 	l8:
2216737Srrh 		switch(march())
2226737Srrh 		{   case 2: continue;           /* i.e. goto l2         */
2236737Srrh 		    case 99:
2246737Srrh 			switch(die(99))
2256737Srrh 			{   case 2000: goto l2000;
2266737Srrh 			    default: bug(111);
2276737Srrh 			}
2286737Srrh 		    default: bug(110);
2296737Srrh 		}
2306737Srrh 
2316737Srrh 	l2800:  copystr(wd2,wd1);
2326737Srrh 		*wd2=0;
2336737Srrh 		goto l2610;
2346737Srrh 
2356737Srrh 	l4000:  verb=k;
2366737Srrh 		spk=actspk[verb];
2376737Srrh 		if (*wd2!=0 && verb!=say) goto l2800;
2386737Srrh 		if (verb==say) obj= *wd2;
2396737Srrh 		if (obj!=0) goto l4090;
2406737Srrh 	l4080:
2416737Srrh 		switch(verb)
2426737Srrh 		{   case 1:                     /* take = 8010          */
2436737Srrh 			if (atloc[loc]==0||link[atloc[loc]]!=0) goto l8000;
2446737Srrh 			for (i=1; i<=5; i++)
2456737Srrh 				if (dloc[i]==loc&&dflag>=2) goto l8000;
2466737Srrh 			obj=atloc[loc];
2476737Srrh 			goto l9010;
2486737Srrh 		    case 2: case 3: case 9:     /* 8000 : drop,say,wave */
2496737Srrh 		    case 10: case 16: case 17:  /* calm,rub,toss        */
2506737Srrh 		    case 19: case 21: case 28:  /* find,feed,break      */
2516737Srrh 		    case 29:                    /* wake                 */
2526737Srrh 		l8000:  printf("%s what?\n",wd1);
2536737Srrh 			obj=0;
2546737Srrh 			goto l2600;
2556737Srrh 		    case 4: case 6:             /* 8040 open,lock       */
2566737Srrh 			spk=28;
2576737Srrh 			if (here(clam)) obj=clam;
2586737Srrh 			if (here(oyster)) obj=oyster;
2596737Srrh 			if (at(door)) obj=door;
2606737Srrh 			if (at(grate)) obj=grate;
2616737Srrh 			if (obj!=0 && here(chain)) goto l8000;
2626737Srrh 			if (here(chain)) obj=chain;
2636737Srrh 			if (obj==0) goto l2011;
2646737Srrh 			goto l9040;
2656737Srrh 		    case 5: goto l2009;         /* nothing              */
2666737Srrh 		    case 7: goto l9070;         /* on                   */
2676737Srrh 		    case 8: goto l9080;         /* off                  */
2686737Srrh 		    case 11: goto l8000;        /* walk                 */
2696737Srrh 		    case 12: goto l9120;        /* kill                 */
2706737Srrh 		    case 13: goto l9130;        /* pour                 */
2716737Srrh 		    case 14:                    /* eat: 8140            */
2726737Srrh 			if (!here(food)) goto l8000;
2736737Srrh 		l8142:  dstroy(food);
2746737Srrh 			spk=72;
2756737Srrh 			goto l2011;
2766737Srrh 		    case 15: goto l9150;        /* drink                */
2776737Srrh 		    case 18:                    /* quit: 8180           */
2786737Srrh 			gaveup=yes(22,54,54);
2796737Srrh 			if (gaveup) done(2);    /* 8185                 */
2806737Srrh 			goto l2012;
2816737Srrh 		    case 20:                    /* invent=8200          */
2826737Srrh 			spk=98;
2836737Srrh 			for (i=1; i<=100; i++)
2846737Srrh 			{       if (i!=bear && toting(i))
2856737Srrh 				{       if (spk==98) rspeak(99);
2866737Srrh 					blklin=FALSE;
2876737Srrh 					pspeak(i,-1);
2886737Srrh 					blklin=TRUE;
2896737Srrh 					spk=0;
2906737Srrh 				}
2916737Srrh 			}
2926737Srrh 			if (toting(bear)) spk=141;
2936737Srrh 			goto l2011;
2946737Srrh 		    case 22: goto l9220;        /* fill                 */
2956737Srrh 		    case 23: goto l9230;        /* blast                */
2966737Srrh 		    case 24:                    /* score: 8240          */
2976737Srrh 			scorng=TRUE;
2986737Srrh 			printf("If you were to quit now, you would score");
2996737Srrh 			printf(" %d out of a possible ",score());
3006737Srrh 			printf("%d.",mxscor);
3016737Srrh 			scorng=FALSE;
3026737Srrh 			gaveup=yes(143,54,54);
3036737Srrh 			if (gaveup) done(2);
3046737Srrh 			goto l2012;
3056737Srrh 		    case 25:                    /* foo: 8250            */
3066737Srrh 			k=vocab(wd1,3);
3076737Srrh 			spk=42;
3086737Srrh 			if (foobar==1-k) goto l8252;
3096737Srrh 			if (foobar!=0) spk=151;
3106737Srrh 			goto l2011;
3116737Srrh 		l8252:  foobar=k;
3126737Srrh 			if (k!=4) goto l2009;
3136737Srrh 			foobar=0;
3146737Srrh 			if (place[eggs]==plac[eggs]
3156737Srrh 				||(toting(eggs)&&loc==plac[eggs])) goto l2011;
3166737Srrh 			if (place[eggs]==0&&place[troll]==0&&prop[troll]==0)
3176737Srrh 				prop[troll]=1;
3186737Srrh 			k=2;
3196737Srrh 			if (here(eggs)) k=1;
3206737Srrh 			if (loc==plac[eggs]) k=0;
3216737Srrh 			move(eggs,plac[eggs]);
3226737Srrh 			pspeak(eggs,k);
3236737Srrh 			goto l2012;
3246737Srrh 		    case 26:                    /* brief=8260           */
3256737Srrh 			spk=156;
3266737Srrh 			abbnum=10000;
3276737Srrh 			detail=3;
3286737Srrh 			goto l2011;
3296737Srrh 		    case 27:                    /* read=8270            */
3306737Srrh 			if (here(magzin)) obj=magzin;
3316737Srrh 			if (here(tablet)) obj=obj*100+tablet;
3326737Srrh 			if (here(messag)) obj=obj*100+messag;
3336737Srrh 			if (closed&&toting(oyster)) obj=oyster;
3346737Srrh 			if (obj>100||obj==0||dark(0)) goto l8000;
3356737Srrh 			goto l9270;
3366737Srrh 		    case 30:                    /* suspend=8300         */
3376737Srrh 			spk=201;
3386737Srrh 			if (demo) goto l2011;
3396737Srrh 			printf("I can suspend your adventure for you so");
3406737Srrh 			printf(" you can resume later, but\n");
3416737Srrh 			printf("you will have to wait at least");
3426737Srrh 			printf(" %d minutes before continuing.",latncy);
3436737Srrh 			if (!yes(200,54,54)) goto l2012;
3446737Srrh 			datime(&saved,&savet);
3456737Srrh 			setup = -1;
3466737Srrh 			ciao(argv[0]);
3476737Srrh 			continue;
3486737Srrh 		    case 31:                    /* hours=8310           */
3496737Srrh 			printf("Colossal cave is closed 9am-5pm Mon ");
3506737Srrh 			printf("through Fri except holidays.\n");
3516737Srrh 			goto l2012;
3526737Srrh 		    default: bug(23);
3536737Srrh 		}
3546737Srrh 
3556737Srrh 	l4090:
3566737Srrh 		switch(verb)
3576737Srrh 		{   case 1:                     /* take = 9010          */
3586737Srrh 	l9010:          switch(trtake())
3596737Srrh 			{   case 2011: goto l2011;
3606737Srrh 			    case 9220: goto l9220;
3616737Srrh 			    case 2009: goto l2009;
3626737Srrh 			    case 2012: goto l2012;
3636737Srrh 			    default: bug(102);
3646737Srrh 			}
3656737Srrh 	l9020:      case 2:                     /* drop = 9020          */
3666737Srrh 			switch(trdrop())
3676737Srrh 			{   case 2011: goto l2011;
3686737Srrh 			    case 19000: done(3);
3696737Srrh 			    case 2012: goto l2012;
3706737Srrh 			    default: bug(105);
3716737Srrh 			}
3726737Srrh 	l9030:      case 3:
3736737Srrh 			switch(trsay())
3746737Srrh 			{   case 2012: goto l2012;
3756737Srrh 			    case 2630: goto l2630;
3766737Srrh 			    default: bug(107);
3776737Srrh 			}
3786737Srrh 	l9040:      case 4:  case 6:            /* open, close          */
3796737Srrh 			switch(tropen())
3806737Srrh 			{   case 2011: goto l2011;
3816737Srrh 			    case 2010: goto l2010;
3826737Srrh 			    default: bug(106);
3836737Srrh 			}
3846737Srrh 		    case 5: goto l2009;         /* nothing              */
3856737Srrh 		    case 7:                     /* on   9070            */
3866737Srrh 	l9070:          if (!here(lamp))  goto l2011;
3876737Srrh 			spk=184;
3886737Srrh 			if (limit<0) goto l2011;
3896737Srrh 			prop[lamp]=1;
3906737Srrh 			rspeak(39);
3916737Srrh 			if (wzdark) goto l2000;
3926737Srrh 			goto l2012;
3936737Srrh 
3946737Srrh 		    case 8:                     /* off                  */
3956737Srrh 	l9080:          if (!here(lamp)) goto l2011;
3966737Srrh 			prop[lamp]=0;
3976737Srrh 			rspeak(40);
3986737Srrh 			if (dark(0)) rspeak(16);
3996737Srrh 			goto l2012;
4006737Srrh 
4016737Srrh 		    case 9:                     /* wave                 */
4026737Srrh 			if ((!toting(obj))&&(obj!=rod||!toting(rod2)))
4036737Srrh 				spk=29;
4046737Srrh 			if (obj!=rod||!at(fissur)||!toting(obj)||closng)
4056737Srrh 				goto l2011;
4066737Srrh 			prop[fissur]=1-prop[fissur];
4076737Srrh 			pspeak(fissur,2-prop[fissur]);
4086737Srrh 			goto l2012;
4096737Srrh 		    case 10: case 11: case 18:  /* calm, walk, quit     */
4106737Srrh 		    case 24: case 25: case 26:  /* score, foo, brief    */
4116737Srrh 		    case 30: case 31:           /* suspend, hours       */
4126737Srrh 			     goto l2011;
4136737Srrh 	l9120:      case 12:                    /* kill                 */
4146737Srrh 			switch(trkill())
4156737Srrh 			{   case 8000: goto l8000;
4166737Srrh 			    case 8: goto l8;
4176737Srrh 			    case 2011: goto l2011;
4186737Srrh 			    case 2608: goto l2608;
4196737Srrh 			    case 19000: done(3);
4206737Srrh 			    default: bug(112);
4216737Srrh 			}
4226737Srrh 	l9130:      case 13:                    /* pour                 */
4236737Srrh 			if (obj==bottle||obj==0) obj=liq(0);
4246737Srrh 			if (obj==0) goto l8000;
4256737Srrh 			if (!toting(obj)) goto l2011;
4266737Srrh 			spk=78;
4276737Srrh 			if (obj!=oil&&obj!=water) goto l2011;
4286737Srrh 			prop[bottle]=1;
4296737Srrh 			place[obj]=0;
4306737Srrh 			spk=77;
4316737Srrh 			if (!(at(plant)||at(door))) goto l2011;
4326737Srrh 			if (at(door))
4336737Srrh 			{       prop[door]=0;   /* 9132                 */
4346737Srrh 				if (obj==oil) prop[door]=1;
4356737Srrh 				spk=113+prop[door];
4366737Srrh 				goto l2011;
4376737Srrh 			}
4386737Srrh 			spk=112;
4396737Srrh 			if (obj!=water) goto l2011;
4406737Srrh 			pspeak(plant,prop[plant]+1);
4416737Srrh 			prop[plant]=(prop[plant]+2)% 6;
4426737Srrh 			prop[plant2]=prop[plant]/2;
4436737Srrh 			k=null;
4446737Srrh 			goto l8;
4456737Srrh 		    case 14:                    /* 9140 - eat           */
4466737Srrh 			if (obj==food) goto l8142;
4476737Srrh 			if (obj==bird||obj==snake||obj==clam||obj==oyster
4486737Srrh 			    ||obj==dwarf||obj==dragon||obj==troll
4496737Srrh 			    ||obj==bear) spk=71;
4506737Srrh 			goto l2011;
4516737Srrh 	l9150:      case 15:                    /* 9150 - drink         */
4526737Srrh 			if (obj==0&&liqloc(loc)!=water&&(liq(0)!=water
4536737Srrh 				||!here(bottle))) goto l8000;
4546737Srrh 			if (obj!=0&&obj!=water) spk=110;
4556737Srrh 			if (spk==110||liq(0)!=water||!here(bottle))
4566737Srrh 				goto l2011;
4576737Srrh 			prop[bottle]=1;
4586737Srrh 			place[water]=0;
4596737Srrh 			spk=74;
4606737Srrh 			goto l2011;
4616737Srrh 		    case 16:                    /* 9160: rub            */
4626737Srrh 			if (obj!=lamp) spk=76;
4636737Srrh 			goto l2011;
4646737Srrh 		    case 17:                    /* 9170: throw          */
4656737Srrh 			switch(trtoss())
4666737Srrh 			{   case 2011: goto l2011;
4676737Srrh 			    case 9020: goto l9020;
4686737Srrh 			    case 9120: goto l9120;
4696737Srrh 			    case 8: goto l8;
4706737Srrh 			    case 9210: goto l9210;
4716737Srrh 			    default: bug(113);
4726737Srrh 			}
4736737Srrh 		    case 19: case 20:           /* 9190: find, invent   */
4746737Srrh 			if (at(obj)||(liq(0)==obj&&at(bottle))
4756737Srrh 				||k==liqloc(loc)) spk=94;
4766737Srrh 			for (i=1; i<=5; i++)
4776737Srrh 				if (dloc[i]==loc&&dflag>=2&&obj==dwarf)
4786737Srrh 					spk=94;
4796737Srrh 			if (closed) spk=138;
4806737Srrh 			if (toting(obj)) spk=24;
4816737Srrh 			goto l2011;
4826737Srrh 	l9210:      case 21:                    /* feed                 */
4836737Srrh 			switch(trfeed())
4846737Srrh 			{   case 2011: goto l2011;
4856737Srrh 			    default: bug(114);
4866737Srrh 			}
4876737Srrh 	l9220:      case 22:                    /* fill                 */
4886737Srrh 			switch(trfill())
4896737Srrh 			{   case 2011: goto l2011;
4906737Srrh 			    case 8000: goto l8000;
4916737Srrh 			    case 9020: goto l9020;
4926737Srrh 			    default: bug(115);
4936737Srrh 			}
4946737Srrh 	l9230:      case 23:                    /* blast                */
4956737Srrh 			if (prop[rod2]<0||!closed) goto l2011;
4966737Srrh 			bonus=133;
4976737Srrh 			if (loc==115) bonus=134;
4986737Srrh 			if (here(rod2)) bonus=135;
4996737Srrh 			rspeak(bonus);
5006737Srrh 			done(2);
5016737Srrh 	l9270:      case 27:                    /* read                 */
5026737Srrh 			if (dark(0)) goto l5190;
5036737Srrh 			if (obj==magzin) spk=190;
5046737Srrh 			if (obj==tablet) spk=196;
5056737Srrh 			if (obj==messag) spk=191;
5066737Srrh 			if (obj==oyster&&hinted[2]&&toting(oyster)) spk=194;
5076737Srrh 			if (obj!=oyster||hinted[2]||!toting(oyster)
5086737Srrh 				||!closed) goto l2011;
5096737Srrh 			hinted[2]=yes(192,193,54);
5106737Srrh 			goto l2012;
5116737Srrh 	l9280:      case 28:                    /* break                */
5126737Srrh 			if (obj==mirror) spk=148;
5136737Srrh 			if (obj==vase&&prop[vase]==0)
5146737Srrh 			{       spk=198;
5156737Srrh 				if (toting(vase)) drop(vase,loc);
5166737Srrh 				prop[vase]=2;
5176737Srrh 				fixed[vase]= -1;
5186737Srrh 				goto l2011;
5196737Srrh 			}
5206737Srrh 			if (obj!=mirror||!closed) goto l2011;
5216737Srrh 			rspeak(197);
5226737Srrh 			done(3);
5236737Srrh 
5246737Srrh 	l9290:      case 29:                    /* wake                 */
5256737Srrh 			if (obj!=dwarf||!closed) goto l2011;
5266737Srrh 			rspeak(199);
5276737Srrh 			done(3);
5286737Srrh 
5296737Srrh 		    default: bug(24);
5306737Srrh 		}
5316737Srrh 
5326737Srrh 	l5000:
5336737Srrh 		obj=k;
5346737Srrh 		if (fixed[k]!=loc && !here(k)) goto l5100;
5356737Srrh 	l5010:  if (*wd2!=0) goto l2800;
5366737Srrh 		if (verb!=0) goto l4090;
5376737Srrh 		printf("What do you want to do with the %s?\n",wd1);
5386737Srrh 		goto l2600;
5396737Srrh 	l5100:  if (k!=grate) goto l5110;
5406737Srrh 		if (loc==1||loc==4||loc==7) k=dprssn;
5416737Srrh 		if (loc>9&&loc<15) k=entrnc;
5426737Srrh 		if (k!=grate) goto l8;
5436737Srrh 	l5110:  if (k!=dwarf) goto l5120;
5446737Srrh 		for (i=1; i<=5; i++)
5456737Srrh 			if (dloc[i]==loc&&dflag>=2) goto l5010;
5466737Srrh 	l5120:  if ((liq(0)==k&&here(bottle))||k==liqloc(loc)) goto l5010;
5476737Srrh 		if (obj!=plant||!at(plant2)||prop[plant2]==0) goto l5130;
5486737Srrh 		obj=plant2;
5496737Srrh 		goto l5010;
5506737Srrh 	l5130:  if (obj!=knife||knfloc!=loc) goto l5140;
5516737Srrh 		knfloc = -1;
5526737Srrh 		spk=116;
5536737Srrh 		goto l2011;
5546737Srrh 	l5140:  if (obj!=rod||!here(rod2)) goto l5190;
5556737Srrh 		obj=rod2;
5566737Srrh 		goto l5010;
5576737Srrh 	l5190:  if ((verb==find||verb==invent)&&*wd2==0) goto l5010;
5586737Srrh 		printf("I see no %s here\n",wd1);
5596737Srrh 		goto l2012;
5606737Srrh 	}
5616737Srrh }
5626737Srrh 
563