From 0b02763bf07618d3b3b88d9a8c907d0d60b33014 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 7 Jun 2017 06:38:40 -0400 Subject: [PATCH] More collecting of globals. --- actions1.c | 36 ++++++++++++++++++------------------ actions2.c | 20 ++++++++++---------- advent.h | 9 +++++++-- compile.c | 7 +++---- funcs.h | 4 ++-- init.c | 26 +++++++++++++------------- main.c | 46 ++++++++++++++++++++++------------------------ misc.c | 40 ++++++++++++++++++++-------------------- score.c | 6 +++--- sizes.h | 1 + 10 files changed, 99 insertions(+), 96 deletions(-) diff --git a/actions1.c b/actions1.c index 7f00bda..9c4978b 100644 --- a/actions1.c +++ b/actions1.c @@ -156,8 +156,8 @@ L5190: if((VERB == FIND || VERB == INVENT) && WD2 <= 0) goto L5010; /* Carry, no object given yet. OK if only one object present. */ -L8010: if(ATLOC[LOC] == 0 || LINK[ATLOC[LOC]] != 0 || ATDWRF(LOC) > 0) return(8000); - OBJ=ATLOC[LOC]; +L8010: if(game.atloc[LOC] == 0 || game.link[game.atloc[LOC]] != 0 || ATDWRF(LOC) > 0) return(8000); + OBJ=game.atloc[LOC]; /* Transitive carry/drop are in separate file. */ @@ -231,9 +231,9 @@ L9048: if(VERB == LOCK) goto L9049; if(PROP[CHAIN] == 0)SPK=37; if(SPK != 171) return(2011); PROP[CHAIN]=0; - FIXED[CHAIN]=0; + game.fixed[CHAIN]=0; if(PROP[BEAR] != 3)PROP[BEAR]=2; - FIXED[BEAR]=2-PROP[BEAR]; + game.fixed[BEAR]=2-PROP[BEAR]; return(2011); L9049: SPK=172; @@ -242,7 +242,7 @@ L9049: SPK=172; if(SPK != 172) return(2011); PROP[CHAIN]=2; if(TOTING(CHAIN))DROP(CHAIN,LOC); - FIXED[CHAIN]= -1; + game.fixed[CHAIN]= -1; return(2011); /* Light. Applicable only to lamp and urn. */ @@ -292,7 +292,7 @@ L9090: if((!TOTING(OBJ)) && (OBJ != ROD || !TOTING(ROD2)))SPK=29; 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(SPK == 206 && LOC == game.place[STEPS] && PROP[JADE] < 0) goto L9094; if(game.closed) return(18999); if(game.closng || !AT(FISSUR)) return(2011); if(HERE(BIRD))RSPEAK(SPK); @@ -320,7 +320,7 @@ L9130: if(OBJ == BOTTLE || OBJ == 0)OBJ=LIQ(0); if(OBJ != OIL && OBJ != WATER) return(2011); if(HERE(URN) && PROP[URN] == 0) goto L9134; PROP[BOTTLE]=1; - PLACE[OBJ]=0; + game.place[OBJ]=0; SPK=77; if(!(AT(PLANT) || AT(DOOR))) return(2011); @@ -364,7 +364,7 @@ L9150: if(OBJ == 0 && LIQLOC(LOC) != WATER && (LIQ(0) != WATER || !HERE(BOTTLE)) if(OBJ != 0 && OBJ != WATER)SPK=110; if(SPK == 110 || LIQ(0) != WATER || !HERE(BOTTLE)) return(2011); PROP[BOTTLE]=1; - PLACE[WATER]=0; + game.place[WATER]=0; SPK=74; return(2011); @@ -453,10 +453,10 @@ L8250: K=VOCAB(WD1,3); L8252: game.foobar=K; if(K != 4) return(2009); game.foobar=0; - if(PLACE[EGGS] == PLAC[EGGS] || (TOTING(EGGS) && LOC == PLAC[EGGS])) + if(game.place[EGGS] == PLAC[EGGS] || (TOTING(EGGS) && LOC == PLAC[EGGS])) return(2011); /* Bring back troll if we steal the eggs back from him before crossing. */ - if(PLACE[EGGS] == 0 && PLACE[TROLL] == 0 && PROP[TROLL] == + if(game.place[EGGS] == 0 && game.place[TROLL] == 0 && PROP[TROLL] == 0)PROP[TROLL]=1; K=2; if(HERE(EGGS))K=1; @@ -499,7 +499,7 @@ L9280: if(OBJ == MIRROR)SPK=148; L9282: SPK=198; if(TOTING(VASE))DROP(VASE,LOC); PROP[VASE]=2; - FIXED[VASE]= -1; + game.fixed[VASE]= -1; return(2011); /* Wake. Only use is to disturb the dwarves. */ @@ -541,15 +541,15 @@ L8305: DATIME(&I,&K); SAVWDS(VERB,WD1,WD1X,WD2,game.wzdark,game.zzword,OBJSND[BIRD]); SAVWDS(OBJTXT[SIGN],game.clshnt,game.novice,K,K,K,K); SAVARR(game.abbrev,LOCSIZ); - SAVARR(ATLOC,LOCSIZ); + SAVARR(game.atloc,LOCSIZ); SAVARR(game.dloc,NDWARVES); SAVARR(game.dseen,NDWARVES); - SAVARR(FIXED,NOBJECTS); - SAVARR(HINTED,HNTSIZ); + SAVARR(game.fixed,NOBJECTS); + SAVARR(game.hinted,HNTSIZ); SAVARR(HINTLC,HNTSIZ); - SAVARR(LINK,NOBJECTS*2); + SAVARR(game.link,NOBJECTS*2); SAVARR(game.odloc,NDWARVES); - SAVARR(PLACE,NOBJECTS); + SAVARR(game.place,NOBJECTS); SAVARR(PROP,NOBJECTS); SAVWRD(KK,K); if(K != 0) goto L8318; @@ -587,7 +587,7 @@ L9320: if(OBJ != RUG) return(2011); if(PROP[RUG] != 2) return(2011); game.oldlc2=game.oldloc; game.oldloc=LOC; - game.newloc=PLACE[RUG]+FIXED[RUG]-LOC; + game.newloc=game.place[RUG]+game.fixed[RUG]-LOC; SPK=226; if(PROP[SAPPH] >= 0)SPK=227; RSPEAK(SPK); @@ -613,7 +613,7 @@ L8335: /*etc*/ ; /* Z'ZZZ (word gets recomputed at startup; different each game). */ -L8340: if(!AT(RESER) && LOC != FIXED[RESER]-1) return(2011); +L8340: if(!AT(RESER) && LOC != game.fixed[RESER]-1) return(2011); PSPEAK(RESER,PROP[RESER]+1); PROP[RESER]=1-PROP[RESER]; if(AT(RESER)) return(2012); diff --git a/actions2.c b/actions2.c index 3078408..043913e 100644 --- a/actions2.c +++ b/actions2.c @@ -19,7 +19,7 @@ int carry(void) { if(OBJ != MESSAG) goto L9011; SPK=190; DSTROY(MESSAG); -L9011: if(FIXED[OBJ] != 0) return(2011); +L9011: if(game.fixed[OBJ] != 0) return(2011); if(OBJ != WATER && OBJ != OIL) goto L9017; K=OBJ; OBJ=BOTTLE; @@ -40,7 +40,7 @@ L9014: if((OBJ == BIRD || OBJ == CAGE) && (PROP[BIRD] == 1 || -1-PROP[BIRD] == 1))CARRY(BIRD+CAGE-OBJ,LOC); CARRY(OBJ,LOC); K=LIQ(0); - if(OBJ == BOTTLE && K != 0)PLACE[K]= -1; + if(OBJ == BOTTLE && K != 0)game.place[K]= -1; if(!GSTONE(OBJ) || PROP[OBJ] == 0) return(2009); PROP[OBJ]=0; PROP[CAVITY]=1; @@ -67,7 +67,7 @@ int discard(bool just_do_it) { PROP[SNAKE]=1; L9021: K=LIQ(0); if(K == OBJ)OBJ=BOTTLE; - if(OBJ == BOTTLE && K != 0)PLACE[K]=0; + if(OBJ == BOTTLE && K != 0)game.place[K]=0; if(OBJ == CAGE && PROP[BIRD] == 1)DROP(BIRD,LOC); DROP(OBJ,LOC); if(OBJ != BIRD) return(2012); @@ -121,7 +121,7 @@ L9027: if(OBJ == VASE && LOC != PLAC[PILLOW]) goto L9028; L9028: PROP[VASE]=2; if(AT(PILLOW))PROP[VASE]=0; PSPEAK(VASE,PROP[VASE]+1); - if(PROP[VASE] != 0)FIXED[VASE]= -1; + if(PROP[VASE] != 0)game.fixed[VASE]= -1; goto L9021; } @@ -187,7 +187,7 @@ L9126: if(OBJ == 0)SPK=44; MOVE(RUG,K); DROP(BLOOD,K); for (OBJ=1; OBJ<=NOBJECTS; OBJ++) { - if(PLACE[OBJ] == PLAC[DRAGON] || PLACE[OBJ] == FIXD[DRAGON])MOVE(OBJ,K); + if(game.place[OBJ] == PLAC[DRAGON] || game.place[OBJ] == FIXD[DRAGON])MOVE(OBJ,K); /*etc*/ ; } /* end loop */ LOC=K; @@ -246,7 +246,7 @@ L9175: RSPEAK(SPK); /* This'll teach him to throw the axe at the bear! */ L9176: SPK=164; DROP(AXE,LOC); - FIXED[AXE]= -1; + game.fixed[AXE]= -1; PROP[AXE]=1; JUGGLE(BEAR); return(2011); @@ -296,7 +296,7 @@ L9214: if(OBJ != BEAR) goto L9215; if(!HERE(FOOD)) return(2011); DSTROY(FOOD); PROP[BEAR]=1; - FIXED[AXE]=0; + game.fixed[AXE]=0; PROP[AXE]=0; SPK=168; return(2011); @@ -323,7 +323,7 @@ int fill() { if(SPK != 107) return(2011); PROP[BOTTLE]=MOD(COND[LOC],4)/2*2; K=LIQ(0); - if(TOTING(BOTTLE))PLACE[K]= -1; + if(TOTING(BOTTLE))game.place[K]= -1; if(K == OIL)SPK=108; return(2011); @@ -332,7 +332,7 @@ L9222: SPK=29; if(LIQLOC(LOC) == 0 || !TOTING(VASE)) return(2011); RSPEAK(145); PROP[VASE]=2; - FIXED[VASE]= -1; + game.fixed[VASE]= -1; return(discard(true)); L9224: SPK=213; @@ -340,7 +340,7 @@ L9224: SPK=213; SPK=144; K=LIQ(0); if(K == 0 || !HERE(BOTTLE)) return(2011); - PLACE[K]=0; + game.place[K]=0; PROP[BOTTLE]=1; if(K == OIL)PROP[URN]=1; SPK=211+PROP[URN]; diff --git a/advent.h b/advent.h index 192248d..ed39d8e 100644 --- a/advent.h +++ b/advent.h @@ -54,14 +54,19 @@ struct game_t { long wzdark; long zzword; long abbrev[LOCSIZ+1]; + long atloc[LOCSIZ+1]; long dseen[NDWARVES+1]; long dloc[NDWARVES+1]; long odloc[NDWARVES+1]; + long fixed[NOBJECTS+1]; + long link[NOBJECTS*2 + 1]; + long place[NOBJECTS+1]; + long hinted[HNTSIZ+1]; }; extern struct game_t game; -extern long ATLOC[], FIXED[], LINK[], LNLENG, LNPOSN, PARMS[], PLACE[]; +extern long LNLENG, LNPOSN, PARMS[]; extern char rawbuf[LINESIZE], INLINE[LINESIZE+1], MAP1[], MAP2[]; extern FILE *logfp; extern bool oldstyle; @@ -127,7 +132,7 @@ extern long AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CLAM, COINS, DALTLC, DOOR, DPRSSN, DRAGON, DWARF, EGGS, EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOD, - GRATE, HINT, HINTED[], HINTLC[], + GRATE, HINT, HINTLC[], I, INVENT, IGO, J, JADE, K, K2, KEYS, KK, KNIFE, KQ, L, LAMP, LL, LOC, LOCK, LOOK, MAGZIN, MAXDIE, MAXTRS, MESSAG, MIRROR, MXSCOR, NUGGET, NUL, OBJ, diff --git a/compile.c b/compile.c index 4360d97..7f6d8ed 100644 --- a/compile.c +++ b/compile.c @@ -12,7 +12,6 @@ #define TRNSIZ 5 #define TABSIZ 330 #define VRBSIZ 35 -#define HNTSIZ 20 #define TRVSIZ 885 #define TOKLEN 5 #define HINTLEN 5 @@ -510,9 +509,9 @@ void read_sound_text(FILE* database) /* Having read in the database, certain things are now constructed. * PROPS are set to zero. We finish setting up COND by checking for * forced-motion travel entries. The PLAC and FIXD arrays are used - * to set up ATLOC(N) as the first object at location N, and - * LINK(OBJ) as the next object at the same location as OBJ. - * (OBJ>NOBJECTS indicates that FIXED(OBJ-NOBJECTS)=LOC; LINK(OBJ) is + * to set up game.atloc(N) as the first object at location N, and + * game.link(OBJ) as the next object at the same location as OBJ. + * (OBJ>NOBJECTS indicates that game.fixed(OBJ-NOBJECTS)=LOC; game.link(OBJ) is * still the correct link to use.) game.abbrev is zeroed; it controls * whether the abbreviated description is printed. Counts modulo 5 * unless "LOOK" is used. */ diff --git a/funcs.h b/funcs.h index 3aa7c90..6630396 100644 --- a/funcs.h +++ b/funcs.h @@ -15,8 +15,8 @@ * PCT(N) = true N% of the time (N integer from 0 to 100) * TOTING(OBJ) = true if the OBJ is being carried */ -#define TOTING(OBJ) (PLACE[OBJ] == -1) -#define AT(OBJ) (PLACE[OBJ] == LOC || FIXED[OBJ] == LOC) +#define TOTING(OBJ) (game.place[OBJ] == -1) +#define AT(OBJ) (game.place[OBJ] == LOC || game.fixed[OBJ] == LOC) #define HERE(OBJ) (AT(OBJ) || TOTING(OBJ)) #define LIQ2(PBOTL) ((1-(PBOTL))*WATER+((PBOTL)/2)*(WATER+OIL)) #define LIQ(DUMMY) (LIQ2(PROP[BOTTLE]<0 ? -1-PROP[BOTTLE] : PROP[BOTTLE])) diff --git a/init.c b/init.c index e3b84fb..316655d 100644 --- a/init.c +++ b/init.c @@ -15,13 +15,13 @@ * 12600 words of message text (LINES, LINSIZ). * 885 travel options (TRAVEL, TRVSIZ). * 330 vocabulary words (KTAB, ATAB, TABSIZ). - * 185 locations (LTEXT, STEXT, KEY, COND, abbrev, ATLOC, LOCSND, LOCSIZ). - * 100 objects (PLAC, PLACE, FIXD, FIXED, LINK (TWICE), PTEXT, PROP, + * 185 locations (LTEXT, STEXT, KEY, COND, abbrev, game.atloc, LOCSND, LOCSIZ). + * 100 objects (PLAC, game.place, FIXD, game.fixed, game.link (TWICE), PTEXT, PROP, * OBJSND, OBJTXT). * 35 "action" verbs (ACTSPK, VRBSIZ). * 277 random messages (RTEXT, RTXSIZ). * 12 different player classifications (CTEXT, CVAL, CLSMAX). - * 20 hints (HINTLC, HINTED, HINTS, HNTSIZ). + * 20 hints (HINTLC, game.hinted, HINTS, HNTSIZ). * 5 "# of turns" threshholds (TTEXT, TRNVAL, TRNSIZ). * There are also limits which cannot be exceeded due to the structure of * the database. (E.G., The vocabulary uses n/1000 to determine word type, @@ -180,10 +180,10 @@ void initialise(void) { static int finish_init(void) { for (I=1; I<=100; I++) { - PLACE[I]=0; + game.place[I]=0; PROP[I]=0; - LINK[I]=0; - {long x = I+NOBJECTS; LINK[x]=0;} + game.link[I]=0; + {long x = I+NOBJECTS; game.link[x]=0;} } /* end loop */ /* 1102 */ for (I=1; I<=LOCSIZ; I++) { @@ -191,13 +191,13 @@ static int finish_init(void) { if(LTEXT[I] == 0 || KEY[I] == 0) goto L1102; K=KEY[I]; if(MOD(labs(TRAVEL[K]),1000) == 1)COND[I]=2; -L1102: ATLOC[I]=0; +L1102: game.atloc[I]=0; } /* end loop */ -/* Set up the ATLOC and LINK arrays as described above. We'll use the DROP +/* Set up the game.atloc and game.link arrays as described above. We'll use the DROP * subroutine, which prefaces new objects on the lists. Since we want things * in the other order, we'll run the loop backwards. If the object is in two - * locs, we drop it twice. This also sets up "PLACE" and "fixed" as copies of + * locs, we drop it twice. This also sets up "game.place" and "fixed" as copies of * "PLAC" and "FIXD". Also, since two-placed objects are typically best * described last, we'll drop them first. */ @@ -211,7 +211,7 @@ L1106: /*etc*/ ; for (I=1; I<=NOBJECTS; I++) { K=NOBJECTS + 1 - I; - FIXED[K]=FIXD[K]; + game.fixed[K]=FIXD[K]; if(PLAC[K] != 0 && FIXD[K] <= 0)DROP(K,PLAC[K]); } /* end loop */ @@ -227,11 +227,11 @@ L1106: /*etc*/ ; game.tally=game.tally-PROP[I]; } /* end loop */ -/* Clear the hint stuff. HINTLC(I) is how long he's been at LOC with cond bit - * I. HINTED(I) is true iff hint I has been used. */ +/* Clear the hint stuff. HINTLC[I] is how long he's been at LOC with cond bit + * I. game.hinted[I] is true iff hint I has been used. */ for (I=1; I<=HNTMAX; I++) { - HINTED[I]=false; + game.hinted[I]=false; HINTLC[I]=0; } /* end loop */ diff --git a/main.c b/main.c index 988fcc1..18beb85 100644 --- a/main.c +++ b/main.c @@ -14,16 +14,14 @@ struct game_t game; -long ATLOC[LOCSIZ+1], FIXED[NOBJECTS+1], - LINK[NOBJECTS*2 + 1], LNLENG, LNPOSN, - PARMS[26], PLACE[NOBJECTS+1]; +long LNLENG, LNPOSN, PARMS[26]; char rawbuf[LINESIZE], INLINE[LINESIZE+1], MAP1[129], MAP2[129]; long AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CLAM, COINS, DALTLC, DOOR, DPRSSN, DRAGON, DWARF, EGGS, EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOD, - GRATE, HINT, HINTED[21], HINTLC[21], + GRATE, HINT, HINTLC[21], I, INVENT, IGO, J, JADE, K, K2, KEYS, KK, KNIFE, KQ, L, LAMP, LL, LOC, LOCK, LOOK, MAGZIN, MAXDIE, MAXTRS, MESSAG, MIRROR, MXSCOR, @@ -251,7 +249,7 @@ L6016: TK[J]=game.odloc[I]; /* 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 + * the pirate be spotted. Note that game.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; @@ -262,19 +260,19 @@ L6016: TK[J]=game.odloc[I]; if(TOTING(J)) goto L6021; L6020: if(HERE(J))K=1; } /* end loop */ - if(game.tally == 1 && K == 0 && PLACE[CHEST] == 0 && HERE(LAMP) && PROP[LAMP] + if(game.tally == 1 && K == 0 && game.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; +L6021: if(game.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(AT(J) && game.fixed[J] == 0)CARRY(J,LOC); if(TOTING(J))DROP(J,game.chloc); L6023: /*etc*/ ; } /* end loop */ @@ -346,7 +344,7 @@ L2001: if(TOTING(BEAR))RSPEAK(141); if(DARK(0)) goto L2012; game.abbrev[LOC]=game.abbrev[LOC]+1; - I=ATLOC[LOC]; + I=game.atloc[LOC]; L2004: if(I == 0) goto L2012; OBJ=I; if(OBJ > NOBJECTS)OBJ=OBJ-NOBJECTS; @@ -368,9 +366,9 @@ L2004: if(I == 0) goto L2012; * 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; + if(OBJ == STEPS && LOC == game.fixed[STEPS])KK=1; PSPEAK(OBJ,KK); -L2008: I=LINK[I]; +L2008: I=game.link[I]; goto L2004; L2009: K=54; @@ -388,7 +386,7 @@ L2012: VERB=0; L2600: if(COND[LOC] < game.conds) goto L2603; /* 2602 */ for (HINT=1; HINT<=HNTMAX; HINT++) { - if(HINTED[HINT]) goto L2602; + if(game.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; @@ -607,7 +605,7 @@ L30310: game.newloc=PLAC[TROLL]+FIXD[TROLL]-LOC; PROP[CHASM]=1; PROP[TROLL]=2; DROP(BEAR,game.newloc); - FIXED[BEAR]= -1; + game.fixed[BEAR]= -1; PROP[BEAR]=3; game.oldlc2=game.newloc; goto L99; @@ -707,8 +705,8 @@ L99: if(game.closng) goto L95; game.numdie=game.numdie+1; if(!YES(cmdin,79+game.numdie*2,80+game.numdie*2,54)) score(0); if(game.numdie == MAXDIE) score(0); - PLACE[WATER]=0; - PLACE[OIL]=0; + game.place[WATER]=0; + game.place[OIL]=0; if(TOTING(LAMP))PROP[LAMP]=0; /* 98 */ for (J=1; J<=NOBJECTS; J++) { I=NOBJECTS + 1 - J; @@ -751,8 +749,8 @@ L40010: HINTLC[HINT]=0; if(!YES(cmdin,HINTS[HINT][3],0,54)) goto L2602; SETPRM(1,HINTS[HINT][2],HINTS[HINT][2]); RSPEAK(261); - HINTED[HINT]=YES(cmdin,175,HINTS[HINT][4],54); - if(HINTED[HINT] && game.limit > 30)game.limit=game.limit+30*HINTS[HINT][2]; + game.hinted[HINT]=YES(cmdin,175,HINTS[HINT][4],54); + if(game.hinted[HINT] && game.limit > 30)game.limit=game.limit+30*HINTS[HINT][2]; L40020: HINTLC[HINT]=0; L40030: goto L2602; @@ -761,13 +759,13 @@ L40030: goto L2602; L40100: if(PROP[GRATE] == 0 && !HERE(KEYS)) goto L40010; goto L40020; -L40200: if(PLACE[BIRD] == LOC && TOTING(ROD) && game.oldobj == BIRD) goto L40010; +L40200: if(game.place[BIRD] == LOC && TOTING(ROD) && game.oldobj == BIRD) goto L40010; goto L40030; L40300: if(HERE(SNAKE) && !HERE(BIRD)) goto L40010; goto L40020; -L40400: if(ATLOC[LOC] == 0 && ATLOC[game.oldloc] == 0 && ATLOC[game.oldlc2] == 0 && game.holdng > +L40400: if(game.atloc[LOC] == 0 && game.atloc[game.oldloc] == 0 && game.atloc[game.oldlc2] == 0 && game.holdng > 1) goto L40010; goto L40020; @@ -779,7 +777,7 @@ L40600: goto L40010; L40700: if(game.dflag == 0) goto L40010; goto L40020; -L40800: if(ATLOC[LOC] == 0 && ATLOC[game.oldloc] == 0 && ATLOC[game.oldlc2] == 0) goto +L40800: if(game.atloc[LOC] == 0 && game.atloc[game.oldloc] == 0 && game.atloc[game.oldlc2] == 0) goto L40010; goto L40030; @@ -840,9 +838,9 @@ L10000: PROP[GRATE]=0; JUGGLE(CHASM); if(PROP[BEAR] != 3)DSTROY(BEAR); PROP[CHAIN]=0; - FIXED[CHAIN]=0; + game.fixed[CHAIN]=0; PROP[AXE]=0; - FIXED[AXE]=0; + game.fixed[AXE]=0; RSPEAK(129); game.clock1= -1; game.closng=true; @@ -883,7 +881,7 @@ L11000: PROP[BOTTLE]=PUT(BOTTLE,115,1); PROP[PILLOW]=PUT(PILLOW,116,0); PROP[MIRROR]=PUT(MIRROR,115,0); - FIXED[MIRROR]=116; + game.fixed[MIRROR]=116; for (I=1; I<=NOBJECTS; I++) { if(TOTING(I)) @@ -910,7 +908,7 @@ L12000: RSPEAK(188); L12200: if(game.lmwarn || !HERE(LAMP)) goto L19999; game.lmwarn=true; SPK=187; - if(PLACE[BATTER] == 0)SPK=183; + if(game.place[BATTER] == 0)SPK=183; if(PROP[BATTER] == 1)SPK=189; RSPEAK(SPK); goto L19999; diff --git a/misc.c b/misc.c index f211eac..eb3d060 100644 --- a/misc.c +++ b/misc.c @@ -509,8 +509,8 @@ long I, J; /* Juggle an object by picking it up and putting it down again, the purpose * being to get the object to the front of the chain of things at its loc. */ - I=PLACE[OBJECT]; - J=FIXED[OBJECT]; + I=game.place[OBJECT]; + J=game.fixed[OBJECT]; MOVE(OBJECT,I); MOVE(OBJECT+NOBJECTS,J); return; @@ -521,13 +521,13 @@ long FROM; /* Place any object anywhere by picking it up and dropping it. May already be * toting, in which case the carry is a no-op. Mustn't pick up objects which - * are not at any loc, since carry wants to remove objects from ATLOC chains. */ + * are not at any loc, since carry wants to remove objects from game.atloc chains. */ if(OBJECT > NOBJECTS) goto L1; - FROM=PLACE[OBJECT]; + FROM=game.place[OBJECT]; goto L2; -L1: {long x = OBJECT-NOBJECTS; FROM=FIXED[x];} +L1: {long x = OBJECT-NOBJECTS; FROM=game.fixed[x];} L2: if(FROM > 0 && FROM <= 300)CARRY(OBJECT,FROM); DROP(OBJECT,WHERE); return; @@ -549,35 +549,35 @@ long TEMP; /* Start toting an object, removing it from the list of things at its former * location. Incr holdng unless it was already being toted. If OBJECT>NOBJECTS - * (moving "fixed" second loc), don't change PLACE or game.holdng. */ + * (moving "fixed" second loc), don't change game.place or game.holdng. */ if(OBJECT > NOBJECTS) goto L5; - if(PLACE[OBJECT] == -1)return; - PLACE[OBJECT]= -1; + if(game.place[OBJECT] == -1)return; + game.place[OBJECT]= -1; game.holdng=game.holdng+1; -L5: if(ATLOC[WHERE] != OBJECT) goto L6; - ATLOC[WHERE]=LINK[OBJECT]; +L5: if(game.atloc[WHERE] != OBJECT) goto L6; + game.atloc[WHERE]=game.link[OBJECT]; return; -L6: TEMP=ATLOC[WHERE]; -L7: if(LINK[TEMP] == OBJECT) goto L8; - TEMP=LINK[TEMP]; +L6: TEMP=game.atloc[WHERE]; +L7: if(game.link[TEMP] == OBJECT) goto L8; + TEMP=game.link[TEMP]; goto L7; -L8: LINK[TEMP]=LINK[OBJECT]; +L8: game.link[TEMP]=game.link[OBJECT]; return; } void DROP(long OBJECT, long WHERE) { -/* Place an object at a given loc, prefixing it onto the ATLOC list. Decr +/* Place an object at a given loc, prefixing it onto the game.atloc list. Decr * game.holdng if the object was being toted. */ if(OBJECT > NOBJECTS) goto L1; - if(PLACE[OBJECT] == -1)game.holdng=game.holdng-1; - PLACE[OBJECT]=WHERE; + if(game.place[OBJECT] == -1)game.holdng=game.holdng-1; + game.place[OBJECT]=WHERE; goto L2; -L1: {long x = OBJECT-NOBJECTS; FIXED[x]=WHERE;} +L1: {long x = OBJECT-NOBJECTS; game.fixed[x]=WHERE;} L2: if(WHERE <= 0)return; - LINK[OBJECT]=ATLOC[WHERE]; - ATLOC[WHERE]=OBJECT; + game.link[OBJECT]=game.atloc[WHERE]; + game.atloc[WHERE]=OBJECT; return; } diff --git a/score.c b/score.c index c8428d7..2d89757 100644 --- a/score.c +++ b/score.c @@ -40,7 +40,7 @@ void score(long MODE) { if(I == CHEST)K=14; if(I > CHEST)K=16; if(PROP[I] >= 0)SCORE=SCORE+2; - if(PLACE[I] == 3 && PROP[I] == 0)SCORE=SCORE+K-2; + if(game.place[I] == 3 && PROP[I] == 0)SCORE=SCORE+K-2; MXSCOR=MXSCOR+K; L20010: /*etc*/ ; } /* end loop */ @@ -69,7 +69,7 @@ L20020: MXSCOR=MXSCOR+45; /* Did he come to Witt's End as he should? */ - if(PLACE[MAGZIN] == 108)SCORE=SCORE+1; + if(game.place[MAGZIN] == 108)SCORE=SCORE+1; MXSCOR=MXSCOR+1; /* Round it off. */ @@ -80,7 +80,7 @@ L20020: MXSCOR=MXSCOR+45; /* Deduct for hints/turns/saves. Hints < 4 are special; see database desc. */ for (I=1; I<=HNTMAX; I++) { - if(HINTED[I])SCORE=SCORE-HINTS[I][2]; + if(game.hinted[I])SCORE=SCORE-HINTS[I][2]; } /* end loop */ if(game.novice)SCORE=SCORE-5; if(game.clshnt)SCORE=SCORE-10; diff --git a/sizes.h b/sizes.h index e59fa86..66fb404 100644 --- a/sizes.h +++ b/sizes.h @@ -2,3 +2,4 @@ #define LOCSIZ 185 #define NOBJECTS 100 +#define HNTSIZ 20 -- 2.31.1