SPK is no longer global.

This commit is contained in:
Eric S. Raymond 2017-06-11 22:04:14 -04:00
parent e2ebc24114
commit a062d43079
3 changed files with 19 additions and 17 deletions

4
TODO
View file

@ -3,9 +3,9 @@
The FORTRANish mess that once was is now mostly idiomatic C. Some issues The FORTRANish mess that once was is now mostly idiomatic C. Some issues
remain to be cleaned up: 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 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 * Remaining unstructured gotos in playermove() and do_command(). The goto L12
in playermove() is particularly horrible, jumping backwards into the in playermove() is particularly horrible, jumping backwards into the

View file

@ -4,7 +4,9 @@
#include "database.h" #include "database.h"
/* Limit visibility of ugly globals. Eventually these should go away. */ /* 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 * Action handlers. Eventually we'll do lookup through a method table

28
main.c
View file

@ -39,7 +39,7 @@ long AMBER, AXE, BACK, BATTER, BEAR, BIRD, BLOOD,
RUBY, RUG, SAPPH, SAY, SIGN, SNAKE, RUBY, RUG, SAPPH, SAY, SIGN, SNAKE,
STEPS, STREAM, THROW, TRIDNT, TROLL, TROLL2, STEPS, STREAM, THROW, TRIDNT, TROLL, TROLL2,
URN, VASE, VEND, VOLCAN, WATER; URN, VASE, VEND, VOLCAN, WATER;
long K, SPK, WD1, WD1X, WD2, WD2X; long K, WD1, WD1X, WD2, WD2X;
FILE *logfp; FILE *logfp;
bool oldstyle = false; bool oldstyle = false;
@ -567,15 +567,15 @@ static bool playermove(FILE *cmdin, token_t verb)
if (TRAVEL[KK] < 0) { if (TRAVEL[KK] < 0) {
/* Non-applicable motion. Various messages depending on /* Non-applicable motion. Various messages depending on
* word given. */ * word given. */
SPK=12; int spk=12;
if (K >= 43 && K <= 50)SPK=52; if (K >= 43 && K <= 50)spk=52;
if (K == 29 || K == 30)SPK=52; if (K == 29 || K == 30)spk=52;
if (K == 7 || K == 36 || K == 37)SPK=10; if (K == 7 || K == 36 || K == 37)spk=10;
if (K == 11 || K == 19)SPK=11; if (K == 11 || K == 19)spk=11;
if (verb == FIND || verb == INVENT)SPK=59; if (verb == FIND || verb == INVENT)spk=59;
if (K == 62 || K == 65)SPK=42; if (K == 62 || K == 65)spk=42;
if (K == 17)SPK=80; if (K == 17)spk=80;
RSPEAK(SPK); RSPEAK(spk);
return true; return true;
} }
++KK; ++KK;
@ -961,10 +961,10 @@ L2607: game.foobar=(game.foobar>0 ? -game.foobar : 0);
} else if (game.limit <= 30) { } else if (game.limit <= 30) {
if (!game.lmwarn && HERE(LAMP)) { if (!game.lmwarn && HERE(LAMP)) {
game.lmwarn=true; game.lmwarn=true;
SPK=187; int spk=187;
if (game.place[BATTER] == 0)SPK=183; if (game.place[BATTER] == 0)spk=183;
if (game.prop[BATTER] == 1)SPK=189; if (game.prop[BATTER] == 1)spk=189;
RSPEAK(SPK); RSPEAK(spk);
} }
} }
L19999: K=43; L19999: K=43;