From fb35c34171b0e5b46c217b19bea5d808fb61853b Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 27 Jun 2017 22:15:22 -0400 Subject: [PATCH] After splitting out the stop field, nothing ever negates a travel opcode... ...so all those labs() calls can go away. --- init.c | 2 +- main.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/init.c b/init.c index fc8d5fd..dc70279 100644 --- 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 c58281d..579ecfc 100644 --- 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; -- 2.31.1