After splitting out the stop field, nothing ever negates a travel opcode...
authorEric S. Raymond <esr@thyrsus.com>
Wed, 28 Jun 2017 02:15:22 +0000 (22:15 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 28 Jun 2017 02:15:22 +0000 (22:15 -0400)
...so all those labs() calls can go away.

init.c
main.c

diff --git a/init.c b/init.c
index fc8d5fdce8db6cfeb6c814d3b4c5552cb72f5eeb..dc70279426f396fe987689a01d7e7e6a33c0ef20 100644 (file)
--- a/init.c
+++ b/init.c
@@ -25,7 +25,7 @@ void initialise(void)
         game.abbrev[i] = 0;
         if (!(locations[i].description.big == 0 || tkey[i] == 0)) {
             int k = tkey[i];
-            if (MOD(labs(travel[k].opcode), 1000) == 1)
+            if (MOD(travel[k].opcode, 1000) == 1)
                conditions[i] |= (1 << COND_FORCED);
         }
         game.atloc[i] = 0;
diff --git a/main.c b/main.c
index c58281d157bcd32fb2ab1a97f3d72a617ac39d60..579ecfcecc294160c7dcfcb99a517eba1a886782 100644 (file)
--- a/main.c
+++ b/main.c
@@ -32,9 +32,9 @@
  * inherited from FORTRAN, someday. To understand these, read the
  * encoding description for travel.
  */
-#define T_DESTINATION(entry)   MOD(labs((entry).opcode) / 1000, 1000)
-#define T_NODWARVES(entry)     labs((entry).opcode) / 1000000 == 100
-#define T_MOTION(entry)                MOD(labs((entry).opcode), 1000)
+#define T_DESTINATION(entry)   MOD((entry).opcode / 1000, 1000)
+#define T_NODWARVES(entry)     ((entry).opcode / 1000000 == 100)
+#define T_MOTION(entry)                MOD((entry).opcode, 1000)
 #define T_TERMINATE(entry)     (T_MOTION(entry) == 1)
 #define T_STOP(entry)          ((entry).stop)
 #define T_OPCODE(entry)                ((entry).opcode)
@@ -619,7 +619,7 @@ static bool playermove(token_t verb, int motion)
         }
         ++kk;
     }
-    scratchloc = labs(T_OPCODE(travel[kk])) / 1000;
+    scratchloc = T_OPCODE(travel[kk]) / 1000;
 
     do {
         /*
@@ -648,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(T_OPCODE(travel[kk])) / 1000;
+                    game.newloc = T_OPCODE(travel[kk]) / 1000;
                 } while
                 (game.newloc == scratchloc);
                 scratchloc = game.newloc;
@@ -689,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(T_OPCODE(travel[kk])) / 1000;
+                        game.newloc = T_OPCODE(travel[kk]) / 1000;
                     } while
                     (game.newloc == scratchloc);
                     scratchloc = game.newloc;