Localize K.

This commit is contained in:
Eric S. Raymond 2017-06-12 06:13:00 -04:00
parent 5535c509eb
commit c0a450c4d6
2 changed files with 3 additions and 7 deletions

4
TODO
View file

@ -11,10 +11,6 @@ remain to be cleaned up:
in playermove() is particularly horrible, jumping backwards into the in playermove() is particularly horrible, jumping backwards into the
middle of a loop. middle of a loop.
* In playermove(), why doesn't replacing the global motion number K
with a passed-in argument work? There's some unobvious information
leak here.
* The way return values from handlers such as 2012 trigger side effects * The way return values from handlers such as 2012 trigger side effects
based on global state is nasty. based on global state is nasty.

6
main.c
View file

@ -492,9 +492,9 @@ static void croak(FILE *cmdin)
* him, so we need game.oldlc2, which is the last place he was * him, so we need game.oldlc2, which is the last place he was
* safe.) */ * safe.) */
static bool playermove(FILE *cmdin, token_t verb) static bool playermove(FILE *cmdin, token_t verb, int motion)
{ {
int LL, K2, KK=KEY[game.loc], motion = K; int LL, K2, KK=KEY[game.loc];
game.newloc=game.loc; game.newloc=game.loc;
if (KK == 0) if (KK == 0)
BUG(26); BUG(26);
@ -1056,7 +1056,7 @@ Laction:
BUG(99); BUG(99);
/* Figure out the new location */ /* Figure out the new location */
L8: if (playermove(cmdin, VERB)) L8: if (playermove(cmdin, VERB, K))
return true; return true;
else else
goto L2000; goto L2000;