Localize K to main.c

This commit is contained in:
Eric S. Raymond 2017-06-12 00:21:14 -04:00
parent 1f7a1bc8fd
commit 80c0c10221
2 changed files with 30 additions and 31 deletions

View file

@ -4,7 +4,7 @@
#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, WD1, WD1X, WD2, WD2X; extern long WD1, WD1X, WD2, WD2X;
static long SPK; /* This should go away too */ static long SPK; /* This should go away too */
@ -106,7 +106,6 @@ static int attack(FILE *input, long verb, long obj)
MOVE(obj,k); MOVE(obj,k);
} }
game.loc=k; game.loc=k;
K=NUL; /* FIXME: error if removed */
return(8); return(8);
} }
@ -769,7 +768,6 @@ static int pour(token_t obj)
PSPEAK(PLANT,game.prop[PLANT]+3); PSPEAK(PLANT,game.prop[PLANT]+3);
game.prop[PLANT]=MOD(game.prop[PLANT]+1,3); game.prop[PLANT]=MOD(game.prop[PLANT]+1,3);
game.prop[PLANT2]=game.prop[PLANT]; game.prop[PLANT2]=game.prop[PLANT];
K=NUL;
return(8); return(8);
} else { } else {
game.prop[DOOR]=0; game.prop[DOOR]=0;
@ -864,7 +862,6 @@ static int throw_support(long spk)
{ {
RSPEAK(spk); RSPEAK(spk);
DROP(AXE,game.loc); DROP(AXE,game.loc);
K=NUL;
return(8); return(8);
} }

56
main.c
View file

@ -39,7 +39,9 @@ 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, WD1, WD1X, WD2, WD2X; long WD1, WD1X, WD2, WD2X;
static int K; /* information leak, should go away */
FILE *logfp; FILE *logfp;
bool oldstyle = false; bool oldstyle = false;
@ -1025,32 +1027,32 @@ L4090: part=transitive; goto Laction;
L5000: part=unknown; obj = K; L5000: part=unknown; obj = K;
Laction: Laction:
switch (action(cmdin, part, VERB, obj)) { switch (action(cmdin, part, VERB, obj)) {
case 2: return true; case 2: return true;
case 8: goto L8; case 8: K=NUL; goto L8;
case 2000: goto L2000; case 2000: goto L2000;
case 2012: goto L2012; case 2012: goto L2012;
case 2600: goto L2600; case 2600: goto L2600;
case 2607: goto L2607; case 2607: goto L2607;
case 2630: goto L2630; case 2630: goto L2630;
case 2800: case 2800:
/* Get second word for analysis. */ /* Get second word for analysis. */
WD1=WD2; WD1=WD2;
WD1X=WD2X; WD1X=WD2X;
WD2=0; WD2=0;
goto L2620; goto L2620;
case 8000: case 8000:
/* Random intransitive verbs come here. Clear obj just in case /* Random intransitive verbs come here. Clear obj just in case
* (see attack()). */ * (see attack()). */
SETPRM(1,WD1,WD1X); SETPRM(1,WD1,WD1X);
RSPEAK(257); RSPEAK(257);
obj=0; obj=0;
goto L2600; goto L2600;
case 19000: case 19000:
/* Oh dear, he's disturbed the dwarves. */ /* Oh dear, he's disturbed the dwarves. */
RSPEAK(136); RSPEAK(136);
score(0); score(0);
return true; return true;
} }
BUG(99); BUG(99);
/* Figure out the new location */ /* Figure out the new location */