All travel[] references are now wrapped in extractor/predicate macros.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 28 Jun 2017 01:55:29 +0000 (21:55 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 28 Jun 2017 01:55:29 +0000 (21:55 -0400)
This is a step toward pulling the magic numbers apart into data structures
so there will be fewer magic numbers in the code.

main.c

diff --git a/main.c b/main.c
index e8ee600aaef331ba59c2b826c094f8c886e54f1d..5ad7d90ffe203396e7844b8a0a599b5d0c4ee491 100644 (file)
--- a/main.c
+++ b/main.c
@@ -38,6 +38,7 @@
 #define L_SPEAK(loc)           ((loc) - 500)
 #define T_TERMINATE(entry)     (T_MOTION(entry) == 1)
 #define T_STOP(entry)          ((entry) < 0)
+#define T_OPCODE(entry)                (entry)
 
 struct game_t game;
 
@@ -618,7 +619,7 @@ static bool playermove(token_t verb, int motion)
         }
         ++kk;
     }
-    scratchloc = labs(travel[kk]) / 1000;
+    scratchloc = labs(T_OPCODE(travel[kk])) / 1000;
 
     do {
         /*
@@ -647,7 +648,7 @@ static bool playermove(token_t verb, int motion)
                     if (T_STOP(travel[kk]))
                         BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION);
                     ++kk;
-                    game.newloc = labs(travel[kk]) / 1000;
+                    game.newloc = labs(T_OPCODE(travel[kk])) / 1000;
                 } while
                 (game.newloc == scratchloc);
                 scratchloc = game.newloc;
@@ -688,7 +689,7 @@ static bool playermove(token_t verb, int motion)
                         if (T_STOP(travel[kk]))
                             BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION);
                         ++kk;
-                        game.newloc = labs(travel[kk]) / 1000;
+                        game.newloc = labs(T_OPCODE(travel[kk])) / 1000;
                     } while
                     (game.newloc == scratchloc);
                     scratchloc = game.newloc;