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