From c0a450c4d65d9164f9be806f6609b09e8d1180f2 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 12 Jun 2017 06:13:00 -0400 Subject: [PATCH] Localize K. --- TODO | 4 ---- main.c | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index 6abcb59..218ca91 100644 --- a/TODO +++ b/TODO @@ -11,10 +11,6 @@ remain to be cleaned up: in playermove() is particularly horrible, jumping backwards into the 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 based on global state is nasty. diff --git a/main.c b/main.c index 2b831f2..8e78500 100644 --- a/main.c +++ b/main.c @@ -492,9 +492,9 @@ static void croak(FILE *cmdin) * him, so we need game.oldlc2, which is the last place he was * 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; if (KK == 0) BUG(26); @@ -1056,7 +1056,7 @@ Laction: BUG(99); /* Figure out the new location */ -L8: if (playermove(cmdin, VERB)) +L8: if (playermove(cmdin, VERB, K)) return true; else goto L2000; -- 2.31.1