De-macroize references to travel opcode fields we won't unpack further.

This commit is contained in:
Eric S. Raymond 2017-06-28 09:21:41 -04:00
parent db68e0097e
commit 27bc9f3bd2
3 changed files with 11 additions and 14 deletions

2
init.c
View file

@ -25,7 +25,7 @@ void initialise(void)
game.abbrev[i] = 0; game.abbrev[i] = 0;
if (!(locations[i].description.big == 0 || tkey[i] == 0)) { if (!(locations[i].description.big == 0 || tkey[i] == 0)) {
int k = tkey[i]; int k = tkey[i];
if (T_LOW(travel[k]) == 1) if (T_TERMINATE(travel[k]))
conditions[i] |= (1 << COND_FORCED); conditions[i] |= (1 << COND_FORCED);
} }
game.atloc[i] = 0; game.atloc[i] = 0;

14
main.c
View file

@ -414,7 +414,7 @@ static bool dwarfmove(void)
} }
++kk; ++kk;
} while } while
(!T_STOP(travel[kk - 1])); (!travel[kk - 1].stop);
tk[j] = game.odloc[i]; tk[j] = game.odloc[i];
if (j >= 2) if (j >= 2)
--j; --j;
@ -544,7 +544,7 @@ static bool playermove(token_t verb, int motion)
if (FORCED(scratchloc) && T_DESTINATION(travel[tkey[scratchloc]]) == motion) if (FORCED(scratchloc) && T_DESTINATION(travel[tkey[scratchloc]]) == motion)
k2 = kk; k2 = kk;
} }
if (!T_STOP(travel[kk])) { if (!travel[kk].stop) {
++kk; /* go to next travel entry for this location */ ++kk; /* go to next travel entry for this location */
continue; continue;
} }
@ -556,7 +556,7 @@ static bool playermove(token_t verb, int motion)
} }
} }
motion = T_MOTION(travel[kk]); motion = travel[kk].motion;
kk = tkey[game.loc]; kk = tkey[game.loc];
break; /* fall through to ordinary travel */ break; /* fall through to ordinary travel */
} }
@ -587,9 +587,9 @@ static bool playermove(token_t verb, int motion)
/* Look for a way to fulfil the motion - kk indexes the beginning /* Look for a way to fulfil the motion - kk indexes the beginning
* of the motion entries for here (game.loc). */ * of the motion entries for here (game.loc). */
for (;;) { for (;;) {
if (T_TERMINATE(travel[kk]) || T_MOTION(travel[kk]) == motion) if (T_TERMINATE(travel[kk]) || travel[kk].motion == motion)
break; break;
if (T_STOP(travel[kk])) { if (travel[kk].stop) {
/* FIXME: Magic numbers! */ /* FIXME: Magic numbers! */
/* Couldn't find an entry matching the motion word passed /* Couldn't find an entry matching the motion word passed
* in. Various messages depending on word given. */ * in. Various messages depending on word given. */
@ -632,7 +632,7 @@ static bool playermove(token_t verb, int motion)
} else if (game.prop[motion] != game.newloc / 100 - 3) } else if (game.prop[motion] != game.newloc / 100 - 3)
break; break;
do { do {
if (T_STOP(travel[kk])) if (travel[kk].stop)
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION);
++kk; ++kk;
game.newloc = T_HIGH(travel[kk]); game.newloc = T_HIGH(travel[kk]);
@ -673,7 +673,7 @@ static bool playermove(token_t verb, int motion)
* pretend he wasn't carrying it after all. */ * pretend he wasn't carrying it after all. */
drop(EMERALD, game.loc); drop(EMERALD, game.loc);
do { do {
if (T_STOP(travel[kk])) if (travel[kk].stop)
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION);
++kk; ++kk;
game.newloc = T_HIGH(travel[kk]); game.newloc = T_HIGH(travel[kk]);

View file

@ -138,7 +138,7 @@ typedef struct {{
}} action_t; }} action_t;
typedef struct {{ typedef struct {{
const long opcode; const long motion;
const long dest; const long dest;
const bool stop; const bool stop;
}} travelop_t; }} travelop_t;
@ -150,11 +150,8 @@ typedef struct {{
*/ */
#define T_DESTINATION(entry) MOD((entry).dest, 1000) #define T_DESTINATION(entry) MOD((entry).dest, 1000)
#define T_NODWARVES(entry) ((entry).dest / 1000 == 100) #define T_NODWARVES(entry) ((entry).dest / 1000 == 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_HIGH(entry) ((entry).dest) #define T_HIGH(entry) ((entry).dest)
#define T_LOW(entry) ((entry).opcode) #define T_TERMINATE(entry) ((entry).motion == 1)
#define L_SPEAK(loc) ((loc) - 500) #define L_SPEAK(loc) ((loc) - 500)
extern const location_t locations[]; extern const location_t locations[];
@ -644,7 +641,7 @@ def buildtravel(locs, objs, voc):
def get_travel(travel): def get_travel(travel):
template = """ {{ template = """ {{
.opcode = {}, .motion = {},
.dest = {}, .dest = {},
.stop = {}, .stop = {},
}}, }},