Magic-number elimination.
This commit is contained in:
parent
1329da1087
commit
d97574d35c
4 changed files with 19 additions and 25 deletions
30
actions.c
30
actions.c
|
@ -48,7 +48,7 @@ static int attack(FILE *input, long verb, token_t obj)
|
||||||
RSPEAK(spk);
|
RSPEAK(spk);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
DSTROY(BIRD);
|
DESTROY(BIRD);
|
||||||
game.prop[BIRD]=0;
|
game.prop[BIRD]=0;
|
||||||
spk=BIRD_DEAD;
|
spk=BIRD_DEAD;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ static int attack(FILE *input, long verb, token_t obj)
|
||||||
if (obj == OGRE && d > 0) {
|
if (obj == OGRE && d > 0) {
|
||||||
RSPEAK(spk);
|
RSPEAK(spk);
|
||||||
RSPEAK(KNIFE_THROWN);
|
RSPEAK(KNIFE_THROWN);
|
||||||
DSTROY(OGRE);
|
DESTROY(OGRE);
|
||||||
int dwarves=0;
|
int dwarves=0;
|
||||||
for (int i=1; i < PIRATE; i++) {
|
for (int i=1; i < PIRATE; i++) {
|
||||||
if (game.dloc[i] == game.loc) {
|
if (game.dloc[i] == game.loc) {
|
||||||
|
@ -159,7 +159,7 @@ static int bivalve(token_t verb, token_t obj)
|
||||||
if (!TOTING(TRIDNT))spk= is_oyster ? OYSTER_OPENER : CLAM_OPENER;
|
if (!TOTING(TRIDNT))spk= is_oyster ? OYSTER_OPENER : CLAM_OPENER;
|
||||||
if (verb == LOCK)spk=HUH_MAN;
|
if (verb == LOCK)spk=HUH_MAN;
|
||||||
if (spk == PEARL_FALLS) {
|
if (spk == PEARL_FALLS) {
|
||||||
DSTROY(CLAM);
|
DESTROY(CLAM);
|
||||||
DROP(OYSTER,game.loc);
|
DROP(OYSTER,game.loc);
|
||||||
DROP(PEARL,LOC_CULDESAC);
|
DROP(PEARL,LOC_CULDESAC);
|
||||||
}
|
}
|
||||||
|
@ -241,7 +241,7 @@ static int carry(token_t verb, token_t obj)
|
||||||
if (obj == SIGN)spk=HAND_PASSTHROUGH;
|
if (obj == SIGN)spk=HAND_PASSTHROUGH;
|
||||||
if (obj == MESSAG) {
|
if (obj == MESSAG) {
|
||||||
RSPEAK(REMOVE_MESSAGE);
|
RSPEAK(REMOVE_MESSAGE);
|
||||||
DSTROY(MESSAG);
|
DESTROY(MESSAG);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
if (game.fixed[obj] != 0) {
|
if (game.fixed[obj] != 0) {
|
||||||
|
@ -267,7 +267,7 @@ static int carry(token_t verb, token_t obj)
|
||||||
}
|
}
|
||||||
else if (obj == BIRD && game.prop[BIRD] != 1 && -1-game.prop[BIRD] != 1) {
|
else if (obj == BIRD && game.prop[BIRD] != 1 && -1-game.prop[BIRD] != 1) {
|
||||||
if (game.prop[BIRD] == 2) {
|
if (game.prop[BIRD] == 2) {
|
||||||
DSTROY(BIRD);
|
DESTROY(BIRD);
|
||||||
RSPEAK(BIRD_CRAP);
|
RSPEAK(BIRD_CRAP);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
|
@ -333,7 +333,7 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
|
||||||
if (obj == BIRD && HERE(SNAKE)) {
|
if (obj == BIRD && HERE(SNAKE)) {
|
||||||
RSPEAK(BIRD_ATTACKS);
|
RSPEAK(BIRD_ATTACKS);
|
||||||
if (game.closed) return GO_DWARFWAKE;
|
if (game.closed) return GO_DWARFWAKE;
|
||||||
DSTROY(SNAKE);
|
DESTROY(SNAKE);
|
||||||
/* Set game.prop for use by travel options */
|
/* Set game.prop for use by travel options */
|
||||||
game.prop[SNAKE]=1;
|
game.prop[SNAKE]=1;
|
||||||
|
|
||||||
|
@ -355,13 +355,13 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (obj == COINS && HERE(VEND)) {
|
} else if (obj == COINS && HERE(VEND)) {
|
||||||
DSTROY(COINS);
|
DESTROY(COINS);
|
||||||
DROP(BATTER,game.loc);
|
DROP(BATTER,game.loc);
|
||||||
PSPEAK(BATTER,0);
|
PSPEAK(BATTER,0);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
} else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == 0) {
|
} else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == 0) {
|
||||||
RSPEAK(BIRD_BURNT);
|
RSPEAK(BIRD_BURNT);
|
||||||
DSTROY(BIRD);
|
DESTROY(BIRD);
|
||||||
game.prop[BIRD]=0;
|
game.prop[BIRD]=0;
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
} else if (obj == BEAR && AT(TROLL)) {
|
} else if (obj == BEAR && AT(TROLL)) {
|
||||||
|
@ -408,7 +408,7 @@ static int drink(token_t verb, token_t obj)
|
||||||
spk=BOTTLE_EMPTY;
|
spk=BOTTLE_EMPTY;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DSTROY(BLOOD);
|
DESTROY(BLOOD);
|
||||||
game.prop[DRAGON]=2;
|
game.prop[DRAGON]=2;
|
||||||
OBJSND[BIRD]=OBJSND[BIRD]+3;
|
OBJSND[BIRD]=OBJSND[BIRD]+3;
|
||||||
spk=HEAD_BUZZES;
|
spk=HEAD_BUZZES;
|
||||||
|
@ -425,11 +425,11 @@ static int eat(token_t verb, token_t obj)
|
||||||
if (obj == INTRANSITIVE) {
|
if (obj == INTRANSITIVE) {
|
||||||
if (!HERE(FOOD))
|
if (!HERE(FOOD))
|
||||||
return GO_UNKNOWN;
|
return GO_UNKNOWN;
|
||||||
DSTROY(FOOD);
|
DESTROY(FOOD);
|
||||||
spk=THANKS_DELICIOUS;
|
spk=THANKS_DELICIOUS;
|
||||||
} else {
|
} else {
|
||||||
if (obj == FOOD) {
|
if (obj == FOOD) {
|
||||||
DSTROY(FOOD);
|
DESTROY(FOOD);
|
||||||
spk=THANKS_DELICIOUS;
|
spk=THANKS_DELICIOUS;
|
||||||
}
|
}
|
||||||
if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj ==
|
if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj ==
|
||||||
|
@ -479,7 +479,7 @@ static int feed(token_t verb, token_t obj)
|
||||||
if (obj == DRAGON && game.prop[DRAGON] != 0)spk=RIDICULOUS_ATTEMPT;
|
if (obj == DRAGON && game.prop[DRAGON] != 0)spk=RIDICULOUS_ATTEMPT;
|
||||||
if (obj == TROLL)spk=TROLL_VICES;
|
if (obj == TROLL)spk=TROLL_VICES;
|
||||||
if (obj == SNAKE && !game.closed && HERE(BIRD)) {
|
if (obj == SNAKE && !game.closed && HERE(BIRD)) {
|
||||||
DSTROY(BIRD);
|
DESTROY(BIRD);
|
||||||
game.prop[BIRD]=0;
|
game.prop[BIRD]=0;
|
||||||
spk = BIRD_DEVOURED;
|
spk = BIRD_DEVOURED;
|
||||||
}
|
}
|
||||||
|
@ -494,7 +494,7 @@ static int feed(token_t verb, token_t obj)
|
||||||
if (game.prop[BEAR] == 0)spk=NOTHING_EDIBLE;
|
if (game.prop[BEAR] == 0)spk=NOTHING_EDIBLE;
|
||||||
if (game.prop[BEAR] == 3)spk=RIDICULOUS_ATTEMPT;
|
if (game.prop[BEAR] == 3)spk=RIDICULOUS_ATTEMPT;
|
||||||
if (HERE(FOOD)) {
|
if (HERE(FOOD)) {
|
||||||
DSTROY(FOOD);
|
DESTROY(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;
|
||||||
|
@ -688,7 +688,7 @@ static int listen(void)
|
||||||
PSPEAK(i,OBJSND[i]+game.prop[i]);
|
PSPEAK(i,OBJSND[i]+game.prop[i]);
|
||||||
spk=ARB_0;
|
spk=ARB_0;
|
||||||
if (i == BIRD && OBJSND[i]+game.prop[i] == 8)
|
if (i == BIRD && OBJSND[i]+game.prop[i] == 8)
|
||||||
DSTROY(BIRD);
|
DESTROY(BIRD);
|
||||||
}
|
}
|
||||||
RSPEAK(spk);
|
RSPEAK(spk);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
|
@ -836,7 +836,7 @@ static int rub(token_t verb, token_t obj)
|
||||||
if (obj != LAMP)
|
if (obj != LAMP)
|
||||||
spk=PECULIAR_NOTHING;
|
spk=PECULIAR_NOTHING;
|
||||||
if (obj == URN && game.prop[URN] == 2) {
|
if (obj == URN && game.prop[URN] == 2) {
|
||||||
DSTROY(URN);
|
DESTROY(URN);
|
||||||
DROP(AMBER,game.loc);
|
DROP(AMBER,game.loc);
|
||||||
game.prop[AMBER]=1;
|
game.prop[AMBER]=1;
|
||||||
--game.tally;
|
--game.tally;
|
||||||
|
|
4
advent.h
4
advent.h
|
@ -94,7 +94,6 @@ extern long GETTXT(bool,bool,bool);
|
||||||
extern token_t MAKEWD(long);
|
extern token_t MAKEWD(long);
|
||||||
extern void TYPE0(void);
|
extern void TYPE0(void);
|
||||||
extern long VOCAB(long,long);
|
extern long VOCAB(long,long);
|
||||||
extern void DSTROY(long);
|
|
||||||
extern void JUGGLE(long);
|
extern void JUGGLE(long);
|
||||||
extern void MOVE(long,long);
|
extern void MOVE(long,long);
|
||||||
extern long PUT(long,long,long);
|
extern long PUT(long,long,long);
|
||||||
|
@ -131,6 +130,7 @@ extern int saveresume(FILE *, bool);
|
||||||
* PCT(N) = true N% of the time (N integer from 0 to 100)
|
* PCT(N) = true N% of the time (N integer from 0 to 100)
|
||||||
* TOTING(OBJ) = true if the OBJ is being carried */
|
* TOTING(OBJ) = true if the OBJ is being carried */
|
||||||
|
|
||||||
|
#define DESTROY(N) MOVE(N, NOWHERE)
|
||||||
#define MOD(N,M) ((N) % (M))
|
#define MOD(N,M) ((N) % (M))
|
||||||
#define TOTING(OBJ) (game.place[OBJ] == CARRIED)
|
#define TOTING(OBJ) (game.place[OBJ] == CARRIED)
|
||||||
#define AT(OBJ) (game.place[OBJ] == game.loc || game.fixed[OBJ] == game.loc)
|
#define AT(OBJ) (game.place[OBJ] == game.loc || game.fixed[OBJ] == game.loc)
|
||||||
|
@ -141,7 +141,7 @@ extern int saveresume(FILE *, bool);
|
||||||
#define CNDBIT(L,N) (TSTBIT(COND[L],N))
|
#define CNDBIT(L,N) (TSTBIT(COND[L],N))
|
||||||
#define FORCED(LOC) (COND[LOC] == 2)
|
#define FORCED(LOC) (COND[LOC] == 2)
|
||||||
#define DARK(DUMMY) ((!CNDBIT(game.loc,LIGHT)) && (game.prop[LAMP] == 0 || !HERE(LAMP)))
|
#define DARK(DUMMY) ((!CNDBIT(game.loc,LIGHT)) && (game.prop[LAMP] == 0 || !HERE(LAMP)))
|
||||||
#define PCT(N) (randrange(100) < (N))
|
#define PCT(N) (randrange(100) < (N))
|
||||||
#define GSTONE(OBJ) ((OBJ) == EMRALD || (OBJ) == RUBY || (OBJ) == AMBER || (OBJ) == SAPPH)
|
#define GSTONE(OBJ) ((OBJ) == EMRALD || (OBJ) == RUBY || (OBJ) == AMBER || (OBJ) == SAPPH)
|
||||||
#define FOREST(LOC) ((LOC) >= LOC_FOREST1 && (LOC) <= LOC_FOREST22)
|
#define FOREST(LOC) ((LOC) >= LOC_FOREST1 && (LOC) <= LOC_FOREST22)
|
||||||
#define VOCWRD(LETTRS,SECT) (VOCAB(MAKEWD(LETTRS),SECT))
|
#define VOCWRD(LETTRS,SECT) (VOCAB(MAKEWD(LETTRS),SECT))
|
||||||
|
|
4
main.c
4
main.c
|
@ -754,7 +754,7 @@ static bool closecheck(void)
|
||||||
MOVE(TROLL2,PLAC[TROLL]);
|
MOVE(TROLL2,PLAC[TROLL]);
|
||||||
MOVE(TROLL2+NOBJECTS,FIXD[TROLL]);
|
MOVE(TROLL2+NOBJECTS,FIXD[TROLL]);
|
||||||
JUGGLE(CHASM);
|
JUGGLE(CHASM);
|
||||||
if (game.prop[BEAR] != 3)DSTROY(BEAR);
|
if (game.prop[BEAR] != 3)DESTROY(BEAR);
|
||||||
game.prop[CHAIN]=0;
|
game.prop[CHAIN]=0;
|
||||||
game.fixed[CHAIN]=0;
|
game.fixed[CHAIN]=0;
|
||||||
game.prop[AXE]=0;
|
game.prop[AXE]=0;
|
||||||
|
@ -807,7 +807,7 @@ static bool closecheck(void)
|
||||||
|
|
||||||
for (int i=1; i<=NOBJECTS; i++) {
|
for (int i=1; i<=NOBJECTS; i++) {
|
||||||
if (TOTING(i))
|
if (TOTING(i))
|
||||||
DSTROY(i);
|
DESTROY(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
RSPEAK(CAVE_CLOSED);
|
RSPEAK(CAVE_CLOSED);
|
||||||
|
|
6
misc.c
6
misc.c
|
@ -337,12 +337,6 @@ long VOCAB(long id, long init)
|
||||||
BUG(21);
|
BUG(21);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSTROY(long object)
|
|
||||||
/* Permanently eliminate "object" by moving to a non-existent location. */
|
|
||||||
{
|
|
||||||
MOVE(object,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void JUGGLE(long object)
|
void JUGGLE(long object)
|
||||||
/* Juggle an object by picking it up and putting it down again, the purpose
|
/* Juggle an object by picking it up and putting it down again, the purpose
|
||||||
* being to get the object to the front of the chain of things at its loc. */
|
* being to get the object to the front of the chain of things at its loc. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue