Magic-number elimination.
This commit is contained in:
parent
d61cab352e
commit
dc6a5751ed
3 changed files with 10 additions and 8 deletions
2
advent.h
2
advent.h
|
@ -12,6 +12,7 @@
|
|||
#define MAXPARMS 25
|
||||
#define INVLIMIT 7
|
||||
#define INTRANSITIVE -1 /* illegal object number */
|
||||
#define SPECIALBASE 300 /* base umber of special rooms */
|
||||
|
||||
typedef struct lcg_state
|
||||
{
|
||||
|
@ -146,6 +147,7 @@ extern int saveresume(FILE *, bool);
|
|||
#define GSTONE(OBJ) ((OBJ) == EMRALD || (OBJ) == RUBY || (OBJ) == AMBER || (OBJ) == SAPPH)
|
||||
#define FOREST(LOC) ((LOC) >= 145 && (LOC) <= 166)
|
||||
#define VOCWRD(LETTRS,SECT) (VOCAB(MAKEWD(LETTRS),SECT))
|
||||
#define SPECIAL(LOC) ((LOC) > SPECIALBASE)
|
||||
|
||||
/* The following two functions were added to fix a bug (game.clock1 decremented
|
||||
* while in forest). They should probably be replaced by using another
|
||||
|
|
12
main.c
12
main.c
|
@ -384,8 +384,8 @@ static bool dwarfmove(void)
|
|||
if (kk != 0)
|
||||
do {
|
||||
game.newloc=MOD(labs(TRAVEL[kk])/1000,1000);
|
||||
/* Have we avoided a dwarf enciounter? */
|
||||
bool avoided = (game.newloc > 300 ||
|
||||
/* Have we avoided a dwarf encounter? */
|
||||
bool avoided = (SPECIAL(game.newloc) ||
|
||||
!INDEEP(game.newloc) ||
|
||||
game.newloc == game.odloc[i] ||
|
||||
(j > 1 && game.newloc == TK[j-1]) ||
|
||||
|
@ -529,7 +529,7 @@ static bool playermove(FILE *cmdin, token_t verb, int motion)
|
|||
for (;;) {
|
||||
LL=MOD((labs(TRAVEL[KK])/1000),1000);
|
||||
if (LL != motion) {
|
||||
if (LL <= 300) {
|
||||
if (!SPECIAL(LL)) {
|
||||
if (FORCED(LL) && MOD((labs(TRAVEL[KEY[LL]])/1000),1000) == motion)
|
||||
K2=KK;
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ static bool playermove(FILE *cmdin, token_t verb, int motion)
|
|||
for (;;) {
|
||||
game.newloc=LL/1000;
|
||||
motion=MOD(game.newloc,100);
|
||||
if (game.newloc <= 300) {
|
||||
if (!SPECIAL(game.newloc)) {
|
||||
if (game.newloc <= 100) {
|
||||
if (game.newloc == 0 || PCT(game.newloc))
|
||||
break;
|
||||
|
@ -628,10 +628,10 @@ static bool playermove(FILE *cmdin, token_t verb, int motion)
|
|||
}
|
||||
|
||||
game.newloc=MOD(LL,1000);
|
||||
if (game.newloc <= 300)
|
||||
if (!SPECIAL(game.newloc))
|
||||
return true;
|
||||
if (game.newloc <= 500) {
|
||||
game.newloc=game.newloc-300;
|
||||
game.newloc=game.newloc-SPECIALBASE;
|
||||
switch (game.newloc)
|
||||
{
|
||||
case 1:
|
||||
|
|
2
misc.c
2
misc.c
|
@ -367,7 +367,7 @@ void MOVE(long object, long where)
|
|||
from=game.fixed[object-NOBJECTS];
|
||||
else
|
||||
from=game.place[object];
|
||||
if (from > 0 && from <= 300)
|
||||
if (from > 0 && !SPECIAL(from))
|
||||
CARRY(object,from);
|
||||
DROP(object,where);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue