From a062d43079d42716ab682f04e5a94c97d1527cba Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 11 Jun 2017 22:04:14 -0400 Subject: [PATCH] SPK is no longer global. --- TODO | 4 ++-- actions.c | 4 +++- main.c | 28 ++++++++++++++-------------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/TODO b/TODO index 37857fe..c4102f2 100644 --- a/TODO +++ b/TODO @@ -3,9 +3,9 @@ The FORTRANish mess that once was is now mostly idiomatic C. Some issues remain to be cleaned up: -* The remaining shared globals: K, SPK, WD1, WD1X, WD2, WD2X. These are used +* The remaining shared globals: K, WD1, WD1X, WD2, WD2X. These are used rather promiscuously to pass around information that ought to be function - arguments in a modern language. K and SPK are particular offenders + arguments in a modern language. K is a particular offender * Remaining unstructured gotos in playermove() and do_command(). The goto L12 in playermove() is particularly horrible, jumping backwards into the diff --git a/actions.c b/actions.c index 01a373b..de5f830 100644 --- a/actions.c +++ b/actions.c @@ -4,7 +4,9 @@ #include "database.h" /* Limit visibility of ugly globals. Eventually these should go away. */ -extern long K, SPK, WD1, WD1X, WD2, WD2X; +extern long K, WD1, WD1X, WD2, WD2X; + +static long SPK; /* This should go away too */ /* * Action handlers. Eventually we'll do lookup through a method table diff --git a/main.c b/main.c index 06d4367..e102398 100644 --- a/main.c +++ b/main.c @@ -39,7 +39,7 @@ long AMBER, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, RUBY, RUG, SAPPH, SAY, SIGN, SNAKE, STEPS, STREAM, THROW, TRIDNT, TROLL, TROLL2, URN, VASE, VEND, VOLCAN, WATER; -long K, SPK, WD1, WD1X, WD2, WD2X; +long K, WD1, WD1X, WD2, WD2X; FILE *logfp; bool oldstyle = false; @@ -567,15 +567,15 @@ static bool playermove(FILE *cmdin, token_t verb) if (TRAVEL[KK] < 0) { /* Non-applicable motion. Various messages depending on * word given. */ - SPK=12; - if (K >= 43 && K <= 50)SPK=52; - if (K == 29 || K == 30)SPK=52; - if (K == 7 || K == 36 || K == 37)SPK=10; - if (K == 11 || K == 19)SPK=11; - if (verb == FIND || verb == INVENT)SPK=59; - if (K == 62 || K == 65)SPK=42; - if (K == 17)SPK=80; - RSPEAK(SPK); + int spk=12; + if (K >= 43 && K <= 50)spk=52; + if (K == 29 || K == 30)spk=52; + if (K == 7 || K == 36 || K == 37)spk=10; + if (K == 11 || K == 19)spk=11; + if (verb == FIND || verb == INVENT)spk=59; + if (K == 62 || K == 65)spk=42; + if (K == 17)spk=80; + RSPEAK(spk); return true; } ++KK; @@ -961,10 +961,10 @@ L2607: game.foobar=(game.foobar>0 ? -game.foobar : 0); } else if (game.limit <= 30) { if (!game.lmwarn && HERE(LAMP)) { game.lmwarn=true; - SPK=187; - if (game.place[BATTER] == 0)SPK=183; - if (game.prop[BATTER] == 1)SPK=189; - RSPEAK(SPK); + int spk=187; + if (game.place[BATTER] == 0)spk=183; + if (game.prop[BATTER] == 1)spk=189; + RSPEAK(spk); } } L19999: K=43; -- 2.31.1