Eliminate globals.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 7 Jun 2017 18:03:33 +0000 (14:03 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 7 Jun 2017 18:03:33 +0000 (14:03 -0400)
actions1.c
advent.h
init.c
main.c
score.c

index 100ef83608950d9368bf7c8407e4f7a444014d33..f1de63b3bd9e014e20ca41e29f6c98c1fae19140 100644 (file)
@@ -437,10 +437,7 @@ L9230:     if(game.prop[ROD2] < 0 || !game.closed) return(2011);
 /*  Score.  Call scoring routine but tell it to return. */
 
 L8240: score(-1);
 /*  Score.  Call scoring routine but tell it to return. */
 
 L8240: score(-1);
-       SETPRM(1,SCORE,MXSCOR);
-       SETPRM(3,game.turns,game.turns);
-       RSPEAK(259);
-        return(2012);
+       return(2012);
 
 /*  FEE FIE FOE FOO (AND FUM).  Advance to next state if given in proper order.
  *  Look up WD1 in section 3 of vocab to determine which word we've got.  Last
 
 /*  FEE FIE FOE FOO (AND FUM).  Advance to next state if given in proper order.
  *  Look up WD1 in section 3 of vocab to determine which word we've got.  Last
index 33ed6cf9e9e0f71dbeb87d05f275eee578c8b57a..827c53f02edb296e944838256d6eb447d630280d 100644 (file)
--- a/advent.h
+++ b/advent.h
@@ -6,6 +6,9 @@
 #define LINESIZE       100
 #define NDWARVES       6
 #define PIRATE         NDWARVES        /* must be NDWARVES-1 when zero-origin */
 #define LINESIZE       100
 #define NDWARVES       6
 #define PIRATE         NDWARVES        /* must be NDWARVES-1 when zero-origin */
+#define DALTLC         18              /* alternate dwarf location; low room */
+#define MINTRS         50
+#define MAXTRS         79
 
 typedef struct lcg_state
 {
 
 typedef struct lcg_state
 {
@@ -129,18 +132,18 @@ extern long MOD(long,long);
 extern void set_seed(long);
 extern unsigned long get_next_lcg_value(void);
 extern long randrange(long);
 extern void set_seed(long);
 extern unsigned long get_next_lcg_value(void);
 extern long randrange(long);
-
 extern void score(long);
 extern void score(long);
+
+/* vocabulary items */ 
 extern long AMBER, ATTACK, AXE, BACK, BATTER, BEAR,
    BIRD, BLOOD, BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST,
 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, I, INVENT,
-   J, JADE, K, KEYS, KNIFE, L, LAMP, LOCK, LOOK,
-   MAGZIN, MAXDIE, MAXTRS, MESSAG, MIRROR, MXSCOR, NUGGET, NUL,
-   OGRE, OIL, OLDOBJ, OYSTER, PANIC, PEARL, PILLOW, PLANT, PLANT2, PYRAM,
-   RESER, ROD, ROD2, RUBY, RUG, SAPPH, SAY,
-   SCORE, SECT, SIGN, SNAKE, SPK, STEPS, STICK,
-   STREAM, THROW, TRIDNT, TROLL, TROLL2,
-   URN, V1, V2, VASE, VEND,
-   VOLCAN, VRSION, WATER, WD1, WD1X, WD2, WD2X;
+   CLAM, COINS, DOOR, DPRSSN, DRAGON, DWARF, EGGS,
+   EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOD, GRATE, HINT, INVENT,
+   JADE, KEYS, KNIFE, LAMP, LOCK, LOOK, MAGZIN, MESSAG, MIRROR, NUGGET, NUL,
+   OGRE, OIL, OYSTER, PANIC, PEARL, PILLOW, PLANT, PLANT2, PYRAM,
+   RESER, ROD, ROD2, RUBY, RUG, SAPPH, SAY, SCORE, SECT, SIGN, SNAKE,
+   STEPS, STICK, STREAM, THROW, TRIDNT, TROLL, TROLL2,
+   URN, VASE, VEND, VOLCAN, WATER;
+/* evrything else */
+extern long I, J, K, L, MAXDIE, SPK, V1, V2, VRSION, WD1, WD1X, WD2, WD2X;
 
 
diff --git a/init.c b/init.c
index 0e6ae1c0f32ff6f4554fd8c80a604b7a5fe1a474..3d967ef222bf769d89744881cea3726729cf70f4 100644 (file)
--- a/init.c
+++ b/init.c
@@ -215,14 +215,13 @@ L1106:    /*etc*/ ;
        if(PLAC[K] != 0 && FIXD[K] <= 0)DROP(K,PLAC[K]);
        } /* end loop */
 
        if(PLAC[K] != 0 && FIXD[K] <= 0)DROP(K,PLAC[K]);
        } /* end loop */
 
-/*  Treasures, as noted earlier, are objects 50 through MAXTRS (CURRENTLY 79).
+/*  Treasures, as noted earlier, are objects MINTRS through MAXTRS
  *  Their props are initially -1, and are set to 0 the first time they are
  *  described.  game.tally keeps track of how many are not yet found, so we know
  *  when to close the cave. */
 
  *  Their props are initially -1, and are set to 0 the first time they are
  *  described.  game.tally keeps track of how many are not yet found, so we know
  *  when to close the cave. */
 
-       MAXTRS=79;
        game.tally=0;
        game.tally=0;
-       for (I=50; I<=MAXTRS; I++) {
+       for (I=MINTRS; I<=MAXTRS; I++) {
        if(PTEXT[I] != 0)game.prop[I]= -1;
        game.tally=game.tally-game.prop[I];
        } /* end loop */
        if(PTEXT[I] != 0)game.prop[I]= -1;
        game.tally=game.tally-game.prop[I];
        } /* end loop */
@@ -341,7 +340,6 @@ L1106:      /*etc*/ ;
        game.dloc[4]=44;
        game.dloc[5]=64;
        game.dloc[6]=game.chloc;
        game.dloc[4]=44;
        game.dloc[5]=64;
        game.dloc[6]=game.chloc;
-       DALTLC=18;
 
 /*  Other random flags and counters, as follows:
  *     game.abbnum     How often we should print non-abbreviated descriptions
 
 /*  Other random flags and counters, as follows:
  *     game.abbnum     How often we should print non-abbreviated descriptions
diff --git a/main.c b/main.c
index 78577af2e876bf961e152476324c3ca5a5570e12..c6a1eef1e7537d82317435a3e5401feea464080e 100644 (file)
--- a/main.c
+++ b/main.c
@@ -19,11 +19,11 @@ 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,
 
 long AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD,
                BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST,
-               CLAM, COINS, DALTLC, DOOR, DPRSSN, DRAGON, DWARF, EGGS,
+               CLAM, COINS, DOOR, DPRSSN, DRAGON, DWARF, EGGS,
                EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOD,
                GRATE, HINT, I, INVENT, J, JADE, K, KEYS,
                EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOD,
                GRATE, HINT, I, INVENT, J, JADE, K, KEYS,
-               KNIFE, L, LAMP, LOCK, LOOK, MAGZIN, MAXDIE, MAXTRS,
-               MESSAG, MIRROR, MXSCOR, NUGGET, NUL, OGRE, OIL, OYSTER,
+               KNIFE, L, LAMP, LOCK, LOOK, MAGZIN, MAXDIE,
+               MESSAG, MIRROR, NUGGET, NUL, OGRE, OIL, OYSTER,
                PEARL, PILLOW, PLANT, PLANT2, PYRAM, RESER, ROD, ROD2,
                RUBY, RUG, SAPPH, SAY, SCORE, SECT, SIGN, SNAKE, SPK,
                STEPS, STICK, STREAM, THROW, TRIDNT, TROLL, TROLL2,
                PEARL, PILLOW, PLANT, PLANT2, PYRAM, RESER, ROD, ROD2,
                RUBY, RUG, SAPPH, SAY, SCORE, SECT, SIGN, SNAKE, SPK,
                STEPS, STICK, STREAM, THROW, TRIDNT, TROLL, TROLL2,
diff --git a/score.c b/score.c
index ef80e68df7c8a4c0c4b4ec16c33b409d996c2ec9..d0915b28887aedf3e832785daf86b7513fdb68bf 100644 (file)
--- a/score.c
+++ b/score.c
@@ -7,7 +7,8 @@
  */
 
 void score(long MODE) {
  */
 
 void score(long MODE) {
-       /* <0 if scoring, >0 if quitting, =0 if died or won */
+/* arg is <0 if scoring, >0 if quitting, =0 if died or won */
+       long MXSCOR = 0;
 
 /*  The present scoring algorithm is as follows:
  *     Objective:          Points:        Present total possible:
 
 /*  The present scoring algorithm is as follows:
  *     Objective:          Points:        Present total possible:
@@ -88,7 +89,12 @@ L20020: MXSCOR=MXSCOR+45;
 
 /*  Return to score command if that's where we came from. */
 
 
 /*  Return to score command if that's where we came from. */
 
-       if(MODE < 0) return;
+       if(MODE < 0) {
+               SETPRM(1,SCORE,MXSCOR);
+               SETPRM(3,game.turns,game.turns);
+               RSPEAK(259);
+               return;
+       }
 
 /*  that should be good enough.  Let's tell him all about it. */
 
 
 /*  that should be good enough.  Let's tell him all about it. */