From: Eric S. Raymond Date: Thu, 29 Jun 2017 01:06:36 +0000 (-0400) Subject: Eliminate some promiscuous variable reuse. X-Git-Tag: 1.1~37 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=9d918edeaa244e97e4fc7b4605bf0efb31f2b5d1;p=open-adventure.git Eliminate some promiscuous variable reuse. This was making the opcode-conditional evaluation logic much more difficult to read than it needed to be. --- diff --git a/main.c b/main.c index 75cdf37..7ccffbb 100644 --- a/main.c +++ b/main.c @@ -624,32 +624,33 @@ static bool playermove(token_t verb, int motion) */ for (;;) { /* L12 loop */ for (;;) { - game.newloc = scratchloc / 1000; - long arg = MOD(game.newloc, 100); - if (!SPECIAL(game.newloc)) { + long cond = scratchloc / 1000; + long arg = MOD(cond, 100); + if (!SPECIAL(cond)) { /* YAML N and [pct N] conditionals */ - if (game.newloc <= 100) { - if (game.newloc == 0 || PCT(game.newloc)) + if (cond <= 100) { + if (cond == 0 || PCT(cond)) break; /* else fall through */ } /* YAML [with OBJ] clause */ - if (TOTING(arg) || (game.newloc > 200 && AT(arg))) + if (TOTING(arg) || (cond > 200 && AT(arg))) break; /* else fall through to check [not OBJ STATE] */ - } else if (game.prop[arg] != game.newloc / 100 - 3) + } else if (game.prop[arg] != cond / 100 - 3) break; /* We arrive here on conditional failure. * Skip to next non-matching destination */ + long nextup; do { if (travel[kk].stop) BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); // LCOV_EXCL_LINE ++kk; - game.newloc = T_HIGH(travel[kk]); + nextup = T_HIGH(travel[kk]); } while - (game.newloc == scratchloc); - scratchloc = game.newloc; + (nextup == scratchloc); + scratchloc = nextup; } game.newloc = MOD(scratchloc, 1000);