More more globals into the game state block.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 7 Jun 2017 01:46:17 +0000 (21:46 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 7 Jun 2017 01:46:17 +0000 (21:46 -0400)
actions1.c
advent.h
main.c

index 6a751d7cf5f55efacdfae1d2b517dee8695f1dc0..d9fa2e5e90fe25d3a6bf77a0e6aab3b268bc4460 100644 (file)
@@ -536,9 +536,9 @@ L8305:      DATIME(&I,&K);
        SAVWDS(ABBNUM,BLKLIN,BONUS,CLOCK1,CLOCK2,CLOSED,CLOSNG);
        SAVWDS(DETAIL,DFLAG,DKILL,DTOTAL,FOOBAR,HOLDNG,IWEST);
        SAVWDS(KNFLOC,LIMIT,LL,LMWARN,LOC,NEWLOC,NUMDIE);
        SAVWDS(ABBNUM,BLKLIN,BONUS,CLOCK1,CLOCK2,CLOSED,CLOSNG);
        SAVWDS(DETAIL,DFLAG,DKILL,DTOTAL,FOOBAR,HOLDNG,IWEST);
        SAVWDS(KNFLOC,LIMIT,LL,LMWARN,LOC,NEWLOC,NUMDIE);
-       SAVWDS(OBJ,OLDLC2,OLDLOC,OLDOBJ,PANIC,SAVED,SETUP);
+       SAVWDS(OBJ,game.oldlc2,game.oldloc,OLDOBJ,PANIC,SAVED,SETUP);
        SAVWDS(SPK,TALLY,THRESH,TRNDEX,TRNLUZ,TURNS,OBJTXT[OYSTER]);
        SAVWDS(SPK,TALLY,THRESH,TRNDEX,TRNLUZ,TURNS,OBJTXT[OYSTER]);
-       SAVWDS(VERB,WD1,WD1X,WD2,WZDARK,ZZWORD,OBJSND[BIRD]);
+       SAVWDS(VERB,WD1,WD1X,WD2,WZDARK,game.zzword,OBJSND[BIRD]);
        SAVWDS(OBJTXT[SIGN],CLSHNT,NOVICE,K,K,K,K);
        SAVARR(ABB,LOCSIZ);
        SAVARR(ATLOC,LOCSIZ);
        SAVWDS(OBJTXT[SIGN],CLSHNT,NOVICE,K,K,K,K);
        SAVARR(ABB,LOCSIZ);
        SAVARR(ATLOC,LOCSIZ);
@@ -554,7 +554,7 @@ L8305:      DATIME(&I,&K);
        SAVWRD(KK,K);
        if(K != 0) goto L8318;
        K=NUL;
        SAVWRD(KK,K);
        if(K != 0) goto L8318;
        K=NUL;
-       ZZWORD=RNDVOC(3,ZZWORD);
+       game.zzword=RNDVOC(3,game.zzword);
        if(KK > 0) return(8);
        RSPEAK(266);
        exit(0);
        if(KK > 0) return(8);
        RSPEAK(266);
        exit(0);
@@ -585,8 +585,8 @@ L8320:      if(PROP[RUG] != 2)SPK=224;
 L9320: if(OBJ != RUG) return(2011);
        SPK=223;
        if(PROP[RUG] != 2) return(2011);
 L9320: if(OBJ != RUG) return(2011);
        SPK=223;
        if(PROP[RUG] != 2) return(2011);
-       OLDLC2=OLDLOC;
-       OLDLOC=LOC;
+       game.oldlc2=game.oldloc;
+       game.oldloc=LOC;
        NEWLOC=PLACE[RUG]+FIXED[RUG]-LOC;
        SPK=226;
        if(PROP[SAPPH] >= 0)SPK=227;
        NEWLOC=PLACE[RUG]+FIXED[RUG]-LOC;
        SPK=226;
        if(PROP[SAPPH] >= 0)SPK=227;
@@ -601,7 +601,7 @@ L8330:      SPK=228;
        RSPEAK(labs(K));
        if(K < 0) return(2012);
        SPK=0;
        RSPEAK(labs(K));
        if(K < 0) return(2012);
        SPK=0;
-L8332: SETPRM(1,ZZWORD,0);
+L8332: SETPRM(1,game.zzword,0);
        /* 8335 */ for (I=1; I<=NOBJECTS; I++) {
        if(!HERE(I) || OBJSND[I] == 0 || PROP[I] < 0) goto L8335;
        PSPEAK(I,OBJSND[I]+PROP[I]);
        /* 8335 */ for (I=1; I<=NOBJECTS; I++) {
        if(!HERE(I) || OBJSND[I] == 0 || PROP[I] < 0) goto L8335;
        PSPEAK(I,OBJSND[I]+PROP[I]);
@@ -617,7 +617,7 @@ L8340:      if(!AT(RESER) && LOC != FIXED[RESER]-1) return(2011);
        PSPEAK(RESER,PROP[RESER]+1);
        PROP[RESER]=1-PROP[RESER];
        if(AT(RESER)) return(2012);
        PSPEAK(RESER,PROP[RESER]+1);
        PROP[RESER]=1-PROP[RESER];
        if(AT(RESER)) return(2012);
-       OLDLC2=LOC;
+       game.oldlc2=LOC;
        NEWLOC=0;
        RSPEAK(241);
         return(2);
        NEWLOC=0;
        RSPEAK(241);
         return(2);
index 3dff47b05a3a08cfee33bd3e3ffd1cd65bd26f8d..3e5dc9a39e918f9dd653dd5aab4104157ec9b774 100644 (file)
--- a/advent.h
+++ b/advent.h
@@ -14,6 +14,9 @@ typedef long token_t; /* word token - someday this will be a character array */
 typedef long vocab_t;  /* index into a vocabulary array */
 
 struct game_t {
 typedef long vocab_t;  /* index into a vocabulary array */
 
 struct game_t {
+    long oldloc;
+    long oldlc2;
+    long zzword;
     long dseen[NDWARVES+1];
     long dloc[NDWARVES+1];
     long odloc[NDWARVES+1];
     long dseen[NDWARVES+1];
     long dloc[NDWARVES+1];
     long odloc[NDWARVES+1];
@@ -90,7 +93,7 @@ extern long ABBNUM, AMBER, ATTACK, AXE, BACK, BATTER, BEAR,
    BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2,
    CLAM, CLOCK1, CLOCK2, CLOSED, CLOSNG, CLSHNT,
    COINS, CONDS, DALTLC, DETAIL,
    BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2,
    CLAM, CLOCK1, CLOCK2, CLOSED, CLOSNG, CLSHNT,
    COINS, CONDS, DALTLC, DETAIL,
-    DKILL, DOOR, DPRSSN, DRAGON, DTOTAL, DWARF, EGGS,
+   DKILL, DOOR, DPRSSN, DRAGON, DTOTAL, DWARF, EGGS,
    EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOBAR, FOOD,
    GRATE, HINT, HINTED[], HINTLC[],
    I, INVENT, IGO, IWEST, J, JADE, K, K2, KEYS, KK,
    EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOBAR, FOOD,
    GRATE, HINT, HINTED[], HINTLC[],
    I, INVENT, IGO, IWEST, J, JADE, K, K2, KEYS, KK,
@@ -98,7 +101,7 @@ extern long ABBNUM, AMBER, ATTACK, AXE, BACK, BATTER, BEAR,
    LMWARN, LOC, LOCK, LOOK,
    MAGZIN, MAXDIE, MAXTRS, MESSAG, MIRROR, MXSCOR,
    NEWLOC, NOVICE, NUGGET, NUL, NUMDIE, OBJ,
    LMWARN, LOC, LOCK, LOOK,
    MAGZIN, MAXDIE, MAXTRS, MESSAG, MIRROR, MXSCOR,
    NEWLOC, NOVICE, NUGGET, NUL, NUMDIE, OBJ,
-   OGRE, OIL, OLDLC2, OLDLOC, OLDOBJ, OYSTER,
+   OGRE, OIL, OLDOBJ, OYSTER,
    PANIC, PEARL, PILLOW, PLANT, PLANT2, PROP[], PYRAM,
    RESER, ROD, ROD2, RUBY, RUG, SAPPH, SAVED, SAY,
    SCORE, SECT, SETUP, SIGN, SNAKE, SPK, STEPS, STICK,
    PANIC, PEARL, PILLOW, PLANT, PLANT2, PROP[], PYRAM,
    RESER, ROD, ROD2, RUBY, RUG, SAPPH, SAVED, SAY,
    SCORE, SECT, SETUP, SIGN, SNAKE, SPK, STEPS, STICK,
@@ -106,5 +109,5 @@ extern long ABBNUM, AMBER, ATTACK, AXE, BACK, BATTER, BEAR,
    TRNDEX, TRNLUZ, TROLL, TROLL2,
    TURNS, URN, V1, V2, VASE, VEND, VERB,
    VOLCAN, VRSION, WATER, WD1, WD1X, WD2, WD2X,
    TRNDEX, TRNLUZ, TROLL, TROLL2,
    TURNS, URN, V1, V2, VASE, VEND, VERB,
    VOLCAN, VRSION, WATER, WD1, WD1X, WD2, WD2X,
-   WZDARK, ZZWORD;
+   WZDARK;
 
 
diff --git a/main.c b/main.c
index 75982c651cab10000f7e3b868dd3eab0c512239b..c5b4523aa7bd630714174a04603306ae8cb90f99 100644 (file)
--- a/main.c
+++ b/main.c
@@ -34,15 +34,15 @@ long ABBNUM, AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BONUS,
                MAGZIN, MAXDIE, MAXTRS,
                MESSAG, MIRROR, MXSCOR,
                NEWLOC, NOVICE, NUGGET, NUL, NUMDIE, OBJ,
                MAGZIN, MAXDIE, MAXTRS,
                MESSAG, MIRROR, MXSCOR,
                NEWLOC, NOVICE, NUGGET, NUL, NUMDIE, OBJ,
-               OGRE, OIL, OLDLC2, OLDLOC, OLDOBJ, OYSTER,
+               OGRE, OIL, OLDOBJ, OYSTER,
                PANIC, PEARL, PILLOW, PLANT, PLANT2, PROP[NOBJECTS+1], PYRAM,
                RESER, ROD, ROD2, RUBY, RUG, SAPPH, SAVED, SAY,
                SCORE, SECT, SIGN, SNAKE, SPK, STEPS, STICK,
                STREAM, TALLY, THRESH, THROW, TK[21], TRIDNT,
                TRNDEX, TRNLUZ, TROLL, TROLL2,
                PANIC, PEARL, PILLOW, PLANT, PLANT2, PROP[NOBJECTS+1], PYRAM,
                RESER, ROD, ROD2, RUBY, RUG, SAPPH, SAVED, SAY,
                SCORE, SECT, SIGN, SNAKE, SPK, STEPS, STICK,
                STREAM, TALLY, THRESH, THROW, TK[21], TRIDNT,
                TRNDEX, TRNLUZ, TROLL, TROLL2,
-                TURNS, URN, V1, V2, VASE, VEND, VERB,
+               TURNS, URN, V1, V2, VASE, VEND, VERB,
                VOLCAN, VRSION = 25, WATER, WD1, WD1X, WD2, WD2X,
                VOLCAN, VRSION = 25, WATER, WD1, WD1X, WD2, WD2X,
-               WZDARK = false, ZZWORD;
+               WZDARK = false;
 FILE  *logfp;
 bool oldstyle = false;
 lcg_state lcgstate;
 FILE  *logfp;
 bool oldstyle = false;
 lcg_state lcgstate;
@@ -133,7 +133,7 @@ int main(int argc, char *argv[]) {
 
 L1:    SETUP= -1;
        I=0;
 
 L1:    SETUP= -1;
        I=0;
-       ZZWORD=RNDVOC(3,0);
+       game.zzword=RNDVOC(3,0);
        NOVICE=YES(stdin, 65,1,0);
        NEWLOC=1;
        LOC=1;
        NOVICE=YES(stdin, 65,1,0);
        NEWLOC=1;
        LOC=1;
@@ -160,7 +160,7 @@ static bool fallback_handler(char *buf)
        // autogenerated, so don't charge user time for it.
        --TURNS;
        // here we reconfigure any global game state that uses random numbers
        // autogenerated, so don't charge user time for it.
        --TURNS;
        // here we reconfigure any global game state that uses random numbers
-       ZZWORD=RNDVOC(3,0);
+       game.zzword=RNDVOC(3,0);
        return true;
     }
     return false;
        return true;
     }
     return false;
@@ -323,7 +323,7 @@ L6030:      /*etc*/ ;
        SETPRM(1,STICK,0);
        RSPEAK(K+1+2/(1+STICK));
        if(STICK == 0) goto L2000;
        SETPRM(1,STICK,0);
        RSPEAK(K+1+2/(1+STICK));
        if(STICK == 0) goto L2000;
-       OLDLC2=LOC;
+       game.oldlc2=LOC;
         goto L99;
 
 
         goto L99;
 
 
@@ -521,9 +521,9 @@ L8000:      SETPRM(1,WD1,WD1X);
  *
  *  Given the current location in "LOC", and a motion verb number in "K", put
  *  the new location in "NEWLOC".  The current loc is saved in "OLgame.dloc" in case
  *
  *  Given the current location in "LOC", and a motion verb number in "K", put
  *  the new location in "NEWLOC".  The current loc is saved in "OLgame.dloc" in case
- *  he wants to retreat.  The current OLgame.dloc is saved in OLDLC2, in case he
+ *  he wants to retreat.  The current OLgame.dloc is saved in game.oldlc2, in case he
  *  dies.  (if he does, NEWLOC will be limbo, and OLgame.dloc will be what killed
  *  dies.  (if he does, NEWLOC will be limbo, and OLgame.dloc will be what killed
- *  him, so we need OLDLC2, which is the last place he was safe.) */
+ *  him, so we need game.oldlc2, which is the last place he was safe.) */
 
 L8:    KK=KEY[LOC];
        NEWLOC=LOC;
 
 L8:    KK=KEY[LOC];
        NEWLOC=LOC;
@@ -532,8 +532,8 @@ L8: KK=KEY[LOC];
        if(K == BACK) goto L20;
        if(K == LOOK) goto L30;
        if(K == CAVE) goto L40;
        if(K == BACK) goto L20;
        if(K == LOOK) goto L30;
        if(K == CAVE) goto L40;
-       OLDLC2=OLDLOC;
-       OLDLOC=LOC;
+       game.oldlc2=game.oldloc;
+       game.oldloc=LOC;
 
 L9:    LL=labs(TRAVEL[KK]);
        if(MOD(LL,1000) == 1 || MOD(LL,1000) == K) goto L10;
 
 L9:    LL=labs(TRAVEL[KK]);
        if(MOD(LL,1000) == 1 || MOD(LL,1000) == K) goto L10;
@@ -616,18 +616,18 @@ L30310: NEWLOC=PLAC[TROLL]+FIXD[TROLL]-LOC;
        DROP(BEAR,NEWLOC);
        FIXED[BEAR]= -1;
        PROP[BEAR]=3;
        DROP(BEAR,NEWLOC);
        FIXED[BEAR]= -1;
        PROP[BEAR]=3;
-       OLDLC2=NEWLOC;
+       game.oldlc2=NEWLOC;
         goto L99;
 
 /*  End of specials. */
 
         goto L99;
 
 /*  End of specials. */
 
-/*  Handle "go back".  Look for verb which goes from LOC to OLDLOC, or to OLDLC2
- *  If OLDLOC has forced-motion.  K2 saves entry -> forced loc -> previous loc. */
+/*  Handle "go back".  Look for verb which goes from LOC to game.oldloc, or to game.oldlc2
+ *  If game.oldloc has forced-motion.  K2 saves entry -> forced loc -> previous loc. */
 
 
-L20:   K=OLDLOC;
-       if(FORCED(K))K=OLDLC2;
-       OLDLC2=OLDLOC;
-       OLDLOC=LOC;
+L20:   K=game.oldloc;
+       if(FORCED(K))K=game.oldlc2;
+       game.oldlc2=game.oldloc;
+       game.oldloc=LOC;
        K2=0;
        if(K == LOC)K2=91;
        if(CNDBIT(LOC,4))K2=274;
        K2=0;
        if(K == LOC)K2=91;
        if(CNDBIT(LOC,4))K2=274;
@@ -693,7 +693,7 @@ L50:        SPK=12;
  *  snide messages available.  Each death results in a message (81, 83, etc.)
  *  which offers reincarnation; if accepted, this results in message 82, 84,
  *  etc.  The last time, if he wants another chance, he gets a snide remark as
  *  snide messages available.  Each death results in a message (81, 83, etc.)
  *  which offers reincarnation; if accepted, this results in message 82, 84,
  *  etc.  The last time, if he wants another chance, he gets a snide remark as
- *  we exit.  When reincarnated, all objects being carried get dropped at OLDLC2
+ *  we exit.  When reincarnated, all objects being carried get dropped at game.oldlc2
  *  (presumably the last place prior to being killed) without change of props.
  *  the loop runs backwards to assure that the bird is dropped before the cage.
  *  (this kluge could be changed once we're sure all references to bird and cage
  *  (presumably the last place prior to being killed) without change of props.
  *  the loop runs backwards to assure that the bird is dropped before the cage.
  *  (this kluge could be changed once we're sure all references to bird and cage
@@ -701,12 +701,12 @@ L50:      SPK=12;
  *  it in the cave).  It is turned off and left outside the building (only if he
  *  was carrying it, of course).  He himself is left inside the building (and
  *  heaven help him if he tries to xyzzy back into the cave without the lamp!).
  *  it in the cave).  It is turned off and left outside the building (only if he
  *  was carrying it, of course).  He himself is left inside the building (and
  *  heaven help him if he tries to xyzzy back into the cave without the lamp!).
- *  OLDLOC is zapped so he can't just "retreat". */
+ *  game.oldloc is zapped so he can't just "retreat". */
 
 /*  The easiest way to get killed is to fall into a pit in pitch darkness. */
 
 L90:   RSPEAK(23);
 
 /*  The easiest way to get killed is to fall into a pit in pitch darkness. */
 
 L90:   RSPEAK(23);
-       OLDLC2=LOC;
+       game.oldlc2=LOC;
 
 /*  Okay, he's dead.  Let's get on with it. */
 
 
 /*  Okay, he's dead.  Let's get on with it. */
 
@@ -720,13 +720,13 @@ L99:      if(CLOSNG) goto L95;
        /* 98 */ for (J=1; J<=NOBJECTS; J++) {
        I=NOBJECTS + 1 - J;
        if(!TOTING(I)) goto L98;
        /* 98 */ for (J=1; J<=NOBJECTS; J++) {
        I=NOBJECTS + 1 - J;
        if(!TOTING(I)) goto L98;
-       K=OLDLC2;
+       K=game.oldlc2;
        if(I == LAMP)K=1;
        DROP(I,K);
 L98:   /*etc*/ ;
        } /* end loop */
        LOC=3;
        if(I == LAMP)K=1;
        DROP(I,K);
 L98:   /*etc*/ ;
        } /* end loop */
        LOC=3;
-       OLDLOC=LOC;
+       game.oldloc=LOC;
         goto L2000;
 
 /*  He died during closing time.  No resurrection.  Tally up a death and exit. */
         goto L2000;
 
 /*  He died during closing time.  No resurrection.  Tally up a death and exit. */
@@ -774,7 +774,7 @@ L40200: if(PLACE[BIRD] == LOC && TOTING(ROD) && OLDOBJ == BIRD) goto L40010;
 L40300: if(HERE(SNAKE) && !HERE(BIRD)) goto L40010;
         goto L40020;
 
 L40300: if(HERE(SNAKE) && !HERE(BIRD)) goto L40010;
         goto L40020;
 
-L40400: if(ATLOC[LOC] == 0 && ATLOC[OLDLOC] == 0 && ATLOC[OLDLC2] == 0 && HOLDNG >
+L40400: if(ATLOC[LOC] == 0 && ATLOC[game.oldloc] == 0 && ATLOC[game.oldlc2] == 0 && HOLDNG >
                1) goto L40010;
         goto L40020;
 
                1) goto L40010;
         goto L40020;
 
@@ -786,7 +786,7 @@ L40600:  goto L40010;
 L40700: if(DFLAG == 0) goto L40010;
         goto L40020;
 
 L40700: if(DFLAG == 0) goto L40010;
         goto L40020;
 
-L40800: if(ATLOC[LOC] == 0 && ATLOC[OLDLOC] == 0 && ATLOC[OLDLC2] == 0) goto
+L40800: if(ATLOC[LOC] == 0 && ATLOC[game.oldloc] == 0 && ATLOC[game.oldlc2] == 0) goto
                L40010;
         goto L40030;
 
                L40010;
         goto L40030;
 
@@ -875,7 +875,7 @@ L11000: PROP[BOTTLE]=PUT(BOTTLE,115,1);
        PROP[ROD]=PUT(ROD,115,0);
        PROP[DWARF]=PUT(DWARF,115,0);
        LOC=115;
        PROP[ROD]=PUT(ROD,115,0);
        PROP[DWARF]=PUT(DWARF,115,0);
        LOC=115;
-       OLDLOC=115;
+       game.oldloc=115;
        NEWLOC=115;
 
 /*  Leave the grate with normal (non-negative) property.  Reuse sign. */
        NEWLOC=115;
 
 /*  Leave the grate with normal (non-negative) property.  Reuse sign. */