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