Code simplifications based on abolishing 2011.

This commit is contained in:
Eric S. Raymond 2017-06-11 10:59:33 -04:00
parent 5e5ad6b1aa
commit 8cdbf034a2

202
actions.c
View file

@ -38,7 +38,11 @@ static int attack(FILE *input, long verb, long obj)
} }
if (obj == BIRD) { if (obj == BIRD) {
SPK=137; SPK=137;
if (game.closed) {RSPEAK(SPK); return 2012;} if (game.closed)
{
RSPEAK(SPK);
return 2012;
}
DSTROY(BIRD); DSTROY(BIRD);
game.prop[BIRD]=0; game.prop[BIRD]=0;
SPK=45; SPK=45;
@ -70,7 +74,8 @@ static int attack(FILE *input, long verb, long obj)
} }
} }
SPK=SPK+1+1/k; SPK=SPK+1+1/k;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
if (obj == BEAR)SPK=165+(game.prop[BEAR]+1)/2; if (obj == BEAR)SPK=165+(game.prop[BEAR]+1)/2;
if (obj != DRAGON || game.prop[DRAGON] != 0) {RSPEAK(SPK); return 2012;} if (obj != DRAGON || game.prop[DRAGON] != 0) {RSPEAK(SPK); return 2012;}
@ -109,13 +114,16 @@ static int bigwords(long foo)
SPK=42; SPK=42;
if (game.foobar != 1-k) { if (game.foobar != 1-k) {
if (game.foobar != 0)SPK=151; if (game.foobar != 0)SPK=151;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} else { } else {
game.foobar=k; game.foobar=k;
if (k != 4) return(2009); if (k != 4) return(2009);
game.foobar=0; game.foobar=0;
if (game.place[EGGS] == PLAC[EGGS] || (TOTING(EGGS) && game.loc == PLAC[EGGS])) if (game.place[EGGS]==PLAC[EGGS] || (TOTING(EGGS) && game.loc==PLAC[EGGS])) {
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
}
/* Bring back troll if we steal the eggs back from him before /* Bring back troll if we steal the eggs back from him before
* crossing. */ * crossing. */
if (game.place[EGGS]==0 && game.place[TROLL]==0 && game.prop[TROLL]==0) if (game.place[EGGS]==0 && game.place[TROLL]==0 && game.prop[TROLL]==0)
@ -138,12 +146,13 @@ static int bivalve(token_t verb, token_t obj)
if (TOTING(obj))SPK=120+k; if (TOTING(obj))SPK=120+k;
if (!TOTING(TRIDNT))SPK=122+k; if (!TOTING(TRIDNT))SPK=122+k;
if (verb == LOCK)SPK=61; if (verb == LOCK)SPK=61;
if (SPK != 124) if (SPK == 124) {
{RSPEAK(SPK); return 2012;}
DSTROY(CLAM); DSTROY(CLAM);
DROP(OYSTER,game.loc); DROP(OYSTER,game.loc);
DROP(PEARL,105); DROP(PEARL,105);
{RSPEAK(SPK); return 2012;} }
RSPEAK(SPK);
return 2012;
} }
static int blast(void) static int blast(void)
@ -166,13 +175,15 @@ static int vbreak(token_t obj)
if (TOTING(VASE))DROP(VASE,game.loc); if (TOTING(VASE))DROP(VASE,game.loc);
game.prop[VASE]=2; game.prop[VASE]=2;
game.fixed[VASE]= -1; game.fixed[VASE]= -1;
{RSPEAK(SPK); return 2012;}
} else { } else {
if (obj != MIRROR || !game.closed) {RSPEAK(SPK); return 2012;} if (obj == MIRROR && game.closed) {
SPK=197; SPK=197;
return(18999); return(18999);
} }
} }
RSPEAK(SPK);
return 2012;
}
static int brief(void) static int brief(void)
/* Brief. Intransitive only. Suppress long descriptions after first time. */ /* Brief. Intransitive only. Suppress long descriptions after first time. */
@ -180,7 +191,8 @@ static int brief(void)
SPK=156; SPK=156;
game.abbnum=10000; game.abbnum=10000;
game.detail=3; game.detail=3;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
static int carry(long obj) static int carry(long obj)
@ -211,31 +223,39 @@ static int carry(long obj)
SPK=190; SPK=190;
DSTROY(MESSAG); DSTROY(MESSAG);
} }
if (game.fixed[obj] != 0) if (game.fixed[obj] != 0) {
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
}
if (obj == WATER || obj == OIL) { if (obj == WATER || obj == OIL) {
if (!HERE(BOTTLE) || LIQUID() != obj) { if (!HERE(BOTTLE) || LIQUID() != obj) {
if (TOTING(BOTTLE) && game.prop[BOTTLE] == 1) if (TOTING(BOTTLE) && game.prop[BOTTLE] == 1)
return(fill(BOTTLE)); return(fill(BOTTLE));
if (game.prop[BOTTLE] != 1)SPK=105; if (game.prop[BOTTLE] != 1)SPK=105;
if (!TOTING(BOTTLE))SPK=104; if (!TOTING(BOTTLE))SPK=104;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
obj = BOTTLE; obj = BOTTLE;
} }
SPK=92; SPK=92;
if (game.holdng >= INVLIMIT) if (game.holdng >= INVLIMIT) {
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
if (obj == BIRD && game.prop[BIRD] != 1 && -1-game.prop[BIRD] != 1) { return 2012;
}
else if (obj == BIRD && game.prop[BIRD] != 1 && -1-game.prop[BIRD] != 1) {
if (game.prop[BIRD] == 2) { if (game.prop[BIRD] == 2) {
SPK=238;
DSTROY(BIRD); DSTROY(BIRD);
{RSPEAK(SPK); return 2012;} RSPEAK(238);
return 2012;
} }
if (!TOTING(CAGE))SPK=27; if (!TOTING(CAGE))SPK=27;
if (TOTING(ROD))SPK=26; if (TOTING(ROD))SPK=26;
if (SPK/2 == 13) {RSPEAK(SPK); return 2012;} if (SPK/2 == 13) {
RSPEAK(SPK);
return 2012;
}
game.prop[BIRD]=1; game.prop[BIRD]=1;
} }
if ((obj==BIRD || obj==CAGE) && (game.prop[BIRD]==1 || -1-game.prop[BIRD]==1)) if ((obj==BIRD || obj==CAGE) && (game.prop[BIRD]==1 || -1-game.prop[BIRD]==1))
@ -262,7 +282,6 @@ static int chain(token_t verb)
game.fixed[CHAIN]=0; game.fixed[CHAIN]=0;
if (game.prop[BEAR] != 3)game.prop[BEAR]=2; if (game.prop[BEAR] != 3)game.prop[BEAR]=2;
game.fixed[BEAR]=2-game.prop[BEAR]; game.fixed[BEAR]=2-game.prop[BEAR];
{RSPEAK(SPK); return 2012;}
} else { } else {
SPK=172; SPK=172;
if (game.prop[CHAIN] != 0)SPK=34; if (game.prop[CHAIN] != 0)SPK=34;
@ -271,8 +290,9 @@ static int chain(token_t verb)
game.prop[CHAIN]=2; game.prop[CHAIN]=2;
if (TOTING(CHAIN))DROP(CHAIN,game.loc); if (TOTING(CHAIN))DROP(CHAIN,game.loc);
game.fixed[CHAIN]= -1; game.fixed[CHAIN]= -1;
{RSPEAK(SPK); return 2012;}
} }
RSPEAK(SPK);
return 2012;
} }
static int discard(long obj, bool just_do_it) static int discard(long obj, bool just_do_it)
@ -357,13 +377,15 @@ static int drink(token_t obj)
game.prop[BOTTLE]=1; game.prop[BOTTLE]=1;
game.place[WATER]=0; game.place[WATER]=0;
SPK=74; SPK=74;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} else { } else {
DSTROY(BLOOD); DSTROY(BLOOD);
game.prop[DRAGON]=2; game.prop[DRAGON]=2;
OBJSND[BIRD]=OBJSND[BIRD]+3; OBJSND[BIRD]=OBJSND[BIRD]+3;
SPK=240; SPK=240;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
} }
@ -376,18 +398,17 @@ static int eat(token_t obj)
return(8000); return(8000);
DSTROY(FOOD); DSTROY(FOOD);
SPK=72; SPK=72;
{RSPEAK(SPK); return 2012;}
} else { } else {
if (obj == FOOD) { if (obj == FOOD) {
DSTROY(FOOD); DSTROY(FOOD);
SPK=72; SPK=72;
{RSPEAK(SPK); return 2012;}
} }
if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj == if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj ==
DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj == DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj ==
OGRE)SPK=71; OGRE)SPK=71;
{RSPEAK(SPK); return 2012;}
} }
RSPEAK(SPK);
return 2012;
} }
static int extinguish(int obj) static int extinguish(int obj)
@ -396,24 +417,26 @@ static int extinguish(int obj)
if (obj == INTRANSITIVE) { if (obj == INTRANSITIVE) {
if (HERE(LAMP) && game.prop[LAMP] == 1)obj=LAMP; if (HERE(LAMP) && game.prop[LAMP] == 1)obj=LAMP;
if (HERE(URN) && game.prop[URN] == 2)obj=obj*NOBJECTS+URN; if (HERE(URN) && game.prop[URN] == 2)obj=obj*NOBJECTS+URN;
if (obj == 0 || obj > NOBJECTS) return(8000); if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return(8000);
} }
if (obj == URN) { if (obj == URN) {
game.prop[URN]=game.prop[URN]/2; game.prop[URN]=game.prop[URN]/2;
SPK=210; SPK=210;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
if (obj == LAMP) { else if (obj == LAMP) {
game.prop[LAMP]=0; game.prop[LAMP]=0;
RSPEAK(40); RSPEAK(40);
if (DARK(game.loc)) if (DARK(game.loc))
RSPEAK(16); RSPEAK(16);
return(2012); return(2012);
} }
if (obj == DRAGON || obj == VOLCAN) else if (obj == DRAGON || obj == VOLCAN)
SPK=146; SPK=146;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
static int feed(long obj) static int feed(long obj)
@ -422,7 +445,8 @@ static int feed(long obj)
{ {
if (obj == BIRD) { if (obj == BIRD) {
SPK=100; SPK=100;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
if (!(obj != SNAKE && obj != DRAGON && obj != TROLL)) { if (!(obj != SNAKE && obj != DRAGON && obj != TROLL)) {
@ -434,7 +458,8 @@ static int feed(long obj)
SPK=101; SPK=101;
DSTROY(BIRD); DSTROY(BIRD);
game.prop[BIRD]=0; game.prop[BIRD]=0;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
if (obj == DWARF) { if (obj == DWARF) {
@ -442,30 +467,36 @@ static int feed(long obj)
{RSPEAK(SPK); return 2012;} {RSPEAK(SPK); return 2012;}
SPK=103; SPK=103;
game.dflag=game.dflag+2; game.dflag=game.dflag+2;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
if (obj == BEAR) { if (obj == BEAR) {
if (game.prop[BEAR] == 0)SPK=102; if (game.prop[BEAR] == 0)SPK=102;
if (game.prop[BEAR] == 3)SPK=110; if (game.prop[BEAR] == 3)SPK=110;
if (!HERE(FOOD)) if (!HERE(FOOD)) {
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
}
DSTROY(FOOD); DSTROY(FOOD);
game.prop[BEAR]=1; game.prop[BEAR]=1;
game.fixed[AXE]=0; game.fixed[AXE]=0;
game.prop[AXE]=0; game.prop[AXE]=0;
SPK=168; SPK=168;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
if (obj == OGRE) { if (obj == OGRE) {
if (HERE(FOOD)) if (HERE(FOOD))
SPK=202; SPK=202;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
SPK=14; SPK=14;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
int fill(long obj) int fill(long obj)
@ -476,8 +507,10 @@ int fill(long obj)
if (obj == VASE) { if (obj == VASE) {
SPK=29; SPK=29;
if (LIQLOC(game.loc) == 0)SPK=144; if (LIQLOC(game.loc) == 0)SPK=144;
if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) {
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
}
RSPEAK(145); RSPEAK(145);
game.prop[VASE]=2; game.prop[VASE]=2;
game.fixed[VASE]= -1; game.fixed[VASE]= -1;
@ -494,11 +527,14 @@ int fill(long obj)
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];
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
if (obj != 0 && obj != BOTTLE) if (obj != 0 && obj != BOTTLE) {
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
}
if (obj == 0 && !HERE(BOTTLE)) if (obj == 0 && !HERE(BOTTLE))
return(8000); return(8000);
SPK=107; SPK=107;
@ -516,7 +552,8 @@ int fill(long obj)
game.place[k]= -1; game.place[k]= -1;
if (k == OIL) if (k == OIL)
SPK=108; SPK=108;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
static int find(token_t obj) static int find(token_t obj)
@ -529,7 +566,8 @@ static int find(token_t obj)
SPK=94; SPK=94;
if (game.closed)SPK=138; if (game.closed)SPK=138;
if (TOTING(obj))SPK=24; if (TOTING(obj))SPK=24;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
static int fly(token_t obj) static int fly(token_t obj)
@ -538,11 +576,17 @@ static int fly(token_t obj)
if (obj == INTRANSITIVE) { if (obj == INTRANSITIVE) {
if (game.prop[RUG] != 2)SPK=224; if (game.prop[RUG] != 2)SPK=224;
if (!HERE(RUG))SPK=225; if (!HERE(RUG))SPK=225;
if (SPK/2 == 112) {RSPEAK(SPK); return 2012;} if (SPK/2 == 112) {
RSPEAK(SPK);
return 2012;
}
obj=RUG; obj=RUG;
} }
if (obj != RUG) {RSPEAK(SPK); return 2012;} if (obj != RUG) {
RSPEAK(SPK);
return 2012;
}
SPK=223; SPK=223;
if (game.prop[RUG] != 2) {RSPEAK(SPK); return 2012;} if (game.prop[RUG] != 2) {RSPEAK(SPK); return 2012;}
game.oldlc2=game.oldloc; game.oldlc2=game.oldloc;
@ -570,7 +614,8 @@ static int inven(token_t obj)
} }
if (TOTING(BEAR)) if (TOTING(BEAR))
SPK=141; SPK=141;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
int light(token_t obj) int light(token_t obj)
@ -579,7 +624,7 @@ int light(token_t obj)
if (obj == INTRANSITIVE) { if (obj == INTRANSITIVE) {
if (HERE(LAMP) && game.prop[LAMP] == 0 && game.limit >= 0)obj=LAMP; if (HERE(LAMP) && game.prop[LAMP] == 0 && game.limit >= 0)obj=LAMP;
if (HERE(URN) && game.prop[URN] == 1)obj=obj*NOBJECTS+URN; if (HERE(URN) && game.prop[URN] == 1)obj=obj*NOBJECTS+URN;
if (obj == 0 || obj > NOBJECTS) return(8000); if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return(8000);
} }
if (obj == URN) { if (obj == URN) {
@ -588,14 +633,23 @@ int light(token_t obj)
{RSPEAK(SPK); return 2012;} {RSPEAK(SPK); return 2012;}
SPK=209; SPK=209;
game.prop[URN]=2; game.prop[URN]=2;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} else { } else {
if (obj != LAMP) {RSPEAK(SPK); return 2012;} if (obj != LAMP)
{
RSPEAK(SPK);
return 2012;
}
SPK=184; SPK=184;
if (game.limit < 0) {RSPEAK(SPK); return 2012;} if (game.limit < 0) {
RSPEAK(SPK);
return 2012;
}
game.prop[LAMP]=1; game.prop[LAMP]=1;
RSPEAK(39); RSPEAK(39);
if (game.wzdark) return(2000); if (game.wzdark)
return(2000);
return(2012); return(2012);
} }
} }
@ -620,7 +674,8 @@ static int listen(void)
if (i == BIRD && OBJSND[i]+game.prop[i] == 8) if (i == BIRD && OBJSND[i]+game.prop[i] == 8)
DSTROY(BIRD); DSTROY(BIRD);
} }
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
static int lock(token_t verb, token_t obj) static int lock(token_t verb, token_t obj)
@ -647,20 +702,25 @@ static int lock(token_t verb, token_t obj)
if (obj == CAGE)SPK=32; if (obj == CAGE)SPK=32;
if (obj == KEYS)SPK=55; if (obj == KEYS)SPK=55;
if (obj == GRATE || obj == CHAIN)SPK=31; if (obj == GRATE || obj == CHAIN)SPK=31;
if (SPK != 31 || !HERE(KEYS)) {RSPEAK(SPK); return 2012;} if (SPK != 31 || !HERE(KEYS)) {
RSPEAK(SPK);
return 2012;
}
if (obj == CHAIN) if (obj == CHAIN)
return chain(verb); return chain(verb);
if (game.closng) { if (game.closng) {
SPK=130; SPK=130;
if (!game.panic)game.clock2=15; if (!game.panic)game.clock2=15;
game.panic=true; game.panic=true;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
SPK=34+game.prop[GRATE]; SPK=34+game.prop[GRATE];
game.prop[GRATE]=1; game.prop[GRATE]=1;
if (verb == LOCK)game.prop[GRATE]=0; if (verb == LOCK)game.prop[GRATE]=0;
SPK=SPK+2*game.prop[GRATE]; SPK=SPK+2*game.prop[GRATE];
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
static int pour(token_t obj) static int pour(token_t obj)
@ -691,7 +751,8 @@ static int pour(token_t obj)
game.prop[DOOR]=0; game.prop[DOOR]=0;
if (obj == OIL)game.prop[DOOR]=1; if (obj == OIL)game.prop[DOOR]=1;
SPK=113+game.prop[DOOR]; SPK=113+game.prop[DOOR];
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
} }
@ -755,7 +816,8 @@ static int rub(token_t obj)
--game.tally; --game.tally;
DROP(CAVITY,game.loc); DROP(CAVITY,game.loc);
SPK=216; SPK=216;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
static int say(void) static int say(void)
@ -770,7 +832,7 @@ static int say(void)
return(2630); return(2630);
} }
RSPEAK(258); RSPEAK(258);
return(2012); return 2012;
} }
@ -800,7 +862,8 @@ static int throw(FILE *cmdin, long verb, long obj)
DROP(TROLL2,PLAC[TROLL]); DROP(TROLL2,PLAC[TROLL]);
DROP(TROLL2+NOBJECTS,FIXD[TROLL]); DROP(TROLL2+NOBJECTS,FIXD[TROLL]);
JUGGLE(CHASM); JUGGLE(CHASM);
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} }
if (obj == FOOD && HERE(BEAR)) { if (obj == FOOD && HERE(BEAR)) {
/* But throwing food is another story. */ /* But throwing food is another story. */
@ -852,7 +915,7 @@ static int vscore(void)
/* Score. Call scoring routine but tell it to return. */ /* Score. Call scoring routine but tell it to return. */
{ {
score(-1); score(-1);
return(2012); return 2012;
} }
static int wake(token_t obj) static int wake(token_t obj)
@ -869,22 +932,25 @@ static int wave(token_t obj)
if ((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2)))SPK=29; if ((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2)))SPK=29;
if (obj != ROD || if (obj != ROD ||
!TOTING(obj) || !TOTING(obj) ||
(!HERE(BIRD) && (game.closng || !AT(FISSUR)))) (!HERE(BIRD) && (game.closng || !AT(FISSUR)))) {
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
}
if (HERE(BIRD))SPK=206+MOD(game.prop[BIRD],2); if (HERE(BIRD))SPK=206+MOD(game.prop[BIRD],2);
if (SPK == 206 && game.loc == game.place[STEPS] && game.prop[JADE] < 0) { if (SPK == 206 && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
DROP(JADE,game.loc); DROP(JADE,game.loc);
game.prop[JADE]=0; game.prop[JADE]=0;
--game.tally; --game.tally;
SPK=208; SPK=208;
{RSPEAK(SPK); return 2012;} RSPEAK(SPK);
return 2012;
} else { } else {
if (game.closed) return(18999); if (game.closed) return(18999);
if (game.closng || !AT(FISSUR)) {RSPEAK(SPK); return 2012;} if (game.closng || !AT(FISSUR)) {RSPEAK(SPK); return 2012;}
if (HERE(BIRD))RSPEAK(SPK); if (HERE(BIRD))RSPEAK(SPK);
game.prop[FISSUR]=1-game.prop[FISSUR]; game.prop[FISSUR]=1-game.prop[FISSUR];
PSPEAK(FISSUR,2-game.prop[FISSUR]); PSPEAK(FISSUR,2-game.prop[FISSUR]);
return(2012); return 2012;
} }
} }