Localize K in fill().

This commit is contained in:
Eric S. Raymond 2017-06-08 03:12:07 -04:00
parent 7e4753b23a
commit b29678956e

View file

@ -219,61 +219,75 @@ L9128: RSPEAK(SPK);
return(2011); return(2011);
} }
/* Throw. Same as discard unless axe. Then same as attack except ignore bird, int throw(FILE *cmdin, long obj, long verb)
* and if dwarf is present then one might be killed. (Only way to do so!) /* Throw. Same as discard unless axe. Then same as attack except
* Axe also special for dragon, bear, and troll. Treasures special for troll. */ * ignore bird, and if dwarf is present then one might be killed.
* (Only way to do so!) Axe also special for dragon, bear, and
* troll. Treasures special for troll. */
{
if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))obj=ROD2;
if (!TOTING(obj))
return(2011);
if (obj >= 50 && obj <= MAXTRS && AT(TROLL))
goto L9178;
if (obj == FOOD && HERE(BEAR))
goto L9177;
if (obj != AXE)
return(discard(obj, false));
I=ATDWRF(game.loc);
if (I > 0)
goto L9172;
SPK=152;
if (AT(DRAGON) && game.prop[DRAGON] == 0)
goto L9175;
SPK=158;
if (AT(TROLL))
goto L9175;
SPK=203;
if (AT(OGRE))
goto L9175;
if (HERE(BEAR) && game.prop[BEAR] == 0)
goto L9176;
return(attack(cmdin, 0, verb));
int throw(FILE *cmdin, long obj, long verb) { L9172:
if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))obj=ROD2; SPK=48;
if (!TOTING(obj)) return(2011); if (randrange(NDWARVES+1) < game.dflag) goto L9175;
if (obj >= 50 && obj <= MAXTRS && AT(TROLL)) goto L9178; game.dseen[I]=false;
if (obj == FOOD && HERE(BEAR)) goto L9177; game.dloc[I]=0;
if (obj != AXE) return(discard(obj, false)); SPK=47;
I=ATDWRF(game.loc); game.dkill=game.dkill+1;
if (I > 0) goto L9172; if (game.dkill == 1)SPK=149;
SPK=152; L9175:
if (AT(DRAGON) && game.prop[DRAGON] == 0) goto L9175; RSPEAK(SPK);
SPK=158; DROP(AXE,game.loc);
if (AT(TROLL)) goto L9175; K=NUL;
SPK=203; return(8);
if (AT(OGRE)) goto L9175;
if (HERE(BEAR) && game.prop[BEAR] == 0) goto L9176;
obj=0;
return(attack(cmdin, obj, verb));
L9172: SPK=48; /* This'll teach him to throw the axe at the bear! */
if (randrange(NDWARVES+1) < game.dflag) goto L9175; L9176:
game.dseen[I]=false; SPK=164;
game.dloc[I]=0; DROP(AXE,game.loc);
SPK=47; game.fixed[AXE]= -1;
game.dkill=game.dkill+1; game.prop[AXE]=1;
if (game.dkill == 1)SPK=149; JUGGLE(BEAR);
L9175: RSPEAK(SPK); return(2011);
DROP(AXE,game.loc);
K=NUL;
return(8);
/* This'll teach him to throw the axe at the bear! */ /* But throwing food is another story. */
L9176: SPK=164; L9177:
DROP(AXE,game.loc); obj=BEAR;
game.fixed[AXE]= -1; return(feed(obj));
game.prop[AXE]=1;
JUGGLE(BEAR);
return(2011);
/* But throwing food is another story. */ L9178:
L9177: obj=BEAR; SPK=159;
return(feed(obj)); /* Snarf a treasure for the troll. */
DROP(obj,0);
L9178: SPK=159; MOVE(TROLL,0);
/* Snarf a treasure for the troll. */ MOVE(TROLL+NOBJECTS,0);
DROP(obj,0); DROP(TROLL2,PLAC[TROLL]);
MOVE(TROLL,0); DROP(TROLL2+NOBJECTS,FIXD[TROLL]);
MOVE(TROLL+NOBJECTS,0); JUGGLE(CHASM);
DROP(TROLL2,PLAC[TROLL]); return(2011);
DROP(TROLL2+NOBJECTS,FIXD[TROLL]);
JUGGLE(CHASM);
return(2011);
} }
int feed(long obj) int feed(long obj)
@ -332,6 +346,7 @@ int fill(long obj)
/* Fill. Bottle or urn must be empty, and liquid available. (Vase /* Fill. Bottle or urn must be empty, and liquid available. (Vase
* is nasty.) */ * is nasty.) */
{ {
int k;
if (obj == VASE) { if (obj == VASE) {
SPK=29; SPK=29;
if (LIQLOC(game.loc) == 0)SPK=144; if (LIQLOC(game.loc) == 0)SPK=144;
@ -347,11 +362,11 @@ int fill(long obj)
SPK=213; SPK=213;
if (game.prop[URN] != 0) return(2011); if (game.prop[URN] != 0) return(2011);
SPK=144; SPK=144;
K=LIQ(0); k=LIQ(0);
if (K == 0 || !HERE(BOTTLE)) return(2011); if (k == 0 || !HERE(BOTTLE)) return(2011);
game.place[K]=0; game.place[k]=0;
game.prop[BOTTLE]=1; game.prop[BOTTLE]=1;
if (K == OIL)game.prop[URN]=1; if (k == OIL)game.prop[URN]=1;
SPK=211+game.prop[URN]; SPK=211+game.prop[URN];
return(2011); return(2011);
} }
@ -370,10 +385,10 @@ int fill(long obj)
if (SPK != 107) if (SPK != 107)
return(2011); return(2011);
game.prop[BOTTLE]=MOD(COND[game.loc],4)/2*2; game.prop[BOTTLE]=MOD(COND[game.loc],4)/2*2;
K=LIQ(0); k=LIQ(0);
if (TOTING(BOTTLE)) if (TOTING(BOTTLE))
game.place[K]= -1; game.place[k]= -1;
if (K == OIL) if (k == OIL)
SPK=108; SPK=108;
return(2011); return(2011);
} }