More more globals into the game state block.
[open-adventure.git] / main.c
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,
-               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,
-                TURNS, URN, V1, V2, VASE, VEND, VERB,
+               TURNS, URN, V1, V2, VASE, VEND, VERB,
                VOLCAN, VRSION = 25, WATER, WD1, WD1X, WD2, WD2X,
-               WZDARK = false, ZZWORD;
+               WZDARK = false;
 FILE  *logfp;
 bool oldstyle = false;
 lcg_state lcgstate;
@@ -133,7 +133,7 @@ int main(int argc, char *argv[]) {
 
 L1:    SETUP= -1;
        I=0;
-       ZZWORD=RNDVOC(3,0);
+       game.zzword=RNDVOC(3,0);
        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
-       ZZWORD=RNDVOC(3,0);
+       game.zzword=RNDVOC(3,0);
        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;
-       OLDLC2=LOC;
+       game.oldlc2=LOC;
         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
- *  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
- *  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;
@@ -532,8 +532,8 @@ L8: KK=KEY[LOC];
        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;
@@ -616,18 +616,18 @@ L30310: NEWLOC=PLAC[TROLL]+FIXD[TROLL]-LOC;
        DROP(BEAR,NEWLOC);
        FIXED[BEAR]= -1;
        PROP[BEAR]=3;
-       OLDLC2=NEWLOC;
+       game.oldlc2=NEWLOC;
         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;
@@ -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
- *  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
@@ -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!).
- *  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);
-       OLDLC2=LOC;
+       game.oldlc2=LOC;
 
 /*  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;
-       K=OLDLC2;
+       K=game.oldlc2;
        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. */
@@ -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;
 
-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;
 
@@ -786,7 +786,7 @@ L40600:  goto L40010;
 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;
 
@@ -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;
-       OLDLOC=115;
+       game.oldloc=115;
        NEWLOC=115;
 
 /*  Leave the grate with normal (non-negative) property.  Reuse sign. */