Abolish global variable I.

This commit is contained in:
Eric S. Raymond 2017-06-09 11:53:02 -04:00
parent fd2155b2f2
commit 64897f132e
3 changed files with 23 additions and 22 deletions

View file

@ -780,6 +780,7 @@ static int suspendresume(FILE *input, bool resume)
/* Suspend and resume */ /* Suspend and resume */
{ {
int kk; int kk;
long i;
if (!resume) { if (!resume) {
/* Suspend. Offer to save things in a file, but charging /* Suspend. Offer to save things in a file, but charging
* some points (so can't win by using saved games to retry * some points (so can't win by using saved games to retry
@ -810,8 +811,8 @@ static int suspendresume(FILE *input, bool resume)
* for I/O. All the SAV* functions can be scrapped. * for I/O. All the SAV* functions can be scrapped.
*/ */
DATIME(&I,&K); DATIME(&i,&K);
K=I+650*K; K=i+650*K;
SAVWRD(kk,K); SAVWRD(kk,K);
K=VRSION; K=VRSION;
SAVWRD(0,K); SAVWRD(0,K);
@ -892,8 +893,8 @@ static int throw(FILE *cmdin, long verb, long obj)
} }
if (obj != AXE) if (obj != AXE)
return(discard(obj, false)); return(discard(obj, false));
I=ATDWRF(game.loc); int i=ATDWRF(game.loc);
if (I <= 0) { if (i <= 0) {
if (AT(DRAGON) && game.prop[DRAGON] == 0) { if (AT(DRAGON) && game.prop[DRAGON] == 0) {
SPK=152; SPK=152;
return throw_support(SPK); return throw_support(SPK);
@ -922,8 +923,8 @@ static int throw(FILE *cmdin, long verb, long obj)
SPK=48; SPK=48;
return throw_support(SPK); return throw_support(SPK);
} }
game.dseen[I]=false; game.dseen[i]=false;
game.dloc[I]=0; game.dloc[i]=0;
SPK=47; SPK=47;
game.dkill=game.dkill+1; game.dkill=game.dkill+1;
if (game.dkill == 1)SPK=149; if (game.dkill == 1)SPK=149;

View file

@ -179,5 +179,5 @@ extern long AMBER, ATTACK, AXE, BACK, BATTER, BEAR,
STEPS, STICK, STREAM, THROW, TRIDNT, TROLL, TROLL2, STEPS, STICK, STREAM, THROW, TRIDNT, TROLL, TROLL2,
URN, VASE, VEND, VOLCAN, WATER; URN, VASE, VEND, VOLCAN, WATER;
/* everything else */ /* everything else */
extern long I, K, SPK, WD1, WD1X, WD2, WD2X; extern long K, SPK, WD1, WD1X, WD2, WD2X;

30
main.c
View file

@ -28,7 +28,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 I, K, SPK, WD1, WD1X, WD2, WD2X; long K, SPK, WD1, WD1X, WD2, WD2X;
FILE *logfp; FILE *logfp;
bool oldstyle = false; bool oldstyle = false;
@ -505,9 +505,9 @@ L2001: if(TOTING(BEAR))RSPEAK(141);
if(DARK(0)) goto L2012; if(DARK(0)) goto L2012;
game.abbrev[game.loc]=game.abbrev[game.loc]+1; game.abbrev[game.loc]=game.abbrev[game.loc]+1;
I=game.atloc[game.loc]; i=game.atloc[game.loc];
L2004: if(I == 0) goto L2012; L2004: if(i == 0) goto L2012;
obj=I; obj=i;
if(obj > NOBJECTS)obj=obj-NOBJECTS; if(obj > NOBJECTS)obj=obj-NOBJECTS;
if(obj == STEPS && TOTING(NUGGET)) goto L2008; if(obj == STEPS && TOTING(NUGGET)) goto L2008;
if(game.prop[obj] >= 0) goto L2006; if(game.prop[obj] >= 0) goto L2006;
@ -529,7 +529,7 @@ L2004: if(I == 0) goto L2012;
L2006: KK=game.prop[obj]; L2006: KK=game.prop[obj];
if(obj == STEPS && game.loc == game.fixed[STEPS])KK=1; if(obj == STEPS && game.loc == game.fixed[STEPS])KK=1;
PSPEAK(obj,KK); PSPEAK(obj,KK);
L2008: I=game.link[I]; L2008: i=game.link[i];
goto L2004; goto L2004;
L2009: K=54; L2009: K=54;
@ -621,11 +621,11 @@ L2620: if(WD1 == MAKEWD(23051920)) {
RSPEAK(276); RSPEAK(276);
} }
L2630: L2630:
I=VOCAB(WD1,-1); i=VOCAB(WD1,-1);
if(I == -1) if(i == -1)
goto L3000; goto L3000;
K=MOD(I,1000); K=MOD(i,1000);
KQ=I/1000+1; KQ=i/1000+1;
switch (KQ-1) { case 0: goto L8; case 1: goto L5000; case 2: goto L4000; switch (KQ-1) { case 0: goto L8; case 1: goto L5000; case 2: goto L4000;
case 3: goto L2010; } case 3: goto L2010; }
BUG(22); BUG(22);
@ -647,11 +647,11 @@ L3000: SETPRM(1,WD1,WD1X);
/* Verb and object analysis moved to separate module. */ /* Verb and object analysis moved to separate module. */
L4000: I=4000; VERB=K; goto Laction; L4000: i=4000; VERB=K; goto Laction;
L4090: I=4090; goto Laction; L4090: i=4090; goto Laction;
L5000: I=5000; obj = K; L5000: i=5000; obj = K;
Laction: Laction:
switch (action(cmdin, I, VERB, obj)) { switch (action(cmdin, i, VERB, obj)) {
case 2: return true; case 2: return true;
case 8: goto L8; case 8: goto L8;
case 2000: goto L2000; case 2000: goto L2000;
@ -951,8 +951,8 @@ L11000: game.prop[BOTTLE]=PUT(BOTTLE,115,1);
/* Leave the grate with normal (non-negative) property. Reuse sign. */ /* Leave the grate with normal (non-negative) property. Reuse sign. */
I=PUT(GRATE,116,0); PUT(GRATE,116,0);
I=PUT(SIGN,116,0); PUT(SIGN,116,0);
OBJTXT[SIGN]=OBJTXT[SIGN]+1; OBJTXT[SIGN]=OBJTXT[SIGN]+1;
game.prop[SNAKE]=PUT(SNAKE,116,1); game.prop[SNAKE]=PUT(SNAKE,116,1);
game.prop[BIRD]=PUT(BIRD,116,1); game.prop[BIRD]=PUT(BIRD,116,1);