Simplify conditional evaluation when processing travel opcodes.
This commit is contained in:
parent
289f72e078
commit
d43854f0f6
1 changed files with 13 additions and 21 deletions
34
main.c
34
main.c
|
@ -614,18 +614,10 @@ static bool playermove(token_t verb, int motion)
|
||||||
/* (ESR) We've found a destination that goes with the motion verb.
|
/* (ESR) We've found a destination that goes with the motion verb.
|
||||||
* Next we need to check any conditional(s) on this destination, and
|
* Next we need to check any conditional(s) on this destination, and
|
||||||
* possibly on following entries. */
|
* possibly on following entries. */
|
||||||
scratchloc = T_HIGH(travel[kk]);
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
/*
|
|
||||||
* (ESR) This conditional-skip loop may have to be repeated if
|
|
||||||
* it includes the plover passage. Same deal for any future
|
|
||||||
* cases where we need to block travel and then redo it once
|
|
||||||
* the blocking condition has been removed.
|
|
||||||
*/
|
|
||||||
for (;;) { /* L12 loop */
|
for (;;) { /* L12 loop */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
long cond = scratchloc / 1000;
|
long cond = T_CONDITION(travel[kk]);
|
||||||
long arg = MOD(cond, 100);
|
long arg = MOD(cond, 100);
|
||||||
if (!SPECIAL(cond)) {
|
if (!SPECIAL(cond)) {
|
||||||
/* YAML N and [pct N] conditionals */
|
/* YAML N and [pct N] conditionals */
|
||||||
|
@ -643,18 +635,18 @@ static bool playermove(token_t verb, int motion)
|
||||||
|
|
||||||
/* We arrive here on conditional failure.
|
/* We arrive here on conditional failure.
|
||||||
* Skip to next non-matching destination */
|
* Skip to next non-matching destination */
|
||||||
long nextup;
|
long k2 = kk;
|
||||||
do {
|
do {
|
||||||
if (travel[kk].stop)
|
if (travel[k2].stop)
|
||||||
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); // LCOV_EXCL_LINE
|
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); // LCOV_EXCL_LINE
|
||||||
++kk;
|
++k2;
|
||||||
nextup = T_HIGH(travel[kk]);
|
|
||||||
} while
|
} while
|
||||||
(nextup == scratchloc);
|
(T_HIGH(travel[kk]) == T_HIGH(travel[k2]));
|
||||||
scratchloc = nextup;
|
kk = k2;
|
||||||
}
|
}
|
||||||
|
|
||||||
game.newloc = MOD(scratchloc, 1000);
|
/* Found an eligible rule, now execute it */
|
||||||
|
game.newloc = T_DESTINATION(travel[kk]);
|
||||||
if (!SPECIAL(game.newloc))
|
if (!SPECIAL(game.newloc))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -685,14 +677,14 @@ static bool playermove(token_t verb, int motion)
|
||||||
* to get it out. Having dropped it, go back and
|
* to get it out. Having dropped it, go back and
|
||||||
* pretend he wasn't carrying it after all. */
|
* pretend he wasn't carrying it after all. */
|
||||||
drop(EMERALD, game.loc);
|
drop(EMERALD, game.loc);
|
||||||
|
k2 = kk;
|
||||||
do {
|
do {
|
||||||
if (travel[kk].stop)
|
if (travel[k2].stop)
|
||||||
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); // LCOV_EXCL_LINE
|
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); // LCOV_EXCL_LINE
|
||||||
++kk;
|
++k2;
|
||||||
game.newloc = T_HIGH(travel[kk]);
|
|
||||||
} while
|
} while
|
||||||
(game.newloc == scratchloc);
|
(T_HIGH(travel[kk]) == T_HIGH(travel[k2]));
|
||||||
scratchloc = game.newloc;
|
kk = k2;
|
||||||
continue; /* goto L12 */
|
continue; /* goto L12 */
|
||||||
case 3:
|
case 3:
|
||||||
/* Travel 303. Troll bridge. Must be done only
|
/* Travel 303. Troll bridge. Must be done only
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue