-static bool do_command(FILE *cmdin) {
-
-/* Can't leave cave once it's closing (except by main office). */
-
- if(!OUTSID(NEWLOC) || NEWLOC == 0 || !game.closng) goto L71;
- RSPEAK(130);
- NEWLOC=LOC;
- if(!PANIC)game.clock2=15;
- PANIC=true;
-
-/* See if a dwarf has seen him and has come from where he wants to go. If so,
- * the dwarf's blocking his way. If coming from place forbidden to pirate
- * (dwarves rooted in place) let him get out (and attacked). */
-
-L71: if(NEWLOC == LOC || FORCED(LOC) || CNDBIT(LOC,3)) goto L74;
- /* 73 */ for (I=1; I<=NDWARVES-1; I++) {
- if(game.odloc[I] != NEWLOC || !game.dseen[I]) goto L73;
- NEWLOC=LOC;
- RSPEAK(2);
- goto L74;
-L73: /*etc*/ ;
- } /* end loop */
-L74: LOC=NEWLOC;
-
-/* Dwarf stuff. See earlier comments for description of variables. Remember
- * sixth dwarf is pirate and is thus very different except for motion rules. */
-
-/* First off, don't let the dwarves follow him into a pit or a wall. Activate
- * the whole mess the first time he gets as far as the hall of mists (loc 15).
- * If NEWLOC is forbidden to pirate (in particular, if it's beyond the troll
- * bridge), bypass dwarf stuff. That way pirate can't steal return toll, and
- * dwarves can't meet the bear. Also means dwarves won't follow him into dead
- * end in maze, but c'est la vie. They'll wait for him outside the dead end. */
-
- if(LOC == 0 || FORCED(LOC) || CNDBIT(NEWLOC,3)) goto L2000;
- if(game.dflag != 0) goto L6000;
- if(INDEEP(LOC))game.dflag=1;
- goto L2000;
-
-/* When we encounter the first dwarf, we kill 0, 1, or 2 of the 5 dwarves. If
- * any of the survivors is at loc, replace him with the alternate. */
-
-L6000: if(game.dflag != 1) goto L6010;
- if(!INDEEP(LOC) || (PCT(95) && (!CNDBIT(LOC,4) || PCT(85)))) goto L2000;
- game.dflag=2;
- for (I=1; I<=2; I++) {
- J=1+randrange(NDWARVES-1);
- if(PCT(50))game.dloc[J]=0;
- } /* end loop */
- for (I=1; I<=NDWARVES-1; I++) {
- if(game.dloc[I] == LOC)game.dloc[I]=DALTLC;
- game.odloc[I]=game.dloc[I];
- } /* end loop */
- RSPEAK(3);
- DROP(AXE,LOC);
- goto L2000;
-
-/* Things are in full swing. Move each dwarf at random, except if he's seen us
- * he sticks with us. Dwarves stay deep inside. If wandering at random,
- * they don't back up unless there's no alternative. If they don't have to
- * move, they attack. And, of course, dead dwarves don't do much of anything. */
-
-L6010: game.dtotal=0;
- ATTACK=0;
- STICK=0;
- /* 6030 */ for (I=1; I<=NDWARVES; I++) {
- if(game.dloc[I] == 0) goto L6030;
-/* Fill TK array with all the places this dwarf might go. */
- J=1;
- KK=game.dloc[I];
- KK=KEY[KK];
- if(KK == 0) goto L6016;
-L6012: NEWLOC=MOD(labs(TRAVEL[KK])/1000,1000);
- {long x = J-1;
- if(NEWLOC > 300 || !INDEEP(NEWLOC) || NEWLOC == game.odloc[I] || (J > 1 &&
- NEWLOC == TK[x]) || J >= 20 || NEWLOC == game.dloc[I] ||
- FORCED(NEWLOC) || (I == 6 && CNDBIT(NEWLOC,3)) ||
- labs(TRAVEL[KK])/1000000 == 100) goto L6014;}
- TK[J]=NEWLOC;
- J=J+1;
-L6014: KK=KK+1;
- {long x = KK-1; if(TRAVEL[x] >= 0) goto L6012;}
-L6016: TK[J]=game.odloc[I];
- if(J >= 2)J=J-1;
- J=1+randrange(J);
- game.odloc[I]=game.dloc[I];
- game.dloc[I]=TK[J];
- game.dseen[I]=(game.dseen[I] && INDEEP(LOC)) || (game.dloc[I] == LOC || game.odloc[I] == LOC);
- if(!game.dseen[I]) goto L6030;
- game.dloc[I]=LOC;
- if(I != 6) goto L6027;
-
-/* The pirate's spotted him. He leaves him alone once we've found chest. K
- * counts if a treasure is here. If not, and tally=1 for an unseen chest, let
- * the pirate be spotted. Note that PLACE(CHEST)=0 might mean that he's
- * thrown it to the troll, but in that case he's seen the chest (PROP=0). */
-
- if(LOC == game.chloc || PROP[CHEST] >= 0) goto L6030;
- K=0;
- /* 6020 */ for (J=50; J<=MAXTRS; J++) {
-/* Pirate won't take pyramid from plover room or dark room (too easy!). */
- if(J == PYRAM && (LOC == PLAC[PYRAM] || LOC == PLAC[EMRALD])) goto L6020;
- if(TOTING(J)) goto L6021;
-L6020: if(HERE(J))K=1;
- } /* end loop */
- if(TALLY == 1 && K == 0 && PLACE[CHEST] == 0 && HERE(LAMP) && PROP[LAMP]
- == 1) goto L6025;
- if(game.odloc[6] != game.dloc[6] && PCT(20))RSPEAK(127);
- goto L6030;
-
-L6021: if(PLACE[CHEST] != 0) goto L6022;
-/* Install chest only once, to insure it is the last treasure in the list. */
- MOVE(CHEST,game.chloc);
- MOVE(MESSAG,game.chloc2);
-L6022: RSPEAK(128);
- /* 6023 */ for (J=50; J<=MAXTRS; J++) {
- if(J == PYRAM && (LOC == PLAC[PYRAM] || LOC == PLAC[EMRALD])) goto L6023;
- if(AT(J) && FIXED[J] == 0)CARRY(J,LOC);
- if(TOTING(J))DROP(J,game.chloc);
-L6023: /*etc*/ ;
- } /* end loop */
-L6024: game.dloc[6]=game.chloc;
- game.odloc[6]=game.chloc;
- game.dseen[6]=false;
- goto L6030;
-
-L6025: RSPEAK(186);
- MOVE(CHEST,game.chloc);
- MOVE(MESSAG,game.chloc2);
- goto L6024;
-
-/* This threatening little dwarf is in the room with him! */
-
-L6027: game.dtotal=game.dtotal+1;
- if(game.odloc[I] != game.dloc[I]) goto L6030;
- ATTACK=ATTACK+1;
- if(game.knfloc >= 0)game.knfloc=LOC;
- if(randrange(1000) < 95*(game.dflag-2))STICK=STICK+1;
-L6030: /*etc*/ ;
- } /* end loop */
-
-/* Now we know what's happening. Let's tell the poor sucker about it.
- * Note that various of the "knife" messages must have specific relative
- * positions in the RSPEAK database. */
-
- if(game.dtotal == 0) goto L2000;
- SETPRM(1,game.dtotal,0);
- RSPEAK(4+1/game.dtotal);
- if(ATTACK == 0) goto L2000;
- if(game.dflag == 2)game.dflag=3;
- SETPRM(1,ATTACK,0);
- K=6;
- if(ATTACK > 1)K=250;
- RSPEAK(K);
- SETPRM(1,STICK,0);
- RSPEAK(K+1+2/(1+STICK));
- if(STICK == 0) goto L2000;
- game.oldlc2=LOC;
- goto L99;
-
-
-
-
-
-
-/* Describe the current location and (maybe) get next command. */
-
-/* Print text for current loc. */
-
-L2000: if(LOC == 0) goto L99;
- KK=STEXT[LOC];
- if(MOD(ABB[LOC],game.abbnum) == 0 || KK == 0)KK=LTEXT[LOC];
- if(FORCED(LOC) || !DARK(0)) goto L2001;
- if(game.wzdark && PCT(35)) goto L90;
- KK=RTEXT[16];
-L2001: if(TOTING(BEAR))RSPEAK(141);
- SPEAK(KK);
- K=1;
- if(FORCED(LOC)) goto L8;
- if(LOC == 33 && PCT(25) && !game.closng)RSPEAK(7);
-
-/* Print out descriptions of objects at this location. If not closing and
- * property value is negative, tally off another treasure. Rug is special
- * case; once seen, its PROP is 1 (dragon on it) till dragon is killed.
- * Similarly for chain; PROP is initially 1 (locked to bear). These hacks
- * are because PROP=0 is needed to get full score. */
-
- if(DARK(0)) goto L2012;
- ABB[LOC]=ABB[LOC]+1;
- I=ATLOC[LOC];
-L2004: if(I == 0) goto L2012;
- OBJ=I;
- if(OBJ > NOBJECTS)OBJ=OBJ-NOBJECTS;
- if(OBJ == STEPS && TOTING(NUGGET)) goto L2008;
- if(PROP[OBJ] >= 0) goto L2006;
- if(game.closed) goto L2008;
- PROP[OBJ]=0;
- if(OBJ == RUG || OBJ == CHAIN)PROP[OBJ]=1;
- TALLY=TALLY-1;
-/* Note: There used to be a test here to see whether the player had blown it
- * so badly that he could never ever see the remaining treasures, and if so
- * the lamp was zapped to 35 turns. But the tests were too simple-minded;
- * things like killing the bird before the snake was gone (can never see
- * jewelry), and doing it "right" was hopeless. E.G., could cross troll
- * bridge several times, using up all available treasures, breaking vase,
- * using coins to buy batteries, etc., and eventually never be able to get
- * across again. If bottle were left on far side, could then never get eggs
- * or trident, and the effects propagate. So the whole thing was flushed.
- * anyone who makes such a gross blunder isn't likely to find everything
- * else anyway (so goes the rationalisation). */
-L2006: KK=PROP[OBJ];
- if(OBJ == STEPS && LOC == FIXED[STEPS])KK=1;
- PSPEAK(OBJ,KK);
-L2008: I=LINK[I];
- goto L2004;
-
-L2009: K=54;
-L2010: SPK=K;
-L2011: RSPEAK(SPK);
-
-L2012: VERB=0;
- OLDOBJ=OBJ;
- OBJ=0;
-
-/* Check if this loc is eligible for any hints. If been here long enough,
- * branch to help section (on later page). Hints all come back here eventually
- * to finish the loop. Ignore "HINTS" < 4 (special stuff, see database notes).
- */
-
-L2600: if(COND[LOC] < game.conds) goto L2603;
- /* 2602 */ for (HINT=1; HINT<=HNTMAX; HINT++) {
- if(HINTED[HINT]) goto L2602;
- if(!CNDBIT(LOC,HINT+10))HINTLC[HINT]= -1;
- HINTLC[HINT]=HINTLC[HINT]+1;
- if(HINTLC[HINT] >= HINTS[HINT][1]) goto L40000;
-L2602: /*etc*/ ;
- } /* end loop */
-
-/* If closing time, check for any objects being toted with PROP < 0 and set
- * the prop to -1-PROP. This way objects won't be described until they've
- * been picked up and put down separate from their respective piles. Don't
- * tick game.clock1 unless well into cave (and not at Y2). */
-
-L2603: if(!game.closed) goto L2605;
- if(PROP[OYSTER] < 0 && TOTING(OYSTER))PSPEAK(OYSTER,1);
- for (I=1; I<=NOBJECTS; I++) {
- if(TOTING(I) && PROP[I] < 0)PROP[I]= -1-PROP[I];
- } /* end loop */
-L2605: game.wzdark=DARK(0);
- if(game.knfloc > 0 && game.knfloc != LOC)game.knfloc=0;
- I=0;
- if (!GETIN(cmdin, WD1,WD1X,WD2,WD2X))
- return false;
+/* Check if this loc is eligible for any hints. If been here
+ * long enough, branch to help section (on later page). Hints
+ * all come back here eventually to finish the loop. Ignore
+ * "HINTS" < 4 (special stuff, see database notes).
+ */
+static void checkhints(FILE *cmdin)
+{
+ if (COND[game.loc] >= game.conds) {
+ for (int hint=1; hint<=HNTMAX; hint++) {
+ if (game.hinted[hint])
+ continue;
+ if (!CNDBIT(game.loc,hint+HBASE))
+ game.hintlc[hint]= -1;
+ ++game.hintlc[hint];
+ /* Come here if he's been long enough at required loc(s) for some
+ * unused hint. */
+ if (game.hintlc[hint] >= HINTS[hint][1])
+ {
+ int i;
+
+ switch (hint-1)
+ {
+ case 0:
+ /* cave */
+ if (game.prop[GRATE] == 0 && !HERE(KEYS))
+ break;
+ game.hintlc[hint]=0;
+ return;
+ case 1: /* bird */
+ if (game.place[BIRD] == game.loc && TOTING(ROD) && game.oldobj == BIRD)
+ break;
+ return;
+ case 2: /* snake */
+ if (HERE(SNAKE) && !HERE(BIRD))
+ break;
+ game.hintlc[hint]=0;
+ return;
+ case 3: /* maze */
+ if (game.atloc[game.loc] == 0 &&
+ game.atloc[game.oldloc] == 0 &&
+ game.atloc[game.oldlc2] == 0 &&
+ game.holdng > 1)
+ break;
+ game.hintlc[hint]=0;
+ return;
+ case 4: /* dark */
+ if (game.prop[EMRALD] != -1 && game.prop[PYRAM] == -1)
+ break;
+ game.hintlc[hint]=0;
+ return;
+ case 5: /* witt */
+ break;
+ case 6: /* urn */
+ if (game.dflag == 0)
+ break;
+ game.hintlc[hint]=0;
+ return;
+ case 7: /* woods */
+ if (game.atloc[game.loc] == 0 &&
+ game.atloc[game.oldloc] == 0 &&
+ game.atloc[game.oldlc2] == 0)
+ break;
+ return;
+ case 8: /* ogre */
+ i=ATDWRF(game.loc);
+ if (i < 0) {
+ game.hintlc[hint]=0;
+ return;
+ }
+ if (HERE(OGRE) && i == 0)
+ break;
+ return;
+ case 9: /* jade */
+ if (game.tally == 1 && game.prop[JADE] < 0)
+ break;
+ game.hintlc[hint]=0;
+ return;
+ default:
+ BUG(27);
+ break;
+ }
+
+ /* Fall through to hint display */
+ game.hintlc[hint]=0;
+ if (!YES(cmdin,HINTS[hint][3],ARB_0,OK_MAN))
+ return;
+ SETPRM(1,HINTS[hint][2],HINTS[hint][2]);
+ RSPEAK(HINT_COST);
+ game.hinted[hint]=YES(cmdin,WANT_HINT,HINTS[hint][4],OK_MAN);
+ if (game.hinted[hint] && game.limit > WARNTIME)
+ game.limit += WARNTIME*HINTS[hint][2];
+ }
+ }
+ }
+}