if(OBJ == GRATE || OBJ == CHAIN)SPK=31;
if(SPK != 31 || !HERE(KEYS)) return(2011);
if(OBJ == CHAIN) goto L9048;
- if(!CLOSNG) goto L9043;
+ if(!game.closng) goto L9043;
K=130;
if(!PANIC)game.clock2=15;
PANIC=true;
if(LIMIT < 0) return(2011);
PROP[LAMP]=1;
RSPEAK(39);
- if(WZDARK) return(2000);
+ if(game.wzdark) return(2000);
return(2012);
L9073: SPK=38;
/* Wave. No effect unless waving rod at fissure or at bird. */
L9090: if((!TOTING(OBJ)) && (OBJ != ROD || !TOTING(ROD2)))SPK=29;
- if(OBJ != ROD || !TOTING(OBJ) || (!HERE(BIRD) && (CLOSNG || !AT(FISSUR))))
+ if(OBJ != ROD || !TOTING(OBJ) || (!HERE(BIRD) && (game.closng || !AT(FISSUR))))
return(2011);
if(HERE(BIRD))SPK=206+MOD(PROP[BIRD],2);
if(SPK == 206 && LOC == PLACE[STEPS] && PROP[JADE] < 0) goto L9094;
- if(CLOSED) return(18999);
- if(CLOSNG || !AT(FISSUR)) return(2011);
+ if(game.closed) return(18999);
+ if(game.closng || !AT(FISSUR)) return(2011);
if(HERE(BIRD))RSPEAK(SPK);
PROP[FISSUR]=1-PROP[FISSUR];
PSPEAK(FISSUR,2-PROP[FISSUR]);
L9190: if(AT(OBJ) || (LIQ(0) == OBJ && AT(BOTTLE)) || K == LIQLOC(LOC) || (OBJ ==
DWARF && ATDWRF(LOC) > 0))SPK=94;
- if(CLOSED)SPK=138;
+ if(game.closed)SPK=138;
if(TOTING(OBJ))SPK=24;
return(2011);
/* 8201 */ for (I=1; I<=NOBJECTS; I++) {
if(I == BEAR || !TOTING(I)) goto L8201;
if(SPK == 98)RSPEAK(99);
- BLKLIN=false;
+ game.blklin=false;
PSPEAK(I,-1);
- BLKLIN=true;
+ game.blklin=true;
SPK=0;
L8201: /*etc*/ ;
} /* end loop */
/* Blast. No effect unless you've got dynamite, which is a neat trick! */
-L9230: if(PROP[ROD2] < 0 || !CLOSED) return(2011);
- BONUS=133;
- if(LOC == 115)BONUS=134;
- if(HERE(ROD2))BONUS=135;
- RSPEAK(BONUS);
+L9230: if(PROP[ROD2] < 0 || !game.closed) return(2011);
+ game.bonus=133;
+ if(LOC == 115)game.bonus=134;
+ if(HERE(ROD2))game.bonus=135;
+ RSPEAK(game.bonus);
score(0);
/* Score. Call scoring routine but tell it to return. */
/* Brief. Intransitive only. Suppress long descriptions after first time. */
L8260: SPK=156;
- ABBNUM=10000;
- DETAIL=3;
+ game.abbnum=10000;
+ game.detail=3;
return(2011);
/* Read. Print stuff based on objtxt. Oyster (?) is special case. */
L9280: if(OBJ == MIRROR)SPK=148;
if(OBJ == VASE && PROP[VASE] == 0) goto L9282;
- if(OBJ != MIRROR || !CLOSED) return(2011);
+ if(OBJ != MIRROR || !game.closed) return(2011);
SPK=197;
return(18999);
/* Wake. Only use is to disturb the dwarves. */
-L9290: if(OBJ != DWARF || !CLOSED) return(2011);
+L9290: if(OBJ != DWARF || !game.closed) return(2011);
SPK=199;
return(18999);
* suspended or resumed are guaranteed to match. If unsure whether a value
* needs to be saved, include it. Overkill can't hurt. Pad the last savwds
* with junk variables to bring it up to 7 values. */
- SAVWDS(ABBNUM,BLKLIN,BONUS,game.clock1,game.clock2,CLOSED,CLOSNG);
- SAVWDS(DETAIL,DFLAG,DKILL,DTOTAL,FOOBAR,HOLDNG,IWEST);
+ SAVWDS(game.abbnum,game.blklin,game.bonus,game.clock1,game.clock2,game.closed,game.closng);
+ SAVWDS(game.detail,DFLAG,game.dkill,game.dtotal,FOOBAR,HOLDNG,IWEST);
SAVWDS(KNFLOC,LIMIT,LL,LMWARN,LOC,NEWLOC,NUMDIE);
SAVWDS(OBJ,game.oldlc2,game.oldloc,OLDOBJ,PANIC,SAVED,SETUP);
SAVWDS(SPK,TALLY,THRESH,TRNDEX,TRNLUZ,TURNS,OBJTXT[OYSTER]);
- SAVWDS(VERB,WD1,WD1X,WD2,WZDARK,game.zzword,OBJSND[BIRD]);
+ SAVWDS(VERB,WD1,WD1X,WD2,game.wzdark,game.zzword,OBJSND[BIRD]);
SAVWDS(OBJTXT[SIGN],CLSHNT,NOVICE,K,K,K,K);
SAVARR(ABB,LOCSIZ);
SAVARR(ATLOC,LOCSIZ);
if(!TOTING(OBJ)) return(2011);
if(OBJ != BIRD || !HERE(SNAKE)) goto L9023;
RSPEAK(30);
- if(CLOSED) return(19000);
+ if(game.closed) return(19000);
DSTROY(SNAKE);
/* SET PROP FOR USE BY TRAVEL OPTIONS */
PROP[SNAKE]=1;
if(OBJ > NOBJECTS) return(8000);
L9124: if(OBJ == BIRD) {
SPK=137;
- if(CLOSED) return(2011);
+ if(game.closed) return(2011);
DSTROY(BIRD);
PROP[BIRD]=0;
SPK=45;
if(OBJ == CLAM || OBJ == OYSTER)SPK=150;
if(OBJ == SNAKE)SPK=46;
if(OBJ == DWARF)SPK=49;
- if(OBJ == DWARF && CLOSED) return(19000);
+ if(OBJ == DWARF && game.closed) return(19000);
if(OBJ == DRAGON)SPK=167;
if(OBJ == TROLL)SPK=157;
if(OBJ == OGRE)SPK=203;
game.dseen[I]=false;
game.dloc[I]=0;
SPK=47;
- DKILL=DKILL+1;
- if(DKILL == 1)SPK=149;
+ game.dkill=game.dkill+1;
+ if(game.dkill == 1)SPK=149;
L9175: RSPEAK(SPK);
DROP(AXE,LOC);
K=NUL;
SPK=102;
if(OBJ == DRAGON && PROP[DRAGON] != 0)SPK=110;
if(OBJ == TROLL)SPK=182;
- if(OBJ != SNAKE || CLOSED || !HERE(BIRD)) return(2011);
+ if(OBJ != SNAKE || game.closed || !HERE(BIRD)) return(2011);
SPK=101;
DSTROY(BIRD);
PROP[BIRD]=0;
typedef long vocab_t; /* index into a vocabulary array */
struct game_t {
+ long abbnum;
+ long blklin;
+ long bonus;
+ long chloc;
+ long chloc2;
long clock1;
long clock2;
+ long closed;
+ long closng;
+ long conds;
+ long detail;
+ long dkill;
+ long dtotal;
long oldloc;
long oldlc2;
+ long wzdark;
long zzword;
long dseen[NDWARVES+1];
long dloc[NDWARVES+1];
extern long randrange(long);
extern void score(long);
-extern long ABBNUM, AMBER, ATTACK, AXE, BACK, BATTER, BEAR,
- BIRD, BLOOD, BONUS,
- BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2,
- CLAM, CLOSED, CLOSNG, CLSHNT,
- COINS, CONDS, DALTLC, DETAIL,
- DKILL, DOOR, DPRSSN, DRAGON, DTOTAL, DWARF, EGGS,
+extern long AMBER, ATTACK, AXE, BACK, BATTER, BEAR,
+ BIRD, BLOOD, BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST,
+ CLAM, CLSHNT, COINS, DALTLC, DOOR, DPRSSN, DRAGON, DWARF, EGGS,
EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOBAR, FOOD,
GRATE, HINT, HINTED[], HINTLC[],
I, INVENT, IGO, IWEST, J, JADE, K, K2, KEYS, KK,
STREAM, TALLY, THRESH, THROW, TK[], TRIDNT,
TRNDEX, TRNLUZ, TROLL, TROLL2,
TURNS, URN, V1, V2, VASE, VEND, VERB,
- VOLCAN, VRSION, WATER, WD1, WD1X, WD2, WD2X,
- WZDARK;
+ VOLCAN, VRSION, WATER, WD1, WD1X, WD2, WD2X;
* 3 A knife has been thrown (first set always misses)
* 3+ Dwarves are mad (increases their accuracy)
* Sixth dwarf is special (the pirate). He always starts at his chest's
- * eventual location inside the maze. This loc is saved in CHLOC for ref.
- * the dead end in the other maze has its loc stored in CHLOC2. */
+ * eventual location inside the maze. This loc is saved in game.chloc for ref.
+ * the dead end in the other maze has its loc stored in game.chloc2. */
- CHLOC=114;
- CHLOC2=140;
+ game.chloc=114;
+ game.chloc2=140;
for (I=1; I<=NDWARVES; I++) {
game.dseen[I]=false;
} /* end loop */
game.dloc[3]=33;
game.dloc[4]=44;
game.dloc[5]=64;
- game.dloc[6]=CHLOC;
+ game.dloc[6]=game.chloc;
DALTLC=18;
/* Other random flags and counters, as follows:
- * ABBNUM How often we should print non-abbreviated descriptions
- * BONUS Used to determine amount of bonus if he reaches closing
+ * game.abbnum How often we should print non-abbreviated descriptions
+ * game.bonus Used to determine amount of bonus if he reaches closing
* game.clock1 Number of turns from finding last treasure till closing
* game.clock2 Number of turns from first warning till blinding flash
- * CONDS Min value for cond(loc) if loc has any hints
- * DETAIL How often we've said "not allowed to give more detail"
- * DKILL Number of dwarves killed (unused in scoring, needed for msg)
+ * game.conds Min value for cond(loc) if loc has any hints
+ * game.detail How often we've said "not allowed to give more detail"
+ * game.dkill # of dwarves killed (unused in scoring, needed for msg)
* FOOBAR Current progress in saying "FEE FIE FOE FOO".
* HOLDNG Number of objects being carried
* IGO How many times he's said "go XXX" instead of "XXX"
IGO=0;
IWEST=0;
KNFLOC=0;
- DETAIL=0;
- ABBNUM=5;
+ game.detail=0;
+ game.abbnum=5;
for (I=0; I<=4; I++) {
{long x = 2*I+81; if(RTEXT[x] != 0)MAXDIE=I+1;}
} /* end loop */
NUMDIE=0;
HOLDNG=0;
- DKILL=0;
+ game.dkill=0;
FOOBAR=0;
- BONUS=0;
+ game.bonus=0;
game.clock1=30;
game.clock2=50;
- CONDS=SETBIT(11);
+ game.conds=SETBIT(11);
SAVED=0;
- CLOSNG=false;
+ game.closng=false;
PANIC=false;
- CLOSED=false;
+ game.closed=false;
CLSHNT=false;
NOVICE=false;
SETUP=1;
+ game.blklin=true;
/* if we can ever think of how, we should save it at this point */
struct game_t game;
-long ABB[186], ATLOC[186], BLKLIN = true, DFLAG,
+long ABB[186], ATLOC[186], DFLAG,
FIXED[NOBJECTS+1], HOLDNG,
LINK[NOBJECTS*2 + 1], LNLENG, LNPOSN,
PARMS[26], PLACE[NOBJECTS+1],
SETUP = 0;
char rawbuf[LINESIZE], INLINE[LINESIZE+1], MAP1[129], MAP2[129];
-long ABBNUM, AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BONUS,
- BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2,
- CLAM, CLOSED, CLOSNG, CLSHNT, COINS, CONDS, DALTLC, DETAIL,
- DKILL, DOOR, DPRSSN, DRAGON, DTOTAL, DWARF, EGGS,
+long AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD,
+ BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST,
+ CLAM, CLSHNT, COINS, DALTLC,
+ DOOR, DPRSSN, DRAGON, DWARF, EGGS,
EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOBAR, FOOD,
GRATE, HINT, HINTED[21], HINTLC[21],
I, INVENT, IGO, IWEST, J, JADE, K, K2, KEYS, KK,
STREAM, TALLY, THRESH, THROW, TK[21], TRIDNT,
TRNDEX, TRNLUZ, TROLL, TROLL2,
TURNS, URN, V1, V2, VASE, VEND, VERB,
- VOLCAN, VRSION = 25, WATER, WD1, WD1X, WD2, WD2X,
- WZDARK = false;
+ VOLCAN, VRSION = 25, WATER, WD1, WD1X, WD2, WD2X;
FILE *logfp;
bool oldstyle = false;
lcg_state lcgstate;
/* Logical variables:
*
- * CLOSED says whether we're all the way closed
- * CLOSNG says whether it's closing time yet
+ * game.closed says whether we're all the way closed
+ * game.closng says whether it's closing time yet
* CLSHNT says whether he's read the clue in the endgame
* LMWARN says whether he's been warned about lamp going dim
* NOVICE says whether he asked for instructions at start-up
* PANIC says whether he's found out he's trapped in the cave
- * WZDARK says whether the loc he's leaving was dark */
+ * game.wzdark says whether the loc he's leaving was dark */
#include "funcs.h"
/* Can't leave cave once it's closing (except by main office). */
- if(!OUTSID(NEWLOC) || NEWLOC == 0 || !CLOSNG) goto L71;
+ if(!OUTSID(NEWLOC) || NEWLOC == 0 || !game.closng) goto L71;
RSPEAK(130);
NEWLOC=LOC;
if(!PANIC)game.clock2=15;
* 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: DTOTAL=0;
+L6010: game.dtotal=0;
ATTACK=0;
STICK=0;
/* 6030 */ for (I=1; I<=NDWARVES; I++) {
* 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 == CHLOC || PROP[CHEST] >= 0) goto L6030;
+ 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!). */
L6021: if(PLACE[CHEST] != 0) goto L6022;
/* Install chest only once, to insure it is the last treasure in the list. */
- MOVE(CHEST,CHLOC);
- MOVE(MESSAG,CHLOC2);
+ 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,CHLOC);
+ if(TOTING(J))DROP(J,game.chloc);
L6023: /*etc*/ ;
} /* end loop */
-L6024: game.dloc[6]=CHLOC;
- game.odloc[6]=CHLOC;
+L6024: game.dloc[6]=game.chloc;
+ game.odloc[6]=game.chloc;
game.dseen[6]=false;
goto L6030;
L6025: RSPEAK(186);
- MOVE(CHEST,CHLOC);
- MOVE(MESSAG,CHLOC2);
+ MOVE(CHEST,game.chloc);
+ MOVE(MESSAG,game.chloc2);
goto L6024;
/* This threatening little dwarf is in the room with him! */
-L6027: DTOTAL=DTOTAL+1;
+L6027: game.dtotal=game.dtotal+1;
if(game.odloc[I] != game.dloc[I]) goto L6030;
ATTACK=ATTACK+1;
if(KNFLOC >= 0)KNFLOC=LOC;
* Note that various of the "knife" messages must have specific relative
* positions in the RSPEAK database. */
- if(DTOTAL == 0) goto L2000;
- SETPRM(1,DTOTAL,0);
- RSPEAK(4+1/DTOTAL);
+ if(game.dtotal == 0) goto L2000;
+ SETPRM(1,game.dtotal,0);
+ RSPEAK(4+1/game.dtotal);
if(ATTACK == 0) goto L2000;
if(DFLAG == 2)DFLAG=3;
SETPRM(1,ATTACK,0);
L2000: if(LOC == 0) goto L99;
KK=STEXT[LOC];
- if(MOD(ABB[LOC],ABBNUM) == 0 || KK == 0)KK=LTEXT[LOC];
+ if(MOD(ABB[LOC],game.abbnum) == 0 || KK == 0)KK=LTEXT[LOC];
if(FORCED(LOC) || !DARK(0)) goto L2001;
- if(WZDARK && PCT(35)) goto L90;
+ 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) && !CLOSNG)RSPEAK(7);
+ 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
if(OBJ > NOBJECTS)OBJ=OBJ-NOBJECTS;
if(OBJ == STEPS && TOTING(NUGGET)) goto L2008;
if(PROP[OBJ] >= 0) goto L2006;
- if(CLOSED) goto L2008;
+ if(game.closed) goto L2008;
PROP[OBJ]=0;
if(OBJ == RUG || OBJ == CHAIN)PROP[OBJ]=1;
TALLY=TALLY-1;
* to finish the loop. Ignore "HINTS" < 4 (special stuff, see database notes).
*/
-L2600: if(COND[LOC] < CONDS) goto L2603;
+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;
* 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(!CLOSED) goto L2605;
+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: WZDARK=DARK(0);
+L2605: game.wzdark=DARK(0);
if(KNFLOC > 0 && KNFLOC != LOC)KNFLOC=0;
I=0;
if (!GETIN(cmdin, WD1,WD1X,WD2,WD2X))
/* Look. Can't give more detail. Pretend it wasn't dark (though it may "now"
* be dark) so he won't fall into a pit while staring into the gloom. */
-L30: if(DETAIL < 3)RSPEAK(15);
- DETAIL=DETAIL+1;
- WZDARK=false;
+L30: if(game.detail < 3)RSPEAK(15);
+ game.detail=game.detail+1;
+ game.wzdark=false;
ABB[LOC]=0;
return true;
/* Okay, he's dead. Let's get on with it. */
-L99: if(CLOSNG) goto L95;
+L99: if(game.closng) goto L95;
NUMDIE=NUMDIE+1;
if(!YES(cmdin,79+NUMDIE*2,80+NUMDIE*2,54)) score(0);
if(NUMDIE == MAXDIE) score(0);
FIXED[AXE]=0;
RSPEAK(129);
game.clock1= -1;
- CLOSNG=true;
+ game.closng=true;
goto L19999;
/* Once he's panicked, and clock2 has run out, we come here to set up the
} /* end loop */
RSPEAK(132);
- CLOSED=true;
+ game.closed=true;
return true;
/* Another way we can force an end to things is by having the lamp give out.
long BLANK, CASE, I, K, L, NEG, NPARMS, PARM, PRMTYP, STATE;
/* Print the message which starts at LINES(N). Precede it with a blank line
- * unless BLKLIN is false. */
+ * unless game.blklin is false. */
if(N == 0)return;
- BLANK=BLKLIN;
+ BLANK=game.blklin;
K=N;
NPARMS=1;
L10: L=labs(LINES[K])-1;
* WORD2 (chars 6 thru 10 in WORD2X), else WORD2 is -1. */
-L10: if(BLKLIN)TYPE0();
+L10: if(game.blklin)TYPE0();
MAPLIN(input);
if (feof(input))
return false;
WORD1=GETTXT(true,true,true);
- if(BLKLIN && WORD1 < 0) goto L10;
+ if(game.blklin && WORD1 < 0) goto L10;
WORD1X=GETTXT(false,true,true);
L12: JUNK=GETTXT(false,true,true);
if(JUNK > 0) goto L12;
* Each treasure > chest 16 224
* Surviving (MAX-NUM)*10 30
* Not quitting 4 4
- * Reaching "CLOSNG" 25 25
+ * Reaching "game.closng" 25 25
* "Closed": Quit/Killed 10
* Klutzed 25
* Wrong way 30
/* Now look at how he finished and how far he got. MAXDIE and NUMDIE tell us
* how well he survived. DFLAG will
- * tell us if he ever got suitably deep into the cave. CLOSNG still indicates
+ * tell us if he ever got suitably deep into the cave. game.closng still indicates
* whether he reached the endgame. And if he got as far as "cave closed"
- * (indicated by "CLOSED"), then bonus is zero for mundane exits or 133, 134,
+ * (indicated by "game.closed"), then bonus is zero for mundane exits or 133, 134,
* 135 if he blew it (so to speak). */
SCORE=SCORE+(MAXDIE-NUMDIE)*10;
MXSCOR=MXSCOR+4;
if(DFLAG != 0)SCORE=SCORE+25;
MXSCOR=MXSCOR+25;
- if(CLOSNG)SCORE=SCORE+25;
+ if(game.closng)SCORE=SCORE+25;
MXSCOR=MXSCOR+25;
- if(!CLOSED) goto L20020;
- if(BONUS == 0)SCORE=SCORE+10;
- if(BONUS == 135)SCORE=SCORE+25;
- if(BONUS == 134)SCORE=SCORE+30;
- if(BONUS == 133)SCORE=SCORE+45;
+ if(!game.closed) goto L20020;
+ if(game.bonus == 0)SCORE=SCORE+10;
+ if(game.bonus == 135)SCORE=SCORE+25;
+ if(game.bonus == 134)SCORE=SCORE+30;
+ if(game.bonus == 133)SCORE=SCORE+45;
L20020: MXSCOR=MXSCOR+45;
/* Did he come to Witt's End as he should? */