Capture clock variables into the game-state block.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 7 Jun 2017 04:15:31 +0000 (00:15 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 7 Jun 2017 04:15:31 +0000 (00:15 -0400)
actions1.c
advent.h
funcs.h
init.c
main.c

index d9fa2e5e90fe25d3a6bf77a0e6aab3b268bc4460..d12052fa42a9949ea13d701482e2bd48c25c9ca9 100644 (file)
@@ -201,7 +201,7 @@ L9040:      if(OBJ == CLAM || OBJ == OYSTER) goto L9046;
        if(OBJ == CHAIN) goto L9048;
        if(!CLOSNG) goto L9043;
        K=130;
        if(OBJ == CHAIN) goto L9048;
        if(!CLOSNG) goto L9043;
        K=130;
-       if(!PANIC)CLOCK2=15;
+       if(!PANIC)game.clock2=15;
        PANIC=true;
         return(2010);
 
        PANIC=true;
         return(2010);
 
@@ -533,7 +533,7 @@ L8305:      DATIME(&I,&K);
  *  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. */
  *  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,CLOCK1,CLOCK2,CLOSED,CLOSNG);
+       SAVWDS(ABBNUM,BLKLIN,BONUS,game.clock1,game.clock2,CLOSED,CLOSNG);
        SAVWDS(DETAIL,DFLAG,DKILL,DTOTAL,FOOBAR,HOLDNG,IWEST);
        SAVWDS(KNFLOC,LIMIT,LL,LMWARN,LOC,NEWLOC,NUMDIE);
        SAVWDS(OBJ,game.oldlc2,game.oldloc,OLDOBJ,PANIC,SAVED,SETUP);
        SAVWDS(DETAIL,DFLAG,DKILL,DTOTAL,FOOBAR,HOLDNG,IWEST);
        SAVWDS(KNFLOC,LIMIT,LL,LMWARN,LOC,NEWLOC,NUMDIE);
        SAVWDS(OBJ,game.oldlc2,game.oldloc,OLDOBJ,PANIC,SAVED,SETUP);
index 47548b6baa112e046b3c9735da3397ec17a9fb59..0f82f372df016d8333a9dc6e62d7cd284347aa4e 100644 (file)
--- a/advent.h
+++ b/advent.h
@@ -14,6 +14,8 @@ typedef long token_t; /* word token - someday this will be char[TOKLEN+1] */
 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 clock1;
+    long clock2;
     long oldloc;
     long oldlc2;
     long zzword;
     long oldloc;
     long oldlc2;
     long zzword;
@@ -91,7 +93,7 @@ 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,
 extern long ABBNUM, AMBER, ATTACK, AXE, BACK, BATTER, BEAR,
    BIRD, BLOOD, BONUS,
    BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2,
-   CLAM, CLOCK1, CLOCK2, CLOSED, CLOSNG, CLSHNT,
+   CLAM, CLOSED, CLOSNG, CLSHNT,
    COINS, CONDS, DALTLC, DETAIL,
    DKILL, DOOR, DPRSSN, DRAGON, DTOTAL, DWARF, EGGS,
    EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOBAR, FOOD,
    COINS, CONDS, DALTLC, DETAIL,
    DKILL, DOOR, DPRSSN, DRAGON, DTOTAL, DWARF, EGGS,
    EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOBAR, FOOD,
diff --git a/funcs.h b/funcs.h
index 34f69cdfc261d6c2502b890abca3539c9a20e0fc..3aa7c90662c94d3ed37d09eea50bcc7e737eaa2f 100644 (file)
--- a/funcs.h
+++ b/funcs.h
@@ -29,7 +29,7 @@
 #define FOREST(LOC)    ((LOC) >= 145 && (LOC) <= 166)
 #define VOCWRD(LETTRS,SECT)    (VOCAB(MAKEWD(LETTRS),SECT))
 
 #define FOREST(LOC)    ((LOC) >= 145 && (LOC) <= 166)
 #define VOCWRD(LETTRS,SECT)    (VOCAB(MAKEWD(LETTRS),SECT))
 
-/*  The following two functions were added to fix a bug (CLOCK1 decremented
+/*  The following two functions were added to fix a bug (game.clock1 decremented
  *  while in forest).  They should probably be replaced by using another
  *  "cond" bit.  For now, however, a quick fix...  OUTSID(LOC) is true if
  *  LOC is outside, INDEEP(LOC) is true if LOC is "deep" in the cave (hall
  *  while in forest).  They should probably be replaced by using another
  *  "cond" bit.  For now, however, a quick fix...  OUTSID(LOC) is true if
  *  LOC is outside, INDEEP(LOC) is true if LOC is "deep" in the cave (hall
diff --git a/init.c b/init.c
index 2a714649e50026f6e2dcf276692cc98af7ba5328..8b2b1b07dc2607a67515eaa233eafac56471af84 100644 (file)
--- a/init.c
+++ b/init.c
@@ -345,8 +345,8 @@ L1106:      /*etc*/ ;
 /*  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
 /*  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
- *     CLOCK1  Number of turns from finding last treasure till closing
- *     CLOCK2  Number of turns from first warning till blinding flash
+ *     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)
  *     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)
@@ -383,8 +383,8 @@ L1106:      /*etc*/ ;
        DKILL=0;
        FOOBAR=0;
        BONUS=0;
        DKILL=0;
        FOOBAR=0;
        BONUS=0;
-       CLOCK1=30;
-       CLOCK2=50;
+       game.clock1=30;
+       game.clock2=50;
        CONDS=SETBIT(11);
        SAVED=0;
        CLOSNG=false;
        CONDS=SETBIT(11);
        SAVED=0;
        CLOSNG=false;
diff --git a/main.c b/main.c
index c5b4523aa7bd630714174a04603306ae8cb90f99..951c90f068bd6192a1f14812103d4f74b93b2674 100644 (file)
--- a/main.c
+++ b/main.c
@@ -22,9 +22,8 @@ long ABB[186], ATLOC[186], BLKLIN = true, DFLAG,
 char rawbuf[LINESIZE], INLINE[LINESIZE+1], MAP1[129], MAP2[129];
 
 long ABBNUM, AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BONUS,
 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, CLOCK1, CLOCK2, CLOSED, CLOSNG, CLSHNT,
-               COINS, CONDS, DALTLC, DETAIL,
+               BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2,
+               CLAM, CLOSED, CLOSNG, CLSHNT, COINS, CONDS, DALTLC, DETAIL,
                DKILL, DOOR, DPRSSN, DRAGON, DTOTAL, DWARF, EGGS,
                EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOBAR, FOOD,
                GRATE, HINT, HINTED[21], HINTLC[21],
                DKILL, DOOR, DPRSSN, DRAGON, DTOTAL, DWARF, EGGS,
                EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOBAR, FOOD,
                GRATE, HINT, HINTED[21], HINTLC[21],
@@ -173,7 +172,7 @@ static bool do_command(FILE *cmdin) {
        if(!OUTSID(NEWLOC) || NEWLOC == 0 || !CLOSNG) goto L71;
        RSPEAK(130);
        NEWLOC=LOC;
        if(!OUTSID(NEWLOC) || NEWLOC == 0 || !CLOSNG) goto L71;
        RSPEAK(130);
        NEWLOC=LOC;
-       if(!PANIC)CLOCK2=15;
+       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,
        PANIC=true;
 
 /*  See if a dwarf has seen him and has come from where he wants to go.  If so,
@@ -407,7 +406,7 @@ L2602:      /*etc*/ ;
 /*  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
 /*  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 CLOCK1 unless well into cave (and not at Y2). */
+ *  tick game.clock1 unless well into cave (and not at Y2). */
 
 L2603: if(!CLOSED) goto L2605;
        if(PROP[OYSTER] < 0 && TOTING(OYSTER))PSPEAK(OYSTER,1);
 
 L2603: if(!CLOSED) goto L2605;
        if(PROP[OYSTER] < 0 && TOTING(OYSTER))PSPEAK(OYSTER,1);
@@ -435,10 +434,10 @@ L2607:    FOOBAR=(FOOBAR>0 ? -FOOBAR : 0);
        }
        if(VERB == SAY && WD2 > 0)VERB=0;
        if(VERB == SAY) goto L4090;
        }
        if(VERB == SAY && WD2 > 0)VERB=0;
        if(VERB == SAY) goto L4090;
-       if(TALLY == 0 && INDEEP(LOC) && LOC != 33)CLOCK1=CLOCK1-1;
-       if(CLOCK1 == 0) goto L10000;
-       if(CLOCK1 < 0)CLOCK2=CLOCK2-1;
-       if(CLOCK2 == 0) goto L11000;
+       if(TALLY == 0 && INDEEP(LOC) && LOC != 33)game.clock1=game.clock1-1;
+       if(game.clock1 == 0) goto L10000;
+       if(game.clock1 < 0)game.clock2=game.clock2-1;
+       if(game.clock2 == 0) goto L11000;
        if(PROP[LAMP] == 1)LIMIT=LIMIT-1;
        if(LIMIT <= 30 && HERE(BATTER) && PROP[BATTER] == 0 && HERE(LAMP)) goto
                L12000;
        if(PROP[LAMP] == 1)LIMIT=LIMIT-1;
        if(LIMIT <= 30 && HERE(BATTER) && PROP[BATTER] == 0 && HERE(LAMP)) goto
                L12000;
@@ -519,11 +518,13 @@ L8000:    SETPRM(1,WD1,WD1X);
 
 /*  Figure out the new location
  *
 
 /*  Figure out the new location
  *
- *  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 game.oldlc2, in case he
- *  dies.  (if he does, NEWLOC will be limbo, and OLgame.dloc will be what killed
- *  him, so we need game.oldlc2, which is the last place he was safe.) */
+ *  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 "game.olddloc" in case he wants to retreat.  The current
+ *  game.oldloc 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 game.oldlc2, which is the last place he was
+ *  safe.) */
 
 L8:    KK=KEY[LOC];
        NEWLOC=LOC;
 
 L8:    KK=KEY[LOC];
        NEWLOC=LOC;
@@ -851,7 +852,7 @@ L10000: PROP[GRATE]=0;
        PROP[AXE]=0;
        FIXED[AXE]=0;
        RSPEAK(129);
        PROP[AXE]=0;
        FIXED[AXE]=0;
        RSPEAK(129);
-       CLOCK1= -1;
+       game.clock1= -1;
        CLOSNG=true;
         goto L19999;
 
        CLOSNG=true;
         goto L19999;