Break travel array into three struct fields.
[open-adventure.git] / main.c
diff --git a/main.c b/main.c
index 2248f3db51d41d7b90bfdf2df7f0aa883ab2bcd3..dd202357ba7004073ce1c51290c74110dbb1ac76 100644 (file)
--- a/main.c
+++ b/main.c
 
 #define DIM(a) (sizeof(a)/sizeof(a[0]))
 
-/* Abstract out the encoding of words in the travel array.  Gives us
- * some hope of getting to a less cryptic representation than we
- * inherited from FORTRAN, someday. To understand these, read the
- * encoding description for travel.
- */
-#define T_DESTINATION(entry)   MOD(labs(entry) / 1000, 1000)
-#define T_NODWARVES(entry)     labs(entry) / 1000000 == 100
-#define T_MOTION(entry)                MOD(labs(entry), 1000)
-#define L_SPEAK(loc)           ((loc) - 500)
-#define T_TERMINATE(entry)     (T_MOTION(entry) == 1)
-
 struct game_t game;
 
 long LNLENG, LNPOSN;
@@ -425,7 +414,7 @@ static bool dwarfmove(void)
                 }
                 ++kk;
             } while
-            (travel[kk - 1] >= 0);
+               (!T_STOP(travel[kk - 1]));
         tk[j] = game.odloc[i];
         if (j >= 2)
             --j;
@@ -555,7 +544,7 @@ static bool playermove(token_t verb, int motion)
                         if (FORCED(scratchloc) && T_DESTINATION(travel[tkey[scratchloc]]) == motion)
                             k2 = kk;
                     }
-                    if (travel[kk] >= 0) {
+                    if (!T_STOP(travel[kk])) {
                         ++kk;  /* go to next travel entry for this location */
                         continue;
                     }
@@ -600,7 +589,7 @@ static bool playermove(token_t verb, int motion)
     for (;;) {
         if (T_TERMINATE(travel[kk]) || T_MOTION(travel[kk]) == motion)
             break;
-        if (travel[kk] < 0) {
+        if (T_STOP(travel[kk])) {
             /* FIXME: Magic numbers! */
             /*  Couldn't find an entry matching the motion word passed
              *  in.  Various messages depending on word given. */
@@ -617,7 +606,7 @@ static bool playermove(token_t verb, int motion)
         }
         ++kk;
     }
-    scratchloc = labs(travel[kk]) / 1000;
+    scratchloc = T_HIGH(travel[kk]);
 
     do {
         /*
@@ -643,10 +632,10 @@ static bool playermove(token_t verb, int motion)
                 } else if (game.prop[motion] != game.newloc / 100 - 3)
                     break;
                 do {
-                    if (travel[kk] < 0)
+                    if (T_STOP(travel[kk]))
                         BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION);
                     ++kk;
-                    game.newloc = labs(travel[kk]) / 1000;
+                    game.newloc = T_HIGH(travel[kk]);
                 } while
                 (game.newloc == scratchloc);
                 scratchloc = game.newloc;
@@ -684,10 +673,10 @@ static bool playermove(token_t verb, int motion)
                      * pretend he wasn't carrying it after all. */
                     drop(EMERALD, game.loc);
                     do {
-                        if (travel[kk] < 0)
+                        if (T_STOP(travel[kk]))
                             BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION);
                         ++kk;
-                        game.newloc = labs(travel[kk]) / 1000;
+                        game.newloc = T_HIGH(travel[kk]);
                     } while
                     (game.newloc == scratchloc);
                     scratchloc = game.newloc;
@@ -747,15 +736,14 @@ static bool closecheck(void)
  *  to get out.  If he doesn't within clock2 turns, we close the cave;
  *  if he does try, we assume he panics, and give him a few additional
  *  turns to get frantic before we close.  When clock2 hits zero, we
- *  branch to 11000 to transport him into the final puzzle.  Note that
- *  the puzzle depends upon all sorts of random things.  For instance,
- *  there must be no water or oil, since there are beanstalks which we
- *  don't want to be able to water, since the code can't handle it.
- *  Also, we can have no keys, since there is a grate (having moved
- *  the fixed object!) there separating him from all the treasures.
- *  Most of these problems arise from the use of negative prop numbers
- *  to suppress the object descriptions until he's actually moved the
- *  objects. */
+ *  transport him into the final puzzle.  Note that the puzzle depends
+ *  upon all sorts of random things.  For instance, there must be no
+ *  water or oil, since there are beanstalks which we don't want to be
+ *  able to water, since the code can't handle it.  Also, we can have
+ *  no keys, since there is a grate (having moved the fixed object!)
+ *  there separating him from all the treasures.  Most of these
+ *  problems arise from the use of negative prop numbers to suppress
+ *  the object descriptions until he's actually moved the objects. */
 {
     if (game.tally == 0 && INDEEP(game.loc) && game.loc != LOC_Y2)
         --game.clock1;